66#include < chrono>
77#include < hyprutils/os/Process.hpp>
88#include < hyprutils/memory/WeakPtr.hpp>
9+ #include < hyprutils/utils/ScopeGuard.hpp>
910#include < csignal>
1011#include < cerrno>
1112#include " ../shared.hpp"
@@ -14,10 +15,99 @@ static int ret = 0;
1415
1516using namespace Hyprutils ::OS;
1617using namespace Hyprutils ::Memory;
18+ using namespace Hyprutils ::Utils;
1719
1820#define UP CUniquePointer
1921#define SP CSharedPointer
2022
23+ static bool testAsymmetricGaps () {
24+ NLog::log (" {}Testing asymmetric gap splits" , Colors::YELLOW);
25+ {
26+
27+ CScopeGuard guard = {[&]() {
28+ NLog::log (" {}Cleaning up asymmetric gap test" , Colors::YELLOW);
29+ Tests::killAllWindows ();
30+ OK (getFromSocket (" /reload" ));
31+ }};
32+
33+ OK (getFromSocket (" /dispatch workspace name:gap_split_test" ));
34+ OK (getFromSocket (" r/keyword general:gaps_in 0" ));
35+ OK (getFromSocket (" r/keyword general:border_size 0" ));
36+ OK (getFromSocket (" r/keyword dwindle:split_width_multiplier 1.0" ));
37+ OK (getFromSocket (" r/keyword workspace name:gap_split_test,gapsout:0 1000 0 0" ));
38+
39+ NLog::log (" {}Testing default split (force_split = 0)" , Colors::YELLOW);
40+ OK (getFromSocket (" r/keyword dwindle:force_split 0" ));
41+
42+ if (!Tests::spawnKitty (" gaps_kitty_A" ) || !Tests::spawnKitty (" gaps_kitty_B" ))
43+ return false ;
44+
45+ NLog::log (" {}Expecting vertical split (B below A)" , Colors::YELLOW);
46+ OK (getFromSocket (" /dispatch focuswindow class:gaps_kitty_A" ));
47+ EXPECT_CONTAINS (getFromSocket (" /activewindow" ), " at: 0,0" );
48+ OK (getFromSocket (" /dispatch focuswindow class:gaps_kitty_B" ));
49+ EXPECT_CONTAINS (getFromSocket (" /activewindow" ), " at: 0,540" );
50+
51+ Tests::killAllWindows ();
52+ EXPECT (Tests::windowCount (), 0 );
53+
54+ NLog::log (" {}Testing force_split = 1" , Colors::YELLOW);
55+ OK (getFromSocket (" r/keyword dwindle:force_split 1" ));
56+
57+ if (!Tests::spawnKitty (" gaps_kitty_A" ) || !Tests::spawnKitty (" gaps_kitty_B" ))
58+ return false ;
59+
60+ NLog::log (" {}Expecting vertical split (B above A)" , Colors::YELLOW);
61+ OK (getFromSocket (" /dispatch focuswindow class:gaps_kitty_B" ));
62+ EXPECT_CONTAINS (getFromSocket (" /activewindow" ), " at: 0,0" );
63+ OK (getFromSocket (" /dispatch focuswindow class:gaps_kitty_A" ));
64+ EXPECT_CONTAINS (getFromSocket (" /activewindow" ), " at: 0,540" );
65+
66+ NLog::log (" {}Expecting horizontal split (C left of B)" , Colors::YELLOW);
67+ OK (getFromSocket (" /dispatch focuswindow class:gaps_kitty_B" ));
68+
69+ if (!Tests::spawnKitty (" gaps_kitty_C" ))
70+ return false ;
71+
72+ OK (getFromSocket (" /dispatch focuswindow class:gaps_kitty_C" ));
73+ EXPECT_CONTAINS (getFromSocket (" /activewindow" ), " at: 0,0" );
74+ OK (getFromSocket (" /dispatch focuswindow class:gaps_kitty_B" ));
75+ EXPECT_CONTAINS (getFromSocket (" /activewindow" ), " at: 460,0" );
76+
77+ Tests::killAllWindows ();
78+ EXPECT (Tests::windowCount (), 0 );
79+
80+ NLog::log (" {}Testing force_split = 2" , Colors::YELLOW);
81+ OK (getFromSocket (" r/keyword dwindle:force_split 2" ));
82+
83+ if (!Tests::spawnKitty (" gaps_kitty_A" ) || !Tests::spawnKitty (" gaps_kitty_B" ))
84+ return false ;
85+
86+ NLog::log (" {}Expecting vertical split (B below A)" , Colors::YELLOW);
87+ OK (getFromSocket (" /dispatch focuswindow class:gaps_kitty_A" ));
88+ EXPECT_CONTAINS (getFromSocket (" /activewindow" ), " at: 0,0" );
89+ OK (getFromSocket (" /dispatch focuswindow class:gaps_kitty_B" ));
90+ EXPECT_CONTAINS (getFromSocket (" /activewindow" ), " at: 0,540" );
91+
92+ NLog::log (" {}Expecting horizontal split (C right of A)" , Colors::YELLOW);
93+ OK (getFromSocket (" /dispatch focuswindow class:gaps_kitty_A" ));
94+
95+ if (!Tests::spawnKitty (" gaps_kitty_C" ))
96+ return false ;
97+
98+ OK (getFromSocket (" /dispatch focuswindow class:gaps_kitty_A" ));
99+ EXPECT_CONTAINS (getFromSocket (" /activewindow" ), " at: 0,0" );
100+ OK (getFromSocket (" /dispatch focuswindow class:gaps_kitty_C" ));
101+ EXPECT_CONTAINS (getFromSocket (" /activewindow" ), " at: 460,0" );
102+ }
103+
104+ // kill all
105+ NLog::log (" {}Killing all windows" , Colors::YELLOW);
106+ Tests::killAllWindows ();
107+
108+ return true ;
109+ }
110+
21111static bool test () {
22112 NLog::log (" {}Testing workspaces" , Colors::GREEN);
23113
@@ -359,6 +449,8 @@ static bool test() {
359449 NLog::log (" {}Killing all windows" , Colors::YELLOW);
360450 Tests::killAllWindows ();
361451
452+ testAsymmetricGaps ();
453+
362454 NLog::log (" {}Expecting 0 windows" , Colors::YELLOW);
363455 EXPECT (Tests::windowCount (), 0 );
364456
0 commit comments