summaryrefslogtreecommitdiff
path: root/hyprtester/src/tests/main/window.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-06-26 19:43:39 +0200
committerGitHub <noreply@github.com>2025-06-26 19:43:39 +0200
commit3d6476c9021519995239ec93bbb11f0dce6c60a0 (patch)
tree381edc199f4348e4bb42863b55d47a01e4f550ab /hyprtester/src/tests/main/window.cpp
parent9a67e0421b49596060719566996ee4ca81ae8843 (diff)
Core: Add a test suite (#9297)
Adds a test suite for testing hyprland's features with a runtime tester --------- Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
Diffstat (limited to 'hyprtester/src/tests/main/window.cpp')
-rw-r--r--hyprtester/src/tests/main/window.cpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/hyprtester/src/tests/main/window.cpp b/hyprtester/src/tests/main/window.cpp
new file mode 100644
index 00000000..4eecd68d
--- /dev/null
+++ b/hyprtester/src/tests/main/window.cpp
@@ -0,0 +1,96 @@
+#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"
+
+static int ret = 0;
+
+using namespace Hyprutils::OS;
+using namespace Hyprutils::Memory;
+
+#define UP CUniquePointer
+#define SP CSharedPointer
+
+bool testWindows() {
+ NLog::log("{}Testing windows", Colors::GREEN);
+
+ // test on workspace "window"
+ NLog::log("{}Switching to workspace `window`", Colors::YELLOW);
+ getFromSocket("/dispatch workspace name:window");
+
+ NLog::log("{}Spawning kittyProcA", Colors::YELLOW);
+ auto kittyProcA = Tests::spawnKitty();
+
+ if (!kittyProcA) {
+ NLog::log("{}Error: kitty did not spawn", Colors::RED);
+ return false;
+ }
+
+ NLog::log("{}Expecting 1 window", Colors::YELLOW);
+ EXPECT(Tests::windowCount(), 1);
+
+ // check kitty properties. One kitty should take the entire screen, as this is smart gaps
+ NLog::log("{}Expecting kitty to take up the whole screen", Colors::YELLOW);
+ {
+ auto str = getFromSocket("/clients");
+ EXPECT(str.contains("at: 0,0"), true);
+ EXPECT(str.contains("size: 1920,1080"), true);
+ EXPECT(str.contains("fullscreen: 0"), true);
+ }
+
+ NLog::log("{}Spawning kittyProcB", Colors::YELLOW);
+ auto kittyProcB = Tests::spawnKitty();
+ if (!kittyProcB) {
+ NLog::log("{}Error: kitty did not spawn", Colors::RED);
+ return false;
+ }
+
+ NLog::log("{}Expecting 2 windows", Colors::YELLOW);
+ EXPECT(Tests::windowCount(), 2);
+
+ // open xeyes
+ NLog::log("{}Spawning xeyes", Colors::YELLOW);
+ getFromSocket("/dispatch exec xeyes");
+
+ NLog::log("{}Keep checking if xeyes spawned", Colors::YELLOW);
+ int counter = 0;
+ while (Tests::windowCount() != 3) {
+ counter++;
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+
+ if (counter > 50) {
+ EXPECT(Tests::windowCount(), 3);
+ return !ret;
+ }
+ }
+
+ NLog::log("{}Expecting 3 windows", Colors::YELLOW);
+ EXPECT(Tests::windowCount(), 3);
+
+ NLog::log("{}Checking props of xeyes", Colors::YELLOW);
+ // check some window props of xeyes, try to tile them
+ {
+ auto str = getFromSocket("/clients");
+ EXPECT_CONTAINS(str, "floating: 1");
+ getFromSocket("/dispatch settiled class:XEyes");
+ std::this_thread::sleep_for(std::chrono::milliseconds(200));
+ str = getFromSocket("/clients");
+ EXPECT_NOT_CONTAINS(str, "floating: 1");
+ }
+
+ // kill all
+ NLog::log("{}Killing all windows", Colors::YELLOW);
+ Tests::killAllWindows();
+
+ NLog::log("{}Expecting 0 windows", Colors::YELLOW);
+ EXPECT(Tests::windowCount(), 0);
+
+ return !ret;
+}