mirror of
https://github.com/hyprwm/Hyprland
synced 2026-05-07 20:58:01 +02:00
test: Focus Fallback with groups
This commit is contained in:
parent
2d466c60cd
commit
73dff984b6
1 changed files with 71 additions and 0 deletions
|
|
@ -370,3 +370,74 @@ TEST_CASE(testScrollingViewBehaviourFocusFallback) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
TEST_CASE(testScrollingViewBehaviourFocusFallbackWithGroups) {
|
||||
|
||||
// same idea as testScrollingViewBehaviourFocusFallback, but with window of class "a" being grouped.
|
||||
|
||||
NLog::log("{}Testing scrolling view behaviour: focus fallback from floating window to a grouped tiled should not move scrolling view", Colors::GREEN);
|
||||
|
||||
OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })"));
|
||||
|
||||
|
||||
// ensure variables are correctly set for the test
|
||||
|
||||
// to correctly set up windows for the test
|
||||
OK(getFromSocket("/eval hl.config({scrolling = {follow_focus = false}})"));
|
||||
// only one tiled window will be grouped 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);
|
||||
}
|
||||
|
||||
// make it a grouped. There need not be any other windows in the group for this test
|
||||
OK(getFromSocket("/dispatch hl.dsp.group.toggle({window = 'class:a'})"));
|
||||
OK(getFromSocket("/dispatch hl.dsp.layout('colresize 0.8')"));
|
||||
|
||||
if (!Tests::spawnKitty("b")) {
|
||||
FAIL_TEST("{}Failed to spawn kitty with class `b`", Colors::RED);
|
||||
}
|
||||
|
||||
if (!Tests::spawnKitty("c")) {
|
||||
FAIL_TEST("{}Failed to spawn kitty with class `c`", Colors::RED);
|
||||
}
|
||||
|
||||
// make it float - the view now mush have shifted to fit window class:b
|
||||
OK(getFromSocket("/dispatch hl.dsp.window.float({action = 'enable', window = 'class:c'})"));
|
||||
|
||||
// establish focus history
|
||||
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:c'})"));
|
||||
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:a'})"));
|
||||
OK(getFromSocket("/dispatch hl.dsp.focus({window = 'class:c'})"));
|
||||
|
||||
// kill the floating window
|
||||
OK(getFromSocket("/dispatch hl.dsp.window.kill({window = 'class:c'})"));
|
||||
Tests::waitUntilWindowsN(2);
|
||||
|
||||
// The focus now must have fallen back to tiled window of class "a".
|
||||
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
}
|
||||
// test fail
|
||||
else {
|
||||
FAIL_TEST("{}Failed: {}Expected the x coordinate of window of class \"a\" to be < 0, got {}.", Colors::RED, Colors::RESET, currentWindowPosX);
|
||||
}
|
||||
|
||||
// clean up
|
||||
|
||||
|
||||
// kill all windows
|
||||
NLog::log("{}Killing all windows", Colors::YELLOW);
|
||||
Tests::killAllWindows();
|
||||
EXPECT(Tests::windowCount(), 0);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue