From fdff86c08c627a42be39cac851f670bb47c14885 Mon Sep 17 00:00:00 2001 From: erstarr <253168930+erstarr@users.noreply.github.com> Date: Fri, 1 May 2026 01:00:14 +0200 Subject: [PATCH] test: move window into group `follow_focus = true` --- hyprtester/src/tests/main/scroll.cpp | 63 +++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/hyprtester/src/tests/main/scroll.cpp b/hyprtester/src/tests/main/scroll.cpp index 3b0aa42fe..b44b9f644 100644 --- a/hyprtester/src/tests/main/scroll.cpp +++ b/hyprtester/src/tests/main/scroll.cpp @@ -755,4 +755,65 @@ TEST_CASE(testScrollingViewBehaviourMoveWindowIntoGroupFollowFocusFalse) { Tests::killAllWindows(); ASSERT(Tests::windowCount(), 0); -} \ No newline at end of file +} + + + +TEST_CASE(testScrollingViewBehaviourMoveWindowInGroupFollowFocusTrue) { + + /* + when a window is moved inside a group, scrolling view should move to fit that group when follow_focus = true + ------------------------------------------------------------------------------------------------------------ + */ + + NLog::log("{}Testing scrolling view behaviour: moving a window in a group SHOULD move scrolling view if follow_focus = true", Colors::GREEN); + + OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })")); + + + // ensure variables are correctly set for the test + OK(getFromSocket("/eval hl.config({group = {auto_group = false}})")); + + if (!Tests::spawnKitty("a")) { + FAIL_TEST("{}Failed to spawn kitty with win class `a`", Colors::RED); + } + + OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')")); + OK(getFromSocket("/dispatch hl.dsp.group.toggle({window = 'class:a'})")); + + if (!Tests::spawnKitty("b")) { + FAIL_TEST("{}Failed to spawn kitty with win class `b`", Colors::RED); + } + + if (!Tests::spawnKitty("c")) { + FAIL_TEST("{}Failed to spawn kitty with win class `c`", Colors::RED); + } + + // focus class:b + OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:b'})")); + + // move it into the group where class:a is + OK(getFromSocket("/dispatch hl.dsp.window.move({ into_group = 'left' })")); + + // the focus now should still be on class:b window. If the scrolling view did move, its x coordinate for its `at:` value should be >= 0 + + const std::string currentWindowPos = Tests::getWindowAttribute(getFromSocket("/activewindow"), "at:"); + const std::string currentWindowPosX = currentWindowPos.substr(4, currentWindowPos.find(',') - 4); + // test fail + if (std::stoi(currentWindowPosX) < 0) { + FAIL_TEST("{}window of class 'b' does not have x coordinates >= 0 for its position: {}", Colors::RED, currentWindowPosX); + } + // test pass + else { + NLog ::log("{}Passed: {}window of class 'b' has x coordinates >= 0 for its position: {}", Colors ::GREEN, Colors::RESET, currentWindowPosX); + } + + // clean up + + + // kill all windows + NLog::log("{}Killing all windows", Colors::YELLOW); + Tests::killAllWindows(); + ASSERT(Tests::windowCount(), 0); +} +