1# Copyright (c) 2011 Florian Mounier
2# Copyright (c) 2012, 2014-2015 Tycho Andersen
3# Copyright (c) 2013 Mattias Svala
4# Copyright (c) 2013 Craig Barnes
5# Copyright (c) 2014 ramnes
6# Copyright (c) 2014 Sean Vig
7# Copyright (c) 2014 Adi Sieker
8# Copyright (c) 2014 Chris Wesseling
9#
10# Permission is hereby granted, free of charge, to any person obtaining a copy
11# of this software and associated documentation files (the "Software"), to deal
12# in the Software without restriction, including without limitation the rights
13# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14# copies of the Software, and to permit persons to whom the Software is
15# furnished to do so, subject to the following conditions:
16#
17# The above copyright notice and this permission notice shall be included in
18# all copies or substantial portions of the Software.
19#
20# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26# SOFTWARE.
27
28import pytest
29
30import libqtile.config
31from libqtile import layout
32from libqtile.confreader import Config
33from test.layouts.layout_utils import (
34    assert_dimensions,
35    assert_focus_path,
36    assert_focused,
37)
38
39
40class ZoomyConfig(Config):
41    auto_fullscreen = True
42    groups = [
43        libqtile.config.Group("a"),
44    ]
45    layouts = [
46        layout.Zoomy(columnwidth=200),
47    ]
48    floating_layout = libqtile.resources.default_config.floating_layout
49    keys = []
50    mouse = []
51    screens = []
52
53
54zoomy_config = pytest.mark.parametrize("manager", [ZoomyConfig], indirect=True)
55
56
57@zoomy_config
58def test_zoomy_one(manager):
59    manager.test_window('one')
60    assert_dimensions(manager, 0, 0, 600, 600)
61    manager.test_window('two')
62    assert_dimensions(manager, 0, 0, 600, 600)
63    manager.test_window('three')
64    assert_dimensions(manager, 0, 0, 600, 600)
65    assert_focus_path(manager, 'two', 'one', 'three')
66    # TODO(pc) find a way to check size of inactive windows
67
68
69@zoomy_config
70def test_zoomy_window_focus_cycle(manager):
71    # setup 3 tiled and two floating clients
72    manager.test_window("one")
73    manager.test_window("two")
74    manager.test_window("float1")
75    manager.c.window.toggle_floating()
76    manager.test_window("float2")
77    manager.c.window.toggle_floating()
78    manager.test_window("three")
79
80    # test preconditions, Zoomy adds clients at head
81    assert manager.c.layout.info()['clients'] == ['three', 'two', 'one']
82    # last added window has focus
83    assert_focused(manager, "three")
84
85    # assert window focus cycle, according to order in layout
86    assert_focus_path(manager, 'two', 'one', 'float1', 'float2', 'three')
87