Debian Codegraph @

hyprtester/src/tests/main/solitary.cpp

raw
1 #include "tests.hpp"
2 #include "../../shared.hpp"
3 #include "../../hyprctlCompat.hpp"
4 #include <algorithm>
5 #include <ranges>
6 #include <set>
7 #include <hyprutils/os/Process.hpp>
8 #include <hyprutils/memory/WeakPtr.hpp>
9 #include "../shared.hpp"
10
11 using namespace Hyprutils::OS;
12 using namespace Hyprutils::Memory;
13
14 #define UP CUniquePointer
15 #define SP CSharedPointer
16
17 SUBTEST(expectBlockedByAll, const std::string& blockedByLine, const std::set<std::string>& expectedBlockedBy) {
18 const std::set<std::string> blockedBy = blockedByLine | std::ranges::views::split(',') | std::ranges::to<std::set<std::string>>();
19 NLog::log("blockedBy = {}", blockedBy);
20 NLog::log("expectedBlockedBy = {}", expectedBlockedBy);
21 ASSERT(std::ranges::includes(blockedBy, expectedBlockedBy), true);
22 }
23
24 TEST_CASE(solitaryClients) {
25 OK(getFromSocket("/eval hl.config({ general = { allow_tearing = false } })"));
26 OK(getFromSocket("/eval hl.config({ render = { direct_scanout = 0 } })"));
27 OK(getFromSocket("/eval hl.config({ cursor = { no_hardware_cursors = 1 } })"));
28 NLog::log("{}Expecting blocked solitary/DS/tearing", Colors::YELLOW);
29 {
30 auto str = getFromSocket("/monitors");
31 EXPECT_CONTAINS(str, "solitary: 0\n");
32 CALL_SUBTEST(expectBlockedByAll, Tests::getAttribute(str, "solitaryBlockedBy"), {"windowed mode", "missing candidate"});
33 EXPECT_CONTAINS(str, "activelyTearing: false");
34 CALL_SUBTEST(expectBlockedByAll, Tests::getAttribute(str, "tearingBlockedBy"),
35 {"next frame is not torn", "user settings", "not supported by monitor", "missing candidate"});
36 EXPECT_CONTAINS(str, "directScanoutTo: 0\n");
37 CALL_SUBTEST(expectBlockedByAll, Tests::getAttribute(str, "directScanoutBlockedBy"), {"user settings", "software renders/cursors", "missing candidate"});
38 }
39
40 // FIXME: need a reliable client with solitary opaque surface in fullscreen. kitty doesn't work all the time
41 // NLog::log("{}Spawning kittyProcA", Colors::YELLOW);
42 // auto kittyProcA = Tests::spawnKitty();
43
44 // if (!kittyProcA) {
45 // NLog::log("{}Error: kitty did not spawn", Colors::RED);
46 // return false;
47 // }
48
49 // OK(getFromSocket("/eval hl.config({ general = { allow_tearing = true } })"));
50 // OK(getFromSocket("/eval hl.config({ render = { direct_scanout = 1 } })"));
51 // NLog::log("{}", getFromSocket("/clients"));
52 // OK(getFromSocket("/dispatch hl.dsp.window.fullscreen()"));
53 // NLog::log("{}", getFromSocket("/clients"));
54 // std::this_thread::sleep_for(std::chrono::milliseconds(100));
55 // NLog::log("{}Expecting kitty to almost pass for solitary/DS/tearing", Colors::YELLOW);
56 // {
57 // auto str = getFromSocket("/monitors");
58 // ASSERT_NOT_CONTAINS(str, "solitary: 0\n");
59 // ASSERT_CONTAINS(str, "solitaryBlockedBy: null");
60 // ASSERT_CONTAINS(str, "activelyTearing: false");
61 // ASSERT_CONTAINS(str, "tearingBlockedBy: next frame is not torn,not supported by monitor,window settings");
62 // }
63
64 // OK(getFromSocket("/dispatch hl.dsp.window.set_prop({ window = 'active', prop = 'immediate', value = '1' })"));
65 // NLog::log("{}Expecting kitty to almost pass for tearing", Colors::YELLOW);
66 // {
67 // auto str = getFromSocket("/monitors");
68 // ASSERT_CONTAINS(str, "tearingBlockedBy: next frame is not torn,not supported by monitor\n");
69 // }
70 }