summaryrefslogtreecommitdiff
path: root/hyprtester/src/tests/main/workspaces.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-12-05 14:16:22 +0000
committerGitHub <noreply@github.com>2025-12-05 14:16:22 +0000
commit9264436f35e2c4e94adfdf2a8ea23a346ace3a65 (patch)
tree9fe48ff4728060445e655d8a3b528999fd124ff8 /hyprtester/src/tests/main/workspaces.cpp
parentd5c52ef58e57b371a9df8fd4404c5d55a1b26f34 (diff)
desktop: rewrite reserved area handling + improve tests (#12383)
Diffstat (limited to 'hyprtester/src/tests/main/workspaces.cpp')
-rw-r--r--hyprtester/src/tests/main/workspaces.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/hyprtester/src/tests/main/workspaces.cpp b/hyprtester/src/tests/main/workspaces.cpp
index 622236dc..c1b9690a 100644
--- a/hyprtester/src/tests/main/workspaces.cpp
+++ b/hyprtester/src/tests/main/workspaces.cpp
@@ -6,6 +6,7 @@
#include <chrono>
#include <hyprutils/os/Process.hpp>
#include <hyprutils/memory/WeakPtr.hpp>
+#include <hyprutils/utils/ScopeGuard.hpp>
#include <csignal>
#include <cerrno>
#include "../shared.hpp"
@@ -14,10 +15,99 @@ static int ret = 0;
using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
+using namespace Hyprutils::Utils;
#define UP CUniquePointer
#define SP CSharedPointer
+static bool testAsymmetricGaps() {
+ NLog::log("{}Testing asymmetric gap splits", Colors::YELLOW);
+ {
+
+ CScopeGuard guard = {[&]() {
+ NLog::log("{}Cleaning up asymmetric gap test", Colors::YELLOW);
+ Tests::killAllWindows();
+ OK(getFromSocket("/reload"));
+ }};
+
+ OK(getFromSocket("/dispatch workspace name:gap_split_test"));
+ OK(getFromSocket("r/keyword general:gaps_in 0"));
+ OK(getFromSocket("r/keyword general:border_size 0"));
+ OK(getFromSocket("r/keyword dwindle:split_width_multiplier 1.0"));
+ OK(getFromSocket("r/keyword workspace name:gap_split_test,gapsout:0 1000 0 0"));
+
+ NLog::log("{}Testing default split (force_split = 0)", Colors::YELLOW);
+ OK(getFromSocket("r/keyword dwindle:force_split 0"));
+
+ if (!Tests::spawnKitty("gaps_kitty_A") || !Tests::spawnKitty("gaps_kitty_B"))
+ return false;
+
+ NLog::log("{}Expecting vertical split (B below A)", Colors::YELLOW);
+ OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
+ EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
+ OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
+ EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,540");
+
+ Tests::killAllWindows();
+ EXPECT(Tests::windowCount(), 0);
+
+ NLog::log("{}Testing force_split = 1", Colors::YELLOW);
+ OK(getFromSocket("r/keyword dwindle:force_split 1"));
+
+ if (!Tests::spawnKitty("gaps_kitty_A") || !Tests::spawnKitty("gaps_kitty_B"))
+ return false;
+
+ NLog::log("{}Expecting vertical split (B above A)", Colors::YELLOW);
+ OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
+ EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
+ OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
+ EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,540");
+
+ NLog::log("{}Expecting horizontal split (C left of B)", Colors::YELLOW);
+ OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
+
+ if (!Tests::spawnKitty("gaps_kitty_C"))
+ return false;
+
+ OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_C"));
+ EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
+ OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
+ EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 460,0");
+
+ Tests::killAllWindows();
+ EXPECT(Tests::windowCount(), 0);
+
+ NLog::log("{}Testing force_split = 2", Colors::YELLOW);
+ OK(getFromSocket("r/keyword dwindle:force_split 2"));
+
+ if (!Tests::spawnKitty("gaps_kitty_A") || !Tests::spawnKitty("gaps_kitty_B"))
+ return false;
+
+ NLog::log("{}Expecting vertical split (B below A)", Colors::YELLOW);
+ OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
+ EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
+ OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
+ EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,540");
+
+ NLog::log("{}Expecting horizontal split (C right of A)", Colors::YELLOW);
+ OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
+
+ if (!Tests::spawnKitty("gaps_kitty_C"))
+ return false;
+
+ OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
+ EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
+ OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_C"));
+ EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 460,0");
+ }
+
+ // kill all
+ NLog::log("{}Killing all windows", Colors::YELLOW);
+ Tests::killAllWindows();
+
+ return true;
+}
+
static bool test() {
NLog::log("{}Testing workspaces", Colors::GREEN);
@@ -359,6 +449,8 @@ static bool test() {
NLog::log("{}Killing all windows", Colors::YELLOW);
Tests::killAllWindows();
+ testAsymmetricGaps();
+
NLog::log("{}Expecting 0 windows", Colors::YELLOW);
EXPECT(Tests::windowCount(), 0);