@@ -1,7 +1,7 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3−# Unity - Indicators Autopilot Test Suite
3+# Unity Indicators Autopilot Test Suite
4−# Copyright (C) 2013 Canonical
4+# Copyright (C) 2013, 2014 Canonical
6# This program is free software: you can redistribute it and/or modify
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
7# it under the terms of the GNU General Public License as published by
@@ -15,19 +15,30 @@
16# You should have received a copy of the GNU General Public License
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
20from __future__ import absolute_import
19from __future__ import absolute_import
21+from testscenarios import multiply_scenarios
22from autopilot import platform
23from autopilot import platform
23−from testtools import skipIf
25−from unity8.shell.tests import UnityTestCase
25+from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
28class IndicatorTestCase(UnityTestCase):
28class IndicatorTestCase(UnityTestCase):
30− scenarios = [
30+ device_emulation_scenarios = _get_device_emulation_scenarios()
33+ if platform.model() == 'Desktop':
34+ self.skipTest('Test cannot be run on the desktop.')
35+ super(IndicatorTestCase, self).setUp()
36+ self.unity_proxy = self.launch_unity()
39+class IndicatorExistsTestCase(IndicatorTestCase):
41+ indicator_scenarios = [
31 ('Bluetooth', dict(indicator_name='indicator-bluetooth')),
42 ('Bluetooth', dict(indicator_name='indicator-bluetooth')),
32 ('Datetime', dict(indicator_name='indicator-datetime')),
43 ('Datetime', dict(indicator_name='indicator-datetime')),
33 ('Location', dict(indicator_name='indicator-location')),
44 ('Location', dict(indicator_name='indicator-location')),
@@ -36,13 +47,58 @@ class IndicatorTestCase(UnityTestCase):
36 ('Power', dict(indicator_name='indicator-power')),
47 ('Power', dict(indicator_name='indicator-power')),
37 ('Sound', dict(indicator_name='indicator-sound')),
48 ('Sound', dict(indicator_name='indicator-sound')),
50+ scenarios = multiply_scenarios(
52+ IndicatorTestCase.device_emulation_scenarios
40− @skipIf(platform.image_codename() == 'Desktop',
41− "Unity8/phablet-only test!")
42 def setUp(self):
55 def setUp(self):
43− super(IndicatorTestCase, self).setUp()
56+ super(IndicatorExistsTestCase, self).setUp()
57+ if (platform.model() == 'Nexus 10' and
58+ self.indicator_name == 'indicator-bluetooth'):
59+ self.skipTest('Nexus 10 does not have bluetooth at the moment.')
45 def test_indicator_exists(self):
61 def test_indicator_exists(self):
46− unity_proxy = self.launch_unity()
62+ self.main_window._get_indicator_widget(
67+class IndicatorPageTitleMatchesWidgetTestCase(IndicatorTestCase):
69+ indicator_scenarios = [
70+ ('Bluetooth', dict(indicator_name='indicator-bluetooth',
72+ ('Datetime', dict(indicator_name='indicator-datetime',
74+ ('Location', dict(indicator_name='indicator-location',
76+ ('Messaging', dict(indicator_name='indicator-messages',
78+ ('Network', dict(indicator_name='indicator-network',
80+ ('Power', dict(indicator_name='indicator-power',
82+ ('Sound', dict(indicator_name='indicator-sound',
85+ scenarios = multiply_scenarios(
87+ IndicatorTestCase.device_emulation_scenarios
91+ super(IndicatorPageTitleMatchesWidgetTestCase, self).setUp()
92+ if (platform.model() == 'Nexus 10' and
93+ self.indicator_name == 'indicator-bluetooth'):
94+ self.skipTest('Nexus 10 does not have bluetooth at the moment.')
96+ def test_indicator_page_title_matches_widget(self):
97+ """Swiping open an indicator must show its correct title.
99+ See https://bugs.launchpad.net/ubuntu-ux/+bug/1253804 .
101+ indicator_page = self.main_window.open_indicator_page(
47− indicator = self.main_window.get_indicator(self.indicator_name)
102+ self.indicator_name)
48− self.assertIsNotNone(indicator)
103+ self.assertTrue(indicator_page.visible)
104+ self.assertEqual(indicator_page.title, self.title)