1# Copyright (c) 2008, Aldo Cortesi. All rights reserved.
2#
3# Permission is hereby granted, free of charge, to any person obtaining a copy
4# of this software and associated documentation files (the "Software"), to deal
5# in the Software without restriction, including without limitation the rights
6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7# copies of the Software, and to permit persons to whom the Software is
8# furnished to do so, subject to the following conditions:
9#
10# The above copyright notice and this permission notice shall be included in
11# all copies or substantial portions of the Software.
12#
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19# SOFTWARE.
20
21import pytest
22
23import libqtile.config
24from libqtile import layout
25from libqtile.confreader import Config
26from test.layouts.layout_utils import assert_focused
27
28
29class FloatingConfig(Config):
30    auto_fullscreen = True
31    groups = [
32        libqtile.config.Group("a"),
33    ]
34    layouts = [
35        layout.Floating()
36    ]
37    floating_layout = libqtile.resources.default_config.floating_layout
38    keys = []
39    mouse = []
40    screens = []
41    follow_mouse_focus = False
42
43
44floating_config = pytest.mark.parametrize("manager", [FloatingConfig], indirect=True)
45
46
47@floating_config
48def test_float_next_prev_window(manager):
49    # spawn three windows
50    manager.test_window("one")
51    manager.test_window("two")
52    manager.test_window("three")
53
54    # focus previous windows
55    assert_focused(manager, "three")
56    manager.c.group.prev_window()
57    assert_focused(manager, "two")
58    manager.c.group.prev_window()
59    assert_focused(manager, "one")
60    # checking that it loops around properly
61    manager.c.group.prev_window()
62    assert_focused(manager, "three")
63
64    # focus next windows
65    # checking that it loops around properly
66    manager.c.group.next_window()
67    assert_focused(manager, "one")
68    manager.c.group.next_window()
69    assert_focused(manager, "two")
70    manager.c.group.next_window()
71    assert_focused(manager, "three")
72