Debian Codegraph @

hyprtester/src/tests/shared.hpp

raw
1 #pragma once
2
3 #include <hyprutils/os/Process.hpp>
4 #include <hyprutils/memory/WeakPtr.hpp>
5 #include <sys/types.h>
6
7 //NOLINTNEXTLINE
8 namespace Tests {
9 Hyprutils::Memory::CUniquePointer<Hyprutils::OS::CProcess> spawnKitty(const std::string& class_ = "", const std::vector<std::string> args = {});
10 Hyprutils::Memory::CUniquePointer<Hyprutils::OS::CProcess> spawnLayerKitty(const std::string& namespace_ = "", const std::vector<std::string> args = {});
11 bool processAlive(pid_t pid);
12 int windowCount();
13 int countOccurrences(const std::string& in, const std::string& what);
14 void sync(int rounds = 3);
15 bool killAllWindows();
16 void waitUntilWindowsN(int n);
17 int layerCount();
18 bool killAllLayers();
19 std::string execAndGet(const std::string& cmd);
20 bool writeFile(const std::string& name, const std::string& contents);
21 /**
22 * Extracts the given attribute from Hyprland's response to requests such as `/clients`, `/workspaces`, etc.
23 * Automatically appends `: ` to `attr`.
24 *
25 * For example, `Tests::getAttribute(getFromSocket("/activewindow"), "at")` returns the active window's coordinates, e.g., `"2,32"`
26 */
27 std::string getAttribute(const std::string& hyprlandResponse, std::string attr);
28 };