Unity 8
 All Classes Functions
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 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.process_helpers import unlock_unity
26 from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
27 
28 
29 class IndicatorTestCase(UnityTestCase):
30 
31  device_emulation_scenarios = _get_device_emulation_scenarios()
32 
33  def setUp(self):
34  if platform.model() == 'Desktop':
35  self.skipTest('Test cannot be run on the desktop.')
36  super(IndicatorTestCase, self).setUp()
37  self.unity_proxy = self.launch_unity()
38  unlock_unity(self.unity_proxy)
39 
40 
41 class IndicatorExistsTestCase(IndicatorTestCase):
42 
43  indicator_scenarios = [
44  ('Bluetooth', dict(indicator_name='indicator-bluetooth')),
45  ('Datetime', dict(indicator_name='indicator-datetime')),
46  ('Location', dict(indicator_name='indicator-location')),
47  ('Messaging', dict(indicator_name='indicator-messages')),
48  ('Network', dict(indicator_name='indicator-network')),
49  ('Power', dict(indicator_name='indicator-power')),
50  ('Sound', dict(indicator_name='indicator-sound')),
51  ]
52  scenarios = multiply_scenarios(
53  indicator_scenarios,
54  IndicatorTestCase.device_emulation_scenarios
55  )
56 
57  def setUp(self):
58  super(IndicatorExistsTestCase, self).setUp()
59  if (platform.model() == 'Nexus 10' and
60  self.indicator_name == 'indicator-bluetooth'):
61  self.skipTest('Nexus 10 does not have bluetooth at the moment.')
62 
63  def test_indicator_exists(self):
64  self.main_window._get_indicator_widget(
65  self.indicator_name
66  )
67 
68 
69 class IndicatorPageTitleMatchesWidgetTestCase(IndicatorTestCase):
70 
71  indicator_scenarios = [
72  ('Bluetooth', dict(indicator_name='indicator-bluetooth',
73  title='Bluetooth')),
74  ('Datetime', dict(indicator_name='indicator-datetime',
75  title='Upcoming events')),
76  ('Location', dict(indicator_name='indicator-location',
77  title='Location')),
78  ('Messaging', dict(indicator_name='indicator-messages',
79  title='Notification center')),
80  ('Network', dict(indicator_name='indicator-network',
81  title='Network')),
82  ('Power', dict(indicator_name='indicator-power',
83  title='Battery')),
84  ('Sound', dict(indicator_name='indicator-sound',
85  title='Sound')),
86  ]
87  scenarios = multiply_scenarios(
88  indicator_scenarios,
89  IndicatorTestCase.device_emulation_scenarios
90  )
91 
92  def setUp(self):
93  super(IndicatorPageTitleMatchesWidgetTestCase, self).setUp()
94  if (platform.model() == 'Nexus 10' and
95  self.indicator_name == 'indicator-bluetooth'):
96  self.skipTest('Nexus 10 does not have bluetooth at the moment.')
97 
98  def test_indicator_page_title_matches_widget(self):
99  """Swiping open an indicator must show its correct title.
100 
101  See https://bugs.launchpad.net/ubuntu-ux/+bug/1253804 .
102  """
103  indicator_page = self.main_window.open_indicator_page(
104  self.indicator_name)
105  self.assertTrue(indicator_page.visible)
106  self.assertEqual(indicator_page.title, self.title)