Unity 8
test_indicators.py
1 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2 #
3 # Unity Indicators Autopilot Test Suite
4 # Copyright (C) 2013, 2014, 2015 Canonical
5 #
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
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
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/>.
18 
19 from testscenarios import multiply_scenarios
20 
21 from autopilot import platform
22 
23 from unity8.indicators import tests
24 
25 
26 class IndicatorExistsTestCase(tests.DeviceIndicatorTestCase):
27 
28  indicator_scenarios = [
29  ('Bluetooth', dict(indicator_name='indicator-bluetooth')),
30  ('Datetime', dict(indicator_name='indicator-datetime')),
31  ('Location', dict(indicator_name='indicator-location')),
32  ('Messaging', dict(indicator_name='indicator-messages')),
33  ('Network', dict(indicator_name='indicator-network')),
34  ('Power', dict(indicator_name='indicator-power')),
35  ('Sound', dict(indicator_name='indicator-sound')),
36  ]
37  scenarios = multiply_scenarios(
38  indicator_scenarios,
39  tests.IndicatorTestCase.device_emulation_scenarios
40  )
41 
42  def setUp(self):
43  super().setUp()
44  if (platform.model() == 'Nexus 10' and
45  self.indicator_name == 'indicator-bluetooth'):
46  self.skipTest('Nexus 10 does not have bluetooth at the moment.')
47 
48  def test_indicator_exists(self):
49  self.main_window._get_indicator_panel_item(
50  self.indicator_name
51  )
52 
53 
54 class IndicatorPageTitleMatchesWidgetTestCase(tests.DeviceIndicatorTestCase):
55 
56  indicator_scenarios = [
57  ('Bluetooth', dict(indicator_name='indicator-bluetooth',
58  title='Bluetooth')),
59  ('Datetime', dict(indicator_name='indicator-datetime',
60  title='Time & Date')),
61  ('Location', dict(indicator_name='indicator-location',
62  title='Location')),
63  ('Messaging', dict(indicator_name='indicator-messages',
64  title='Notifications')),
65  ('Network', dict(indicator_name='indicator-network',
66  title='Network')),
67  ('Power', dict(indicator_name='indicator-power',
68  title='Battery')),
69  ('Sound', dict(indicator_name='indicator-sound',
70  title='Sound')),
71  ]
72  scenarios = multiply_scenarios(
73  indicator_scenarios,
74  tests.IndicatorTestCase.device_emulation_scenarios
75  )
76 
77  def setUp(self):
78  super().setUp()
79  if (platform.model() == 'Nexus 10' and
80  self.indicator_name == 'indicator-bluetooth'):
81  self.skipTest('Nexus 10 does not have bluetooth at the moment.')
82 
83  def test_indicator_page_title_matches_widget(self):
84  """Swiping open an indicator must show its correct title.
85 
86  See https://bugs.launchpad.net/ubuntu-ux/+bug/1253804 .
87  """
88  indicator_page = self.main_window.open_indicator_page(
89  self.indicator_name)
90  self.assertTrue(indicator_page.visible)
91  self.assertEqual(indicator_page.title, self.title)