on xenial help sign in
Moved the fixture setup helpers to the common file.
2bac421Leo Arias
tests/autopilot/unity8/fixture_setup.py+36−1
@@ -1,7 +1,7 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
2#
3# Unity Autopilot Test Suite
3# Unity Autopilot Test Suite
4−# Copyright (C) 2014 Canonical
4+# Copyright (C) 2014, 2015 Canonical
5#
5#
6# This program is free software: you can redistribute it and/or modify
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
7# it under the terms of the GNU General Public License as published by
@@ -18,6 +18,8 @@
18#
18#
19
19
20import fixtures
20import fixtures
21+import subprocess
22+
21from autopilot import introspection
23from autopilot import introspection
22
24
23from unity8 import process_helpers
25from unity8 import process_helpers
@@ -62,3 +64,36 @@ class LaunchDashApp(fixtures.Fixture):
62
64
63 def stop_application(self):
65 def stop_application(self):
64 process_helpers.stop_job('unity8-dash')
66 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 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
2#
3# Unity Indicators Autopilot Test Suite
3# Unity Indicators Autopilot Test Suite
4−# Copyright (C) 2013, 2014 Canonical
4+# Copyright (C) 2013, 2014, 2015 Canonical
5#
5#
6# This program is free software: you can redistribute it and/or modify
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
7# it under the terms of the GNU General Public License as published by
@@ -22,11 +22,10 @@ from testscenarios import multiply_scenarios
22
22
23from autopilot import platform
23from autopilot import platform
24
24
25−from unity8 import indicators
25+from unity8 import indicators, fixture_setup
26from unity8.process_helpers import unlock_unity
26from unity8.process_helpers import unlock_unity
27from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
27from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
28
28
29−from unity8.indicators import fixture_setup as indicators_fixtures
30
29
31class IndicatorTestCase(UnityTestCase):
30class IndicatorTestCase(UnityTestCase):
32
31
@@ -113,7 +112,7 @@ class DisplayIndicatorTestCase(IndicatorTestCase):
113 def test(self):
112 def test(self):
114 display_indicator = indicators.DisplayIndicator(self.main_window)
113 display_indicator = indicators.DisplayIndicator(self.main_window)
115 display_indicator_page = display_indicator.open()
114 display_indicator_page = display_indicator.open()
116− fixture = indicators_fixtures.IndicatorDisplayRotationLock(False)
115+ fixture = fixture_setup.IndicatorDisplayRotationLock(False)
117
116
118 display_indicator_page.unlock_rotation()
117 display_indicator_page.unlock_rotation()
119 self.assertEqual(fixture._is_rotation_lock_enabled(), False)
118 self.assertEqual(fixture._is_rotation_lock_enabled(), False)