@@ -1,7 +1,7 @@
11# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
22#
3−# Unity - Indicators Autopilot Test Suite
4−# Copyright (C) 2013 Canonical
3+# Unity Indicators Autopilot Test Suite
4+# Copyright (C) 2013, 2014 Canonical
55#
66# This program is free software: you can redistribute it and/or modify
77# it under the terms of the GNU General Public License as published by
@@ -15,19 +15,30 @@
1515#
1616# You should have received a copy of the GNU General Public License
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
18−#
1918
2019from __future__ import absolute_import
2120
21+from testscenarios import multiply_scenarios
22+
2223from autopilot import platform
23−from testtools import skipIf
2424
25−from unity8.shell.tests import UnityTestCase
25+from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
2626
2727
2828class IndicatorTestCase(UnityTestCase):
2929
30− scenarios = [
30+ device_emulation_scenarios = _get_device_emulation_scenarios()
31+
32+ def setUp(self):
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()
37+
38+
39+class IndicatorExistsTestCase(IndicatorTestCase):
40+
41+ indicator_scenarios = [
3142 ('Bluetooth', dict(indicator_name='indicator-bluetooth')),
3243 ('Datetime', dict(indicator_name='indicator-datetime')),
3344 ('Location', dict(indicator_name='indicator-location')),
@@ -36,13 +47,58 @@ class IndicatorTestCase(UnityTestCase):
3647 ('Power', dict(indicator_name='indicator-power')),
3748 ('Sound', dict(indicator_name='indicator-sound')),
3849 ]
50+ scenarios = multiply_scenarios(
51+ indicator_scenarios,
52+ IndicatorTestCase.device_emulation_scenarios
53+ )
3954
40− @skipIf(platform.image_codename() == 'Desktop',
41− "Unity8/phablet-only test!")
4255 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.')
4460
4561 def test_indicator_exists(self):
46− unity_proxy = self.launch_unity()
47− indicator = self.main_window.get_indicator(self.indicator_name)
48− self.assertIsNotNone(indicator)
62+ self.main_window._get_indicator_widget(
63+ self.indicator_name
64+ )
65+
66+
67+class IndicatorPageTitleMatchesWidgetTestCase(IndicatorTestCase):
68+
69+ indicator_scenarios = [
70+ ('Bluetooth', dict(indicator_name='indicator-bluetooth',
71+ title='Bluetooth')),
72+ ('Datetime', dict(indicator_name='indicator-datetime',
73+ title='Upcoming')),
74+ ('Location', dict(indicator_name='indicator-location',
75+ title='Location')),
76+ ('Messaging', dict(indicator_name='indicator-messages',
77+ title='Incoming')),
78+ ('Network', dict(indicator_name='indicator-network',
79+ title='Network')),
80+ ('Power', dict(indicator_name='indicator-power',
81+ title='Battery')),
82+ ('Sound', dict(indicator_name='indicator-sound',
83+ title='Sound')),
84+ ]
85+ scenarios = multiply_scenarios(
86+ indicator_scenarios,
87+ IndicatorTestCase.device_emulation_scenarios
88+ )
89+
90+ def setUp(self):
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.')
95+
96+ def test_indicator_page_title_matches_widget(self):
97+ """Swiping open an indicator must show its correct title.
98+
99+ See https://bugs.launchpad.net/ubuntu-ux/+bug/1253804 .
100+ """
101+ indicator_page = self.main_window.open_indicator_page(
102+ self.indicator_name)
103+ self.assertTrue(indicator_page.visible)
104+ self.assertEqual(indicator_page.title, self.title)