Back to index

unity  6.0.0
test_visual.py
Go to the documentation of this file.
00001 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
00002 # Copyright 2012 Canonical
00003 # Authors: Thomi Richards,
00004 #          Marco Trevisan (TreviƱo)
00005 #
00006 # This program is free software: you can redistribute it and/or modify it
00007 # under the terms of the GNU General Public License version 3, as published
00008 # by the Free Software Foundation.
00009 
00010 from __future__ import absolute_import
00011 
00012 from autopilot.matchers import Eventually
00013 import logging
00014 from testtools.matchers import Equals
00015 from time import sleep
00016 
00017 from unity.emulators.icons import BFBLauncherIcon
00018 from unity.tests.launcher import LauncherTestCase
00019 
00020 logger = logging.getLogger(__name__)
00021 
00022 
00023 class LauncherVisualTests(LauncherTestCase):
00024     """Tests for visual aspects of the launcher (icon saturation etc.)."""
00025 
00026     def test_keynav_from_dash_saturates_icons(self):
00027         """Starting super+tab switcher from the dash must resaturate launcher icons.
00028 
00029         Tests fix for bug #913569.
00030         """
00031         bfb = self.launcher.model.get_bfb_icon()
00032         self.mouse.move(bfb.center_x, bfb.center_y)
00033         self.dash.ensure_visible()
00034         sleep(1)
00035         # We can't use 'launcher_instance.switcher_start()' since it moves the mouse.
00036         self.keybinding_hold_part_then_tap("launcher/switcher")
00037         self.addCleanup(self.keybinding_release, "launcher/switcher")
00038         self.addCleanup(self.keybinding, "launcher/switcher/exit")
00039 
00040         self.keybinding_tap("launcher/switcher/next")
00041         for icon in self.launcher.model.get_launcher_icons():
00042             self.assertThat(icon.desaturated, Eventually(Equals(False)))
00043 
00044     def test_opening_dash_desaturates_icons(self):
00045         """Opening the dash must desaturate all the launcher icons."""
00046         self.dash.ensure_visible()
00047         self.addCleanup(self.dash.ensure_hidden)
00048 
00049         for icon in self.launcher.model.get_launcher_icons():
00050             if isinstance(icon, BFBLauncherIcon):
00051                 self.assertThat(icon.desaturated, Eventually(Equals(False)))
00052             else:
00053                 self.assertThat(icon.desaturated, Eventually(Equals(True)))
00054 
00055     def test_opening_dash_with_mouse_over_launcher_keeps_icon_saturation(self):
00056         """Opening dash with mouse over launcher must not desaturate icons."""
00057         launcher_instance = self.get_launcher()
00058         x,y,w,h = launcher_instance.geometry
00059         self.mouse.move(x + w/2, y + h/2)
00060         sleep(.5)
00061         self.dash.ensure_visible()
00062         self.addCleanup(self.dash.ensure_hidden)
00063         for icon in self.launcher.model.get_launcher_icons():
00064             self.assertThat(icon.desaturated, Eventually(Equals(False)))
00065 
00066     def test_mouse_over_with_dash_open_desaturates_icons(self):
00067         """Moving mouse over launcher with dash open must saturate icons."""
00068         launcher_instance = self.get_launcher()
00069         self.dash.ensure_visible()
00070         self.addCleanup(self.dash.ensure_hidden)
00071         sleep(.5)
00072         x,y,w,h = launcher_instance.geometry
00073         self.mouse.move(x + w/2, y + h/2)
00074         sleep(.5)
00075         for icon in self.launcher.model.get_launcher_icons():
00076             self.assertThat(icon.desaturated, Eventually(Equals(False)))