on xenial help sign in
Moved the fixture setup helpers to the common file.
commit2bac421aab78109ec6e4808d0693877720c3570a authorLeo Arias <leo.arias@canonical.com> dateMon 19 Jan 2015, 14:07 (12 years ago) parentd516c41
3 files changed+39−63
tests/autopilot/unity8/fixture_setup.py+36−1 tests/autopilot/unity8/indicators/fixture_setup.py−58 tests/autopilot/unity8/indicators/tests/test_indicators.py+3−4
tests/autopilot/unity8/fixture_setup.py+36−1
@@ -1,7 +1,7 @@
11# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
22#
33# Unity Autopilot Test Suite
4−# Copyright (C) 2014 Canonical
4+# Copyright (C) 2014, 2015 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
@@ -18,6 +18,8 @@
1818#
1919
2020import fixtures
21+import subprocess
22+
2123from autopilot import introspection
2224
2325from unity8 import process_helpers
@@ -62,3 +64,36 @@ class LaunchDashApp(fixtures.Fixture):
6264
6365 def stop_application(self):
6466 process_helpers.stop_job('unity8-dash')
67+
68+
69+class IndicatorDisplayRotationLock(fixtures.Fixture):
70+
71+ def __init__(self, enable):
72+ super().__init__()
73+ self.enable = enable
74+
75+ def setUp(self):
76+ super().setUp()
77+ original_state = self._is_rotation_lock_enabled()
78+ if self.enable != original_state:
79+ self.addCleanup(self._set_rotation_lock, original_state)
80+ self._set_rotation_lock(self.enable)
81+
82+ def _is_rotation_lock_enabled(self):
83+ command = [
84+ 'gsettings', 'get',
85+ 'com.ubuntu.touch.system',
86+ 'rotation-lock'
87+ ]
88+ output = subprocess.check_output(command, universal_newlines=True)
89+ print (output)
90+ return True if output.count('true') else False
91+
92+ def _set_rotation_lock(self, value):
93+ value_string = 'true' if value else 'false'
94+ command = [
95+ 'gsettings', 'set',
96+ 'com.ubuntu.touch.system',
97+ 'rotation-lock', '{}'.format(value_string)
98+ ]
99+ subprocess.check_output(command)
tests/autopilot/unity8/indicators/fixture_setup.pydeleted−58
@@ -1,58 +0,0 @@
1−# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−#
3−# Unity Autopilot Test Suite
4−# Copyright (C) 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−
20−"""Set up and clean up fixtures for the Unity acceptance tests."""
21−
22−import os
23−import subprocess
24−
25−import fixtures
26−
27−
28−class IndicatorDisplayRotationLock(fixtures.Fixture):
29−
30− def __init__(self, enable):
31− super().__init__()
32− self.enable = enable
33−
34− def setUp(self):
35− super().setUp()
36− original_state = self._is_rotation_lock_enabled()
37− if self.enable != original_state:
38− self.addCleanup(self._set_rotation_lock, original_state)
39− self._set_rotation_lock(self.enable)
40−
41− def _is_rotation_lock_enabled(self):
42− command = [
43− 'gsettings', 'get',
44− 'com.ubuntu.touch.system',
45− 'rotation-lock'
46− ]
47− output = subprocess.check_output(command, universal_newlines=True)
48− print (output)
49− return True if output.count('true') else False
50−
51− def _set_rotation_lock(self, value):
52− value_string = 'true' if value else 'false'
53− command = [
54− 'gsettings', 'set',
55− 'com.ubuntu.touch.system',
56− 'rotation-lock', '{}'.format(value_string)
57− ]
58− subprocess.check_output(command)
tests/autopilot/unity8/indicators/tests/test_indicators.py+3−4
@@ -1,7 +1,7 @@
11# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
22#
33# Unity Indicators Autopilot Test Suite
4−# Copyright (C) 2013, 2014 Canonical
4+# Copyright (C) 2013, 2014, 2015 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
@@ -22,11 +22,10 @@ from testscenarios import multiply_scenarios
2222
2323from autopilot import platform
2424
25−from unity8 import indicators
25+from unity8 import indicators, fixture_setup
2626from unity8.process_helpers import unlock_unity
2727from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
2828
29−from unity8.indicators import fixture_setup as indicators_fixtures
3029
3130class IndicatorTestCase(UnityTestCase):
3231
@@ -113,7 +112,7 @@ class DisplayIndicatorTestCase(IndicatorTestCase):
113112 def test(self):
114113 display_indicator = indicators.DisplayIndicator(self.main_window)
115114 display_indicator_page = display_indicator.open()
116− fixture = indicators_fixtures.IndicatorDisplayRotationLock(False)
115+ fixture = fixture_setup.IndicatorDisplayRotationLock(False)
117116
118117 display_indicator_page.unlock_rotation()
119118 self.assertEqual(fixture._is_rotation_lock_enabled(), False)