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