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 __future__ import absolute_import
20 
21 from testscenarios import multiply_scenarios
22 
23 from autopilot import platform
24 
25 from unity8.indicators import tests
26 
27 
28 class IndicatorExistsTestCase(tests.IndicatorTestCase):
29 
30  indicator_scenarios = [
31  ('Bluetooth', dict(indicator_name='indicator-bluetooth')),
32  ('Datetime', dict(indicator_name='indicator-datetime')),
33  ('Location', dict(indicator_name='indicator-location')),
34  ('Messaging', dict(indicator_name='indicator-messages')),
35  ('Network', dict(indicator_name='indicator-network')),
36  ('Power', dict(indicator_name='indicator-power')),
37  ('Sound', dict(indicator_name='indicator-sound')),
38  ]
39  scenarios = multiply_scenarios(
40  indicator_scenarios,
41  tests.IndicatorTestCase.device_emulation_scenarios
42  )
43 
44  def setUp(self):
45  super(IndicatorExistsTestCase, self).setUp()
46  if (platform.model() == 'Nexus 10' and
47  self.indicator_name == 'indicator-bluetooth'):
48  self.skipTest('Nexus 10 does not have bluetooth at the moment.')
49 
50  def test_indicator_exists(self):
51  self.main_window._get_indicator_panel_item(
52  self.indicator_name
53  )
54 
55 
56 class IndicatorPageTitleMatchesWidgetTestCase(tests.IndicatorTestCase):
57 
58  indicator_scenarios = [
59  ('Bluetooth', dict(indicator_name='indicator-bluetooth',
60  title='Bluetooth')),
61  ('Datetime', dict(indicator_name='indicator-datetime',
62  title='Time & Date')),
63  ('Location', dict(indicator_name='indicator-location',
64  title='Location')),
65  ('Messaging', dict(indicator_name='indicator-messages',
66  title='Notifications')),
67  ('Network', dict(indicator_name='indicator-network',
68  title='Network')),
69  ('Power', dict(indicator_name='indicator-power',
70  title='Battery')),
71  ('Sound', dict(indicator_name='indicator-sound',
72  title='Sound')),
73  ]
74  scenarios = multiply_scenarios(
75  indicator_scenarios,
76  tests.IndicatorTestCase.device_emulation_scenarios
77  )
78 
79  def setUp(self):
80  super(IndicatorPageTitleMatchesWidgetTestCase, self).setUp()
81  if (platform.model() == 'Nexus 10' and
82  self.indicator_name == 'indicator-bluetooth'):
83  self.skipTest('Nexus 10 does not have bluetooth at the moment.')
84 
85  def test_indicator_page_title_matches_widget(self):
86  """Swiping open an indicator must show its correct title.
87 
88  See https://bugs.launchpad.net/ubuntu-ux/+bug/1253804 .
89  """
90  indicator_page = self.main_window.open_indicator_page(
91  self.indicator_name)
92  self.assertTrue(indicator_page.visible)
93  self.assertEqual(indicator_page.title, self.title)