Back to index

unity  6.0.0
test_reveal.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, GreaterThan
00015 from time import sleep
00016 
00017 from unity.tests.launcher import LauncherTestCase
00018 
00019 logger = logging.getLogger(__name__)
00020 
00021 
00022 class LauncherRevealTests(LauncherTestCase):
00023     """Test the launcher reveal behavior when in autohide mode."""
00024 
00025     def setUp(self):
00026         super(LauncherRevealTests, self).setUp()
00027         # these automatically reset to the original value, as implemented in AutopilotTestCase
00028         self.set_unity_option('launcher_capture_mouse', True)
00029         self.set_unity_option('launcher_hide_mode', 1)
00030         launcher = self.get_launcher()
00031         self.assertThat(launcher.hidemode, Eventually(Equals(1)))
00032 
00033     def test_launcher_keyboard_reveal_works(self):
00034         """Revealing launcher with keyboard must work."""
00035         self.launcher_instance.keyboard_reveal_launcher()
00036         self.addCleanup(self.launcher_instance.keyboard_unreveal_launcher)
00037         self.assertThat(self.launcher_instance.is_showing, Eventually(Equals(True)))
00038 
00039     def test_reveal_on_mouse_to_edge(self):
00040         """Tests reveal of launchers by mouse pressure."""
00041         self.launcher_instance.move_mouse_to_right_of_launcher()
00042         self.launcher_instance.mouse_reveal_launcher()
00043         self.assertThat(self.launcher_instance.is_showing, Eventually(Equals(True)))
00044 
00045     def test_reveal_with_mouse_under_launcher(self):
00046         """The Launcher must hide properly if the mouse is under the launcher."""
00047 
00048         self.launcher_instance.move_mouse_over_launcher()
00049         # we can't use "launcher_instance.keyboard_reveal_launcher()"
00050         # since it moves the mouse out of the way, invalidating the test.
00051         self.keybinding_hold("launcher/reveal")
00052         sleep(1)
00053         self.keybinding_release("launcher/reveal")
00054         self.assertThat(self.launcher_instance.is_showing, Eventually(Equals(False)))
00055 
00056     def test_reveal_does_not_hide_again(self):
00057         """Tests reveal of launchers by mouse pressure to ensure it doesn't
00058         automatically hide again.
00059         """
00060         self.launcher_instance.move_mouse_to_right_of_launcher()
00061         self.launcher_instance.mouse_reveal_launcher()
00062         self.assertThat(self.launcher_instance.is_showing, Eventually(Equals(True)))
00063 
00064     def test_launcher_does_not_reveal_with_mouse_down(self):
00065         """Launcher must not reveal if have mouse button 1 down."""
00066         self.screen_geo.move_mouse_to_monitor(self.launcher_instance.monitor)
00067         self.mouse.press(1)
00068         self.addCleanup(self.mouse.release, 1)
00069         #FIXME: This is really bad API. it says reveal but it's expected to fail. bad bad bad!!
00070         self.launcher_instance.mouse_reveal_launcher()
00071         # Need a sleep here otherwise this test would pass even if the code failed.
00072         # THis test needs to be rewritten...
00073         sleep(5)
00074         self.assertThat(self.launcher_instance.is_showing, Equals(False))
00075 
00076     def test_new_icon_has_the_shortcut(self):
00077          """New icons should have an associated shortcut"""
00078          if self.launcher.model.num_bamf_launcher_icons() >= 10:
00079              self.skip("There are already more than 9 icons in the launcher")
00080 
00081          desktop_file = self.KNOWN_APPS['Calculator']['desktop-file']
00082          if self.launcher.model.get_icon_by_desktop_id(desktop_file) != None:
00083              self.skip("Calculator icon is already on the launcher.")
00084 
00085          self.start_app('Calculator')
00086          icon = self.launcher.model.get_icon_by_desktop_id(desktop_file)
00087          self.assertThat(icon.shortcut, GreaterThan(0))