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