~3v1n0/unity/launcher-controller-bamf-check

« back to all changes in this revision

Viewing changes to tests/autopilot/autopilot/tests/test_invisible_windows.py

  • Committer: Tarmac
  • Author(s): Thomi Richards
  • Date: 2012-05-17 00:03:41 UTC
  • mfrom: (2350.3.9 autopilot-change)
  • Revision ID: tarmac-20120517000341-jsv4dqpx7v6fuse6
Remove autopilot from the unity source tree - large reorganization of the autopilot code.. Fixes: . Approved by Tim Penhey.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
 
# Copyright 2012 Canonical
3
 
# Author: Thomi Richards
4
 
#
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.
8
 
#
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.
12
 
 
13
 
from subprocess import call
14
 
from testtools import TestCase
15
 
from time import sleep
16
 
 
17
 
from autopilot.utilities import make_window_skip_taskbar
18
 
from autopilot.emulators.unity.switcher import Switcher
19
 
from autopilot.emulators.bamf import Bamf
20
 
 
21
 
 
22
 
class InvisibleWindowTests(TestCase):
23
 
    """Test unity's handling of windows with the Skip-Tasklist flag set."""
24
 
 
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.
28
 
 
29
 
        """
30
 
        self.skipTest("This test needs to be rewritten. We don't support changing window states after they've been mapped.")
31
 
 
32
 
        b = Bamf()
33
 
        self.assertFalse(self.app_is_running('Calculator'))
34
 
        b.launch_application("gcalctool.desktop")
35
 
        self.addCleanup(call, ["killall", "gcalctool"])
36
 
        sleep(1)
37
 
 
38
 
        switcher = Switcher()
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)
42
 
 
43
 
        switcher.initiate()
44
 
        icon_names = [i.tooltip_text for i in switcher.get_switcher_icons()]
45
 
        switcher.terminate()
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)
54
 
        sleep(2)
55
 
 
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)
59
 
 
60
 
        switcher.initiate()
61
 
        icon_names = [i.tooltip_text for i in switcher.get_switcher_icons()]
62
 
        switcher.terminate()
63
 
        self.assertNotIn('Calculator', icon_names)
64
 
 
65
 
    def test_pinned_invisible_window(self):
66
 
        """Test behavior of an app with an invisible window that's pinned to the launher."""
67
 
 
68
 
        self.skipTest("This test needs to be rewritten. We don't support changing window states after they've been mapped.")
69
 
 
70
 
        b = Bamf()
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()
78
 
        calc_icon = None
79
 
        for icon in icons:
80
 
            if icon.tooltip_text == 'Calculator':
81
 
                calc_icon = icon
82
 
                break
83
 
 
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)
87
 
 
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)
94
 
 
95
 
        # clicking on launcher icon should start a new instance:
96
 
        self.launcher.get_launcher_for_monitor(0).click_launcher_icon(calc_icon)
97
 
        sleep(1)
98
 
 
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))