test: fullscreen

This commit is contained in:
erstarr 2026-05-01 02:12:02 +02:00
parent 96baa6fe9f
commit d16100b3de

View file

@ -936,3 +936,60 @@ TEST_CASE(testScrollingViewBehaviourMaximise) {
ASSERT(Tests::windowCount(), 0);
}
TEST_CASE(testScrollingViewBehaviourFullscreen) {
/*
This is almost the same as the testScrollingViewBehaviourMaximise() test, just with fullscreen 1 (fullscreen) instead of fullscreen 0 (maximise)
fullscreening and then unfullscreening a window shouldn't move scrolling view, regardless of follow_focus
*/
NLog::log("{}Testing scrolling view behaviour: fullscreening and then unfullscreening a window shouldn't move scrolling view", Colors::GREEN);
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })"));
// ensure variables are correctly set for the test - this is to avoid unwanted view shifts when setting up the windows
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = 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')"));
if (!Tests::spawnKitty("b")) {
FAIL_TEST("{}Failed to spawn kitty with win class `b`", Colors::RED);
}
// focus class:a - this does not move scrolling view when follow_focus = 0
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})"));
// maximise class:a window
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({mode = 'maximized', action = 'set', window = 'class:a'})"));
// unmaximise class:a window
OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({mode = 'maximized', 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);
// 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);
}
// test fail
else {
FAIL_TEST("{}Failed: {}window of class 'a' does not have negative x coordinates for its position: {}", Colors::RED, Colors::RESET, currentWindowPosX);
}
// clean up
// kill all windows
NLog::log("{}Killing all windows", Colors::YELLOW);
Tests::killAllWindows();
ASSERT(Tests::windowCount(), 0);
}