diff options
| author | Mike Will <myQwil@gmail.com> | 2025-08-19 14:32:37 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-19 19:32:37 +0100 |
| commit | 10cec2b7e2cd2781121c6ac6b7883cc6f1376d45 (patch) | |
| tree | 2190f47a57c29c3fefbb6627822a4123e3d5a907 /hyprtester/src/tests/main/window.cpp | |
| parent | d0d728c6a6fada8e8c8bee6a5e2e2f76baeddd12 (diff) | |
dwindle: simplify split_bias logic and set of possible values. (#11448)
Diffstat (limited to 'hyprtester/src/tests/main/window.cpp')
| -rw-r--r-- | hyprtester/src/tests/main/window.cpp | 83 |
1 files changed, 53 insertions, 30 deletions
diff --git a/hyprtester/src/tests/main/window.cpp b/hyprtester/src/tests/main/window.cpp index d79e6155..ec4ba20c 100644 --- a/hyprtester/src/tests/main/window.cpp +++ b/hyprtester/src/tests/main/window.cpp @@ -1,22 +1,24 @@ -#include "tests.hpp" -#include "../../shared.hpp" -#include "../../hyprctlCompat.hpp" -#include <print> +#include <cmath> #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; +#include "../../shared.hpp" +#include "../../hyprctlCompat.hpp" +#include "../shared.hpp" +#include "tests.hpp" -using namespace Hyprutils::OS; -using namespace Hyprutils::Memory; +static int ret = 0; -#define UP CUniquePointer -#define SP CSharedPointer +static bool spawnKitty(const std::string& class_) { + NLog::log("{}Spawning {}", Colors::YELLOW, class_); + if (!Tests::spawnKitty(class_)) { + NLog::log("{}Error: {} did not spawn", Colors::RED, class_); + return false; + } + return true; +} static bool test() { NLog::log("{}Testing windows", Colors::GREEN); @@ -25,19 +27,11 @@ static bool test() { 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); + if (!spawnKitty("kitty_A")) 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); + NLog::log("{}Expecting kitty_A to take up the whole screen", Colors::YELLOW); { auto str = getFromSocket("/clients"); EXPECT(str.contains("at: 0,0"), true); @@ -45,15 +39,44 @@ static bool test() { 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("{}Testing window split ratios", Colors::YELLOW); + { + const double RATIO = 1.25; + const double PERCENT = RATIO / 2.0 * 100.0; + const int GAPSIN = 5; + const int GAPSOUT = 20; + const int BORDERS = 2 * 2; + const int WTRIM = BORDERS + GAPSIN + GAPSOUT; + const int HEIGHT = 1080 - (BORDERS + (GAPSOUT * 2)); + const int WIDTH1 = std::round(1920.0 / 2.0 * (2 - RATIO)) - WTRIM; + const int WIDTH2 = std::round(1920.0 / 2.0 * RATIO) - WTRIM; + + OK(getFromSocket("/keyword dwindle:default_split_ratio 1.25")); + + if (!spawnKitty("kitty_B")) + return false; + + NLog::log("{}Expecting kitty_B to take up roughly {}% of screen width", Colors::YELLOW, 100 - PERCENT); + EXPECT_CONTAINS(getFromSocket("/activewindow"), std::format("size: {},{}", WIDTH1, HEIGHT)); - NLog::log("{}Expecting 2 windows", Colors::YELLOW); - EXPECT(Tests::windowCount(), 2); + OK(getFromSocket("/dispatch killwindow activewindow")); + Tests::waitUntilWindowsN(1); + + NLog::log("{}Inverting the split ratio", Colors::YELLOW); + OK(getFromSocket("/keyword dwindle:default_split_ratio 0.75")); + + if (!spawnKitty("kitty_B")) + return false; + + NLog::log("{}Expecting kitty_B to take up roughly {}% of screen width", Colors::YELLOW, PERCENT); + EXPECT_CONTAINS(getFromSocket("/activewindow"), std::format("size: {},{}", WIDTH2, HEIGHT)); + + OK(getFromSocket("/dispatch focuswindow class:kitty_A")); + NLog::log("{}Expecting kitty_A to have the same width as the previous kitty_B", Colors::YELLOW); + EXPECT_CONTAINS(getFromSocket("/activewindow"), std::format("size: {},{}", WIDTH1, HEIGHT)); + + OK(getFromSocket("/keyword dwindle:default_split_ratio 1")); + } // open xeyes NLog::log("{}Spawning xeyes", Colors::YELLOW); |
