~ubuntu-branches/ubuntu/trusty/unity/trusty

« back to all changes in this revision

Viewing changes to tests/autopilot/unity/tests/test_spread.py

  • Committer: Łukasz 'sil2100' Zemczak
  • Date: 2012-10-04 16:47:13 UTC
  • mfrom: (55.813.27)
  • Revision ID: lukasz.zemczak@canonical.com-20121004164713-nlpdhe3vfi7hdbuw
* New upstream release.
  - unity 6.8 candidate segfaults on "app expose" with low gfx mode 
    (LP: #1060148)
  - [regression] Dash - Left separator is missing (LP: #1057798)
  - unity-panel-service crashed with SIGSEGV in 
    panel_indicator_entry_accessible_get_n_children() from 
    atk_object_get_n_accessible_children() (LP: #913324)
  - [regression] If unity is started with maximized dash, unmaximizing the 
    dash does not wrap rows (LP: #1053116)
  - Dash lens buttons don't work after changing form factor to maximize on 
    desktop (LP: #1053316)
  - Clicking on Workspace Switcher icon when the expo is showing, not always
    closes it 1059759 convert files list deprecated keys (LP: #1059594)
  - Unity through llvmpipe is slow (LP: #1046497)
  - compiz crashed with SIGSEGV in unity::QuicklistView::Show() from 
    unity::QuicklistManager::ShowQuicklist() (LP: #1055995)
  - compiz crashed with SIGSEGV from 
    unity::dash::HomeLens::Impl::LensSearchFinished() (LP: #1054219)
  - [regression] Starting an app & then locking to launcher is not persistent
    across sessions (LP: #1054645)
  - [regression] Dash, Launcher, Menu Bar - Unintended shadows are rendered 
    for the Unity Launcher and Panel, when the dash is open (LP: #1043260)
  - [Unity 6.x] Active blur doesn't update if you disable CCSM > OpenGL > 
    Framebuffer object (LP: #1039999)
  - Alt+Tab/Alt+grave brings other window to the front but loses focus 
    entirely. (LP: #1035628)
  - Spread - Scaling all the windows is too slow (LP: #1055643)
  - Window management - Middle clicking on a window inside the spread should
    close that window (equivalent action to clicking on the close button) 
    (LP: #1052821)
  - Scale window decorations don't have properly rounded corners 
    (LP: #1055610)
  - Scale window decorations text does not match theme style (Radiance) 
    (LP: #1055609)
  - Spread window decorations does not match the theme when changed 
    (LP: #1055605)
  - scaled window decorations are sometimes wider than the window 
    (LP: #1053225)
  - Launcher should not auto-hide after dragging an icon, if mouse is still
    over it (LP: #1053978)
  - unity spread window on second click not working when ibus language panel
    is shown. (LP: #1035895)
  - windows.push_back(<uninitialized value>) in 
    BamfLauncherIcon::GetFocusableWindows (LP: #1053220)
  - Category emblems are blurry (LP: #1056874)
  - Rendering flaws of the dash previews (LP: #1055455)
  - [UIFe] Social Lens doesn't have authorised and meaningful icon 
    (LP: #1056191)
  - [dash] Preview fade out animation hangs occasionally (LP: #1058145)
  - Dash - rendering of ribbons shouldn't be relative (LP: #1057971)
  - Horizontal alignment search box and views below (LP: #1055544)
  - Compiz crashed in cairo_save() from 
    unity::UnityWindow::RenderDecoration() from 
    unity::UnityWindow::scalePaintDecoration() from 
    ScaleWindow::scalePaintDecoration() (LP: #1061396)
  - [regression] Spinner doesn't spin around its center (LP: #1061081)
  - [regression] Graphical glitches in HUD/Dash bottom left and top right 
    corner (LP: #1060532)
  - [Quantal] unity-lens-application does not start on some slow machines 
    (LP: #1058619)
  - [Dash] Rendering flaw of the dash search entry (LP: #1059562)
  - [dash] Rendering flaw of filterbar after scrolling down/scrolling up. 
    (LP: #1059607)
  - Unity launcher doesn't prompt for password to unlock the device when 
    clicking on a encrypted volume icon (LP: #713432)
  - [regression] Unable to add desktop files with spaces in their name from 
    Nautilus into the Launcher (LP: #1055552 )
  - Missing context menus for Qt apps after minimizing the window 
    (LP: #929712)
  - Music preview note image is blurry (LP: #1060195)

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: Marco Trevisan (Treviño)
 
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
from __future__ import absolute_import
 
10
 
 
11
from autopilot.matchers import Eventually
 
12
import logging
 
13
from time import sleep
 
14
from testtools.matchers import Equals, NotEquals
 
15
 
 
16
from unity.tests import UnityTestCase
 
17
from unity.emulators.screen import Screen
 
18
 
 
19
 
 
20
class SpreadTests(UnityTestCase):
 
21
    """Spread tests"""
 
22
 
 
23
    def start_test_application_windows(self, app_name, num_windows=2):
 
24
        """Start a given number of windows of the requested application"""
 
25
        self.close_all_app(app_name)
 
26
        windows = []
 
27
 
 
28
        for i in range(num_windows):
 
29
            win = self.start_app_window(app_name)
 
30
            if len(windows):
 
31
                self.assertThat(win.application, Equals(windows[-1].application))
 
32
 
 
33
            windows.append(win)
 
34
 
 
35
        self.assertThat(len(windows), Equals(num_windows))
 
36
 
 
37
        return windows
 
38
 
 
39
    def initiate_spread_for_screen(self):
 
40
        """Initiate the Spread for all windows"""
 
41
        self.addCleanup(self.keybinding, "spread/cancel")
 
42
        self.keybinding("spread/start")
 
43
        sleep(1)
 
44
        self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
 
45
 
 
46
 
 
47
    def initiate_spread_for_application(self, desktop_id):
 
48
        """Initiate the Spread for windows of the given app"""
 
49
        icon = self.launcher.model.get_icon(desktop_id=desktop_id)
 
50
        self.assertThat(lambda: icon, Eventually(NotEquals(None)))
 
51
        launcher = self.launcher.get_launcher_for_monitor(self.screen_geo.get_primary_monitor())
 
52
 
 
53
        self.addCleanup(self.keybinding, "spread/cancel")
 
54
        launcher.click_launcher_icon(icon)
 
55
        self.assertThat(self.window_manager.scale_active_for_group, Eventually(Equals(True)))
 
56
 
 
57
    def assertWindowIsNotScaled(self, xid):
 
58
        """Assert that a window is not scaled"""
 
59
        refresh_fn = lambda: xid in [w.xid for w in self.screen.scaled_windows]
 
60
        self.assertThat(refresh_fn, Eventually(Equals(False)))
 
61
 
 
62
    def assertWindowIsClosed(self, xid):
 
63
        """Assert that a window is not in the list of the open windows"""
 
64
        refresh_fn = lambda: xid in [w.x_id for w in self.bamf.get_open_windows()]
 
65
        self.assertThat(refresh_fn, Eventually(Equals(False)))
 
66
 
 
67
 
 
68
    def test_scale_application_windows(self):
 
69
        """Test if all the windows of an application are scaled when application spread is initiated"""
 
70
        [win1, win2] = self.start_test_application_windows("Calculator")
 
71
        self.initiate_spread_for_application(win1.application.desktop_file)
 
72
 
 
73
        self.assertThat(lambda: len(self.screen.scaled_windows), Eventually(Equals(2)))
 
74
        self.assertThat(lambda: (win1.x_id and win2.x_id) in [w.xid for w in self.screen.scaled_windows],
 
75
                        Eventually(Equals(True)))
 
76
 
 
77
    def test_scaled_window_is_focused_on_click(self):
 
78
        """Test that a window is focused when clicked in spread"""
 
79
        windows = self.start_test_application_windows("Calculator", 3)
 
80
        self.initiate_spread_for_application(windows[0].application.desktop_file)
 
81
 
 
82
        not_focused = [w for w in windows if not w.is_focused][0]
 
83
 
 
84
        target_xid = not_focused.x_id
 
85
        [target_win] = [w for w in self.screen.scaled_windows if w.xid == target_xid]
 
86
 
 
87
        (x, y, w, h) = target_win.geometry
 
88
        self.mouse.move(x + w / 2, y + h / 2)
 
89
        sleep(.5)
 
90
        self.mouse.click()
 
91
 
 
92
        self.assertThat(lambda: not_focused.is_focused, Eventually(Equals(True)))
 
93
 
 
94
    def test_scaled_window_closes_on_close_button_click(self):
 
95
        """Test that a window is closed when its close button is clicked in spread"""
 
96
        win = self.start_test_application_windows("Calculator", 1)[0]
 
97
        self.initiate_spread_for_screen()
 
98
 
 
99
        target_xid = win.x_id
 
100
        [target_win] = [w for w in self.screen.scaled_windows if w.xid == target_xid]
 
101
 
 
102
        (x, y, w, h) = target_win.scale_close_geometry
 
103
        self.mouse.move(x + w / 2, y + h / 2)
 
104
        sleep(.5)
 
105
        self.mouse.click()
 
106
 
 
107
        self.assertWindowIsNotScaled(target_xid)
 
108
        self.assertWindowIsClosed(target_xid)