Debian Codegraph @

hyprtester/src/tests/main/persistent.cpp

raw
1 #include "tests.hpp"
2 #include "../../shared.hpp"
3 #include "../../hyprctlCompat.hpp"
4 #include <hyprutils/os/Process.hpp>
5 #include <hyprutils/memory/WeakPtr.hpp>
6
7 using namespace Hyprutils::OS;
8 using namespace Hyprutils::Memory;
9
10 #define UP CUniquePointer
11 #define SP CSharedPointer
12
13 TEST_CASE(persistentWorkspaces) {
14 // test on workspace "window"
15 NLog::log("{}Switching to workspace 1", Colors::YELLOW);
16 getFromSocket("/dispatch hl.dsp.focus({ workspace = '1' })"); // no OK: we might be on 1 already
17
18 OK(getFromSocket("/eval hl.workspace_rule({ workspace = '5', monitor = 'HEADLESS-2', persistent = true })"));
19 OK(getFromSocket("/eval hl.workspace_rule({ workspace = '6', monitor = 'HEADLESS-PERSISTENT-TEST', persistent = true })"));
20 OK(getFromSocket("/eval hl.workspace_rule({ workspace = 'name:PERSIST', monitor = 'HEADLESS-PERSISTENT-TEST', persistent = true })"));
21 OK(getFromSocket("/eval hl.workspace_rule({ workspace = 'name:PERSIST-2', monitor = 'HEADLESS-PERSISTENT-TEST', persistent = true })"));
22
23 {
24 auto str = getFromSocket("/workspaces");
25 EXPECT_CONTAINS(str, "ID 5 (5)");
26 EXPECT_COUNT_STRING(str, "workspace ID ", 2);
27 }
28
29 OK(getFromSocket("/output create headless HEADLESS-PERSISTENT-TEST"));
30
31 {
32 auto str = getFromSocket("/monitors");
33 ASSERT_CONTAINS(str, "HEADLESS-PERSISTENT-TEST");
34 }
35
36 OK(getFromSocket("/dispatch hl.dsp.focus({ monitor = 'HEADLESS-PERSISTENT-TEST' })"));
37
38 {
39 auto str = getFromSocket("/workspaces");
40 EXPECT_CONTAINS(str, "ID 2 (2)"); // this should be automatically generated by hl
41 EXPECT_CONTAINS(str, "ID 5 (5)");
42 EXPECT_CONTAINS(str, "ID 6 (6)");
43 EXPECT_CONTAINS(str, "(PERSIST) on monitor");
44 EXPECT_CONTAINS(str, "(PERSIST-2) on monitor");
45 EXPECT_COUNT_STRING(str, "workspace ID ", 6);
46 }
47
48 OK(getFromSocket("/reload"));
49
50 {
51 auto str = getFromSocket("/workspaces");
52 EXPECT_NOT_CONTAINS(str, "ID 5 (5)");
53 EXPECT_NOT_CONTAINS(str, "ID 6 (6)");
54 EXPECT_NOT_CONTAINS(str, "(PERSIST) on monitor");
55 EXPECT_COUNT_STRING(str, "workspace ID ", 2);
56 }
57
58 OK(getFromSocket("/output remove HEADLESS-PERSISTENT-TEST"));
59 }