1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
# Copyright 2012 Canonical
3
# Author: Thomi Richards
5
# This program is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 3, as published
7
# by the Free Software Foundation.
9
# This script is designed to run unity in a test drive manner. It will drive
10
# X and test the GL calls that Unity makes, so that we can easily find out if
11
# we are triggering graphics driver/X bugs.
13
from subprocess import call
14
from testtools import TestCase
15
from time import sleep
17
from autopilot.utilities import make_window_skip_taskbar
18
from autopilot.emulators.unity.switcher import Switcher
19
from autopilot.emulators.bamf import Bamf
22
class InvisibleWindowTests(TestCase):
23
"""Test unity's handling of windows with the Skip-Tasklist flag set."""
25
def test_invisible_windows_ignored(self):
26
"""Windows with the '_NET_WM_STATE_SKIP_TASKBAR' flag set must not appear
27
in the launcher or the switcher.
30
self.skipTest("This test needs to be rewritten. We don't support changing window states after they've been mapped.")
33
self.assertFalse(self.app_is_running('Calculator'))
34
b.launch_application("gcalctool.desktop")
35
self.addCleanup(call, ["killall", "gcalctool"])
39
# calculator should be in both launcher AND switcher:
40
icon_names = [i.tooltip_text for i in self.launcher.model.get_launcher_icons()]
41
self.assertIn('Calculator', icon_names)
44
icon_names = [i.tooltip_text for i in switcher.get_switcher_icons()]
46
self.assertIn('Calculator', icon_names)
47
# now set skip_tasklist:
48
apps = b.get_running_applications_by_title('Calculator')
49
self.assertEqual(1, len(apps))
50
windows = apps[0].get_windows()
51
self.assertEqual(1, len(windows))
52
make_window_skip_taskbar(windows[0].x_win)
53
self.addCleanup(make_window_skip_taskbar, windows[0].x_win, False)
56
# calculator should now NOT be in both launcher AND switcher:
57
icon_names = [i.tooltip_text for i in self.launcher.model.get_launcher_icons()]
58
self.assertNotIn('Calculator', icon_names)
61
icon_names = [i.tooltip_text for i in switcher.get_switcher_icons()]
63
self.assertNotIn('Calculator', icon_names)
65
def test_pinned_invisible_window(self):
66
"""Test behavior of an app with an invisible window that's pinned to the launher."""
68
self.skipTest("This test needs to be rewritten. We don't support changing window states after they've been mapped.")
71
self.assertFalse(b.app_is_running('Calculator'))
72
b.launch_application("gcalctool.desktop")
73
self.addCleanup(call, ["killall", "gcalctool"])
74
# need to pin the app to the launcher - this could be tricky.
75
self.launcher.get_launcher_for_monitor(0).reveal_launcher()
76
icons = self.launcher.model.get_launcher_icons()
77
# launcher.grab_switcher()
80
if icon.tooltip_text == 'Calculator':
84
self.assertIsNotNone(calc_icon, "Could not find calculator in launcher.")
85
self.launcher.get_launcher_for_monitor(0).lock_to_launcher(calc_icon)
86
self.addCleanup(self.launcher.get_launcher_for_monitor(0).unlock_from_launcher, calc_icon)
88
# make calc window skip the taskbar:
89
apps = b.get_running_applications_by_title('Calculator')
90
self.assertEqual(1, len(apps))
91
windows = apps[0].get_windows()
92
self.assertEqual(1, len(windows))
93
make_window_skip_taskbar(windows[0].x_win)
95
# clicking on launcher icon should start a new instance:
96
self.launcher.get_launcher_for_monitor(0).click_launcher_icon(calc_icon)
99
# should now be one app with two windows:
100
apps = b.get_running_applications_by_title('Calculator')
101
self.assertEqual(1, len(apps))
102
windows = apps[0].get_windows()
103
self.assertEqual(2, len(windows))