From ebc8f419a5fc1efdff429f62e065f620ffbf7c30 Mon Sep 17 00:00:00 2001 From: erstarr <253168930+erstarr@users.noreply.github.com> Date: Wed, 6 May 2026 02:38:56 +0200 Subject: [PATCH] catch up with main: move to new test function --- hyprtester/src/tests/main/scroll.cpp | 68 ++++++++++++++-------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/hyprtester/src/tests/main/scroll.cpp b/hyprtester/src/tests/main/scroll.cpp index 7bf41c06c..8e379d827 100644 --- a/hyprtester/src/tests/main/scroll.cpp +++ b/hyprtester/src/tests/main/scroll.cpp @@ -225,8 +225,8 @@ TEST_CASE(testScrollingViewBehaviourDispatchFocusWindowFollowFocusFalse) { OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})")); // if the view does not move, we expect the x coordinate of the window of class "a" to be negative, as it would be to the left of the viewport - const std::string posA = Tests::getWindowAttribute(getFromSocket("/activewindow"), "at:"); - const int posAx = std::stoi(posA.substr(4, posA.find(',') - 4)); + const std::string posA = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const int posAx = std::stoi(posA.substr(0, posA.find(','))); if (posAx < 0) { NLog::log("{}Passed: {}Expected the x coordinate of window of class \"a\" to be < 0, got {}.", Colors::GREEN, Colors::RESET, posAx); } else { @@ -269,8 +269,8 @@ TEST_CASE(testScrollingViewBehaviourDispatchFocusWindowFollowFocustrue) { // If the view does not move, we expect the x coordinate of the window of class "a" to be negative, as it would be to the left of the viewport. // If it is not, the view moved, which is what we expect to happen. - const std::string posA = Tests::getWindowAttribute(getFromSocket("/activewindow"), "at:"); - const int posAx = std::stoi(posA.substr(4, posA.find(',') - 4)); + const std::string posA = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const int posAx = std::stoi(posA.substr(0, posA.find(','))); if (posAx < 0) { FAIL_TEST("{}Failed: {}Expected the x coordinate of window of class \"a\" to be >= 0, got {}.", Colors::RED, Colors::RESET, posAx); } else { @@ -330,8 +330,8 @@ TEST_CASE(testScrollingViewBehaviourFocusFallback) { // If the view did not move, we expect currently focused window's (class:a) to have "at: " x coordinat value <0 (must be left of the viewport) - const std::string currentWindowPos = Tests::getWindowAttribute(getFromSocket("/activewindow"), "at:"); - const std::string currentWindowPosX = currentWindowPos.substr(4, currentWindowPos.find(',') - 4); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // test pass if (std::stoi(currentWindowPosX) < 0) { NLog ::log("{}Passed: {}Expected the x coordinate of window of class \"a\" to be < 0, got {}.", Colors ::GREEN, Colors::RESET, currentWindowPosX); @@ -396,8 +396,8 @@ TEST_CASE(testScrollingViewBehaviourFocusFallbackWithGroups) { // If the view did not move, we expect currently focused window's (class:a) to have "at: " x coordinat value <0 (must be left of the viewport) - const std::string currentWindowPos = Tests::getWindowAttribute(getFromSocket("/activewindow"), "at:"); - const std::string currentWindowPosX = currentWindowPos.substr(4, currentWindowPos.find(',') - 4); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // test pass if (std::stoi(currentWindowPosX) < 0) { @@ -451,8 +451,8 @@ TEST_CASE(testScrollingViewBehaviourWorkspaceChange) { OK(getFromSocket("/dispatch hl.dsp.focus({workspace = '1'})")); // If the scrolling view did not move, the x value for `at:` of the currently focused window, class:a, must be <0 (must be left of the viewport) - const std::string currentWindowPos = Tests::getWindowAttribute(getFromSocket("/activewindow"), "at:"); - const std::string currentWindowPosX = currentWindowPos.substr(4, currentWindowPos.find(',') - 4); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // test pass if (std::stoi(currentWindowPosX) < 0) { @@ -509,8 +509,8 @@ TEST_CASE(testScrollingViewBehaviourSpecialWorkspaceChange) { OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})")); // If the scrolling view did not move, the x value for `at:` of the currently focused windows, class:c, must be <0 (must be left of the viewport) - const std::string currentWindowPos = Tests::getWindowAttribute(getFromSocket("/activewindow"), "at:"); - const std::string currentWindowPosX = currentWindowPos.substr(4, currentWindowPos.find(',') - 4); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // test pass if (std::stoi(currentWindowPosX) < 0) { NLog ::log("{}Passed: {}window of class 'a' has negative x coordinates for its position: {}", Colors ::GREEN, Colors::RESET, currentWindowPosX); @@ -567,8 +567,8 @@ TEST_CASE(testScrollingViewBehaviourSpecialToSpecialWorkspaceChange) { // If the scrolling view did not move, the x value for `at:` of the currently focused windows, class:c, must be <0 (must be left of the viewport) - const std::string currentWindowPosSPECIAL = Tests::getWindowAttribute(getFromSocket("/activewindow"), "at:"); - const std::string currentWindowPosSPECIALX = currentWindowPosSPECIAL.substr(4, currentWindowPosSPECIAL.find(',') - 4); + const std::string currentWindowPosSPECIAL = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosSPECIALX = currentWindowPosSPECIAL.substr(0, currentWindowPosSPECIAL.find(',')); // test pass if (std::stoi(currentWindowPosSPECIALX) < 0) { NLog ::log("{}Passed: {}window of class 'a' has negative x coordinates for its position: {}", Colors ::GREEN, Colors::RESET, currentWindowPosSPECIALX); @@ -630,8 +630,8 @@ TEST_CASE(testScrollingViewBehaviourCloseWindowInGroup) { // If the scrolling view did not move, the x value for `at:` of the currently focused windows, class:a, must be <0 (must be left of the viewport) - const std::string currentWindowPos = Tests::getWindowAttribute(getFromSocket("/activewindow"), "at:"); - const std::string currentWindowPosX = currentWindowPos.substr(4, currentWindowPos.find(',') - 4); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // test pass if (std::stoi(currentWindowPosX) < 0) { NLog ::log("{}Passed: {}window of class 'a' has negative x coordinates for its position: {}", Colors ::GREEN, Colors::RESET, currentWindowPosX); @@ -687,8 +687,8 @@ TEST_CASE(testScrollingViewBehaviourMoveWindowIntoGroupFollowFocusFalse) { // the focus now should still be on class:b window. If the view did not 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); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // test pass if (std::stoi(currentWindowPosX) < 0) { NLog ::log("{}Passed: {}window of class 'b' has negative x coordinates for its position: {}", Colors ::GREEN, Colors::RESET, currentWindowPosX); @@ -743,8 +743,8 @@ TEST_CASE(testScrollingViewBehaviourMoveWindowInGroupFollowFocusTrue) { // 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); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // 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); @@ -796,8 +796,8 @@ TEST_CASE(testScrollingViewBehaviourNewLayer) { // If the scrolling view did not move, class:a window's 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); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // test pass if (std::stoi(currentWindowPosX) < 0) { NLog ::log("{}Passed: {}window of class 'a' has negative x coordinates for its position: {}", Colors ::GREEN, Colors::RESET, currentWindowPosX); @@ -855,8 +855,8 @@ TEST_CASE(testScrollingViewBehaviourMaximise) { // If the scrolling view did not move, class:a window's 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); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // test pass if (std::stoi(currentWindowPosX) < 0) { NLog ::log("{}Passed: {}window of class 'a' has negative x coordinates for its position: {}", Colors ::GREEN, Colors::RESET, currentWindowPosX); @@ -909,8 +909,8 @@ TEST_CASE(testScrollingViewBehaviourFullscreen) { OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({mode = 'fullscreen', action = 'unset', window = 'class:a'})")); // If the scrolling view did not move, class:a window's 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); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // test pass if (std::stoi(currentWindowPosX) < 0) { NLog ::log("{}Passed: {}window of class 'a' has negative x coordinates for its position: {}", Colors ::GREEN, Colors::RESET, currentWindowPosX); @@ -956,8 +956,8 @@ TEST_CASE(testScrollingViewBehaviourMoveFocusFollowFocusFalse) { OK(getFromSocket("/dispatch hl.dsp.focus({direction = 'left'})")); // If the scrolling view did not move, class:a window's 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); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // test pass if (std::stoi(currentWindowPosX) < 0) { NLog::log("{}Passed: {}window of class 'a' has negative x coordinates for its position: {}", Colors ::GREEN, Colors::RESET, currentWindowPosX); @@ -1001,8 +1001,8 @@ TEST_CASE(testScrollingViewBehaviourMoveFocusFollowFocusTrue) { // If the scrolling view moved, class:a window's 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); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // test fail if (std::stoi(currentWindowPosX) < 0) { FAIL_TEST("{}Failed: {}window of class 'a' does not have x coordinates >= 0 for its position: {}", Colors::RED, Colors::RESET, currentWindowPosX); @@ -1064,8 +1064,8 @@ TEST_CASE(testScrollingViewBehaviourMoveFocusInGroupFollowFocusFalse) { // the focus now should still be on class:a window. If the scrolling view did not 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); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // test pass if (std::stoi(currentWindowPosX) < 0) { NLog ::log("{}Passed: {}window of class 'a' has negative x coordinates for its position: {}", Colors ::GREEN, Colors::RESET, currentWindowPosX); @@ -1126,8 +1126,8 @@ TEST_CASE(testScrollingViewBehaviourMoveFocusInGroupFollowFocusTrue) { // the focus now should still be on class:a window. If the scrolling view moved, 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); + const std::string currentWindowPos = Tests::getAttribute(getFromSocket("/activewindow"), "at"); + const std::string currentWindowPosX = currentWindowPos.substr(0, currentWindowPos.find(',')); // test fail if (std::stoi(currentWindowPosX) < 0) { FAIL_TEST("{}Failed: {}window of class 'a' does not have x coordinates >= 0 for its position: {}", Colors::RED, Colors::RESET, currentWindowPosX);