on xenial help sign in
Hide the Unity launcher during autopiloting and skip battery tests if unavailable.

Approved by PS Jenkins bot, Łukasz Zemczak.

commitc28d978e88c99c3ea0ea1c3e9e40fc35cbe1ad2b authorMichał Sawicz <michal.sawicz@canonical.com> dateWed 24 Jul 2013, 15:29 (13 years ago) parent84d9ad21ed82ff
3 files changed+32−2
debian/control+2 tests/autopilot/unity8/indicators_client/tests/test_battery.py+10−2 tests/autopilot/unity8/shell/tests/__init__.py+20
debian/control+2
@@ -87,6 +87,8 @@ Depends: indicators-client (>= ${source:Version}),
8787 ${misc:Depends},
8888 ${python:Depends},
8989 ${shlibs:Depends},
90+Recommends: gir1.2-glib-2.0,
91+ python-gi,
9092Description: Test package for Unity 8 shell
9193 Autopilot tests for the unity8 package
9294
tests/autopilot/unity8/indicators_client/tests/test_battery.py+10−2
@@ -70,7 +70,11 @@ class TestDisplayMenus(IndicatorsTestCase):
7070
7171 # wait for the switch menu item
7272 fn_auto_brightness = lambda: self.app.select_single("SwitchMenuItem", objectName="auto-brightness");
73− self.assertThat(fn_auto_brightness, Eventually(NotEquals(None)));
73+ # FIXME: this should go away when we switch to indicator-power
74+ try:
75+ self.assertThat(fn_auto_brightness, Eventually(NotEquals(None)));
76+ except AssertionError:
77+ self.skipTest("WARNING: test skipped due to missing indicator-battery")
7478 auto_brightness = fn_auto_brightness();
7579
7680 old_ab_value = auto_brightness.checked
@@ -86,7 +90,11 @@ class TestDisplayMenus(IndicatorsTestCase):
8690 if self.input_device_class is Touch:
8791 self.skipTest("Dragging is broken with Touch input (LP: #1203808).")
8892 fn_brightness_menu = lambda: self.app.select_single("SliderMenuItem", objectName="brightness");
89− self.assertThat(fn_brightness_menu, Eventually(NotEquals(None)));
93+ # FIXME: this should go away when we switch to indicator-power
94+ try:
95+ self.assertThat(fn_brightness_menu, Eventually(NotEquals(None)));
96+ except AssertionError:
97+ self.skipTest("WARNING: test skipped due to missing indicator-battery")
9098 brightness_menu = fn_brightness_menu();
9199
92100 old_ab_value = brightness_menu.value
tests/autopilot/unity8/shell/tests/__init__.py+20
@@ -19,6 +19,11 @@
1919
2020"""unity autopilot tests."""
2121
22+try:
23+ from gi.repository import Gio
24+except ImportError:
25+ Gio = None
26+
2227from autopilot.platform import model
2328from autopilot.testcase import AutopilotTestCase
2429from autopilot.matchers import Eventually
@@ -36,6 +41,10 @@ from unity8.shell.emulators.main_window import MainWindow
3641
3742logger = logging.getLogger(__name__)
3843
44+UNITYSHELL_GSETTINGS_SCHEMA = "org.compiz.unityshell"
45+UNITYSHELL_GSETTINGS_PATH = "/org/compiz/profiles/unity/plugins/unityshell/"
46+UNITYSHELL_LAUNCHER_KEY = "launcher-hide-mode"
47+UNITYSHELL_LAUNCHER_MODE = 1 # launcher hidden
3948
4049def _get_device_emulation_scenarios():
4150 if model() == 'Desktop':
@@ -64,10 +73,21 @@ class UnityTestCase(AutopilotTestCase):
6473
6574 def setUp(self):
6675 super(UnityTestCase, self).setUp()
76+ if Gio is not None and UNITYSHELL_GSETTINGS_SCHEMA in Gio.Settings.list_relocatable_schemas():
77+ # Hide Unity launcher
78+ self._unityshell_schema = Gio.Settings.new_with_path(UNITYSHELL_GSETTINGS_SCHEMA, UNITYSHELL_GSETTINGS_PATH)
79+ self._launcher_hide_mode = self._unityshell_schema.get_int(UNITYSHELL_LAUNCHER_KEY)
80+ self._unityshell_schema.set_int(UNITYSHELL_LAUNCHER_KEY, UNITYSHELL_LAUNCHER_MODE)
81+ self.addCleanup(self._reset_launcher)
82+
6783 self._proxy = None
6884 self.touch = Touch.create()
6985 self._setup_display_details()
7086
87+ def _reset_launcher(self):
88+ """Reset Unity launcher hide mode"""
89+ self._unityshell_schema.set_int(UNITYSHELL_LAUNCHER_KEY, self._launcher_hide_mode)
90+
7191 def _setup_display_details(self):
7292 scale_divisor = self._determine_geometry()
7393 self._setup_grid_size(scale_divisor)