on xenial help sign in
Finished two full tests for the rotation lock.
fccd122Leo Arias
tests/autopilot/unity8/fixture_setup.py+1−2
@@ -73,7 +73,7 @@ class DisplayRotationLock(fixtures.Fixture):
73 self.enable = enable
73 self.enable = enable
74
74
75 def setUp(self):
75 def setUp(self):
76− super(self, DisplayRotationLock).setUp()
76+ super(DisplayRotationLock, self).setUp()
77 original_state = self._is_rotation_lock_enabled()
77 original_state = self._is_rotation_lock_enabled()
78 if self.enable != original_state:
78 if self.enable != original_state:
79 self.addCleanup(self._set_rotation_lock, original_state)
79 self.addCleanup(self._set_rotation_lock, original_state)
@@ -86,7 +86,6 @@ class DisplayRotationLock(fixtures.Fixture):
86 'rotation-lock'
86 'rotation-lock'
87 ]
87 ]
88 output = subprocess.check_output(command, universal_newlines=True)
88 output = subprocess.check_output(command, universal_newlines=True)
89− print (output)
90 return True if output.count('true') else False
89 return True if output.count('true') else False
91
90
92 def _set_rotation_lock(self, value):
91 def _set_rotation_lock(self, value):
tests/autopilot/unity8/indicators/__init__.py+8
@@ -38,6 +38,11 @@ class DisplayIndicator(object):
38 def __init__(self, main_window):
38 def __init__(self, main_window):
39 self._main_window = main_window
39 self._main_window = main_window
40
40
41+ def is_indicator_icon_visible(self):
42+ panel_item = self._main_window.wait_select_single(
43+ objectName='indicator-rotation-lock-panelItem')
44+ return panel_item.indicatorVisible
45+
41 def open(self):
46 def open(self):
42 """Open the display indicator page.
47 """Open the display indicator page.
43
48
@@ -80,6 +85,9 @@ class DisplayIndicator(object):
80 flickable.dragging.wait_for(False)
85 flickable.dragging.wait_for(False)
81 flickable.moving.wait_for(False)
86 flickable.moving.wait_for(False)
82
87
88+ def close(self):
89+ self._main_window.close_indicator_page()
90+
83
91
84class DisplayIndicatorPage(IndicatorPage):
92class DisplayIndicatorPage(IndicatorPage):
85
93
tests/autopilot/unity8/indicators/tests/test_display_indicator.py+21−5
@@ -25,13 +25,29 @@ from unity8.indicators import tests
25
25
26class DisplayIndicatorTestCase(tests.IndicatorTestCase):
26class DisplayIndicatorTestCase(tests.IndicatorTestCase):
27
27
28− def test(self):
28+ def test_indicator_icon_must_be_visible_after_rotation_locked(self):
29+ # TODO remove the skip when the bug is fixed. --elopio - 2015-01-20
30+ self.skipTest(
31+ 'This test fails because of bug http://pad.lv/1410915')
32+ rotation_unlocked = fixture_setup.DisplayRotationLock(False)
33+ self.useFixture(rotation_unlocked)
29 display_indicator = indicators.DisplayIndicator(self.main_window)
34 display_indicator = indicators.DisplayIndicator(self.main_window)
35+ self.assertFalse(display_indicator.is_indicator_icon_visible())
36+
30 display_indicator_page = display_indicator.open()
37 display_indicator_page = display_indicator.open()
31− fixture = fixture_setup.DisplayRotationLock(False)
38+ display_indicator_page.lock_rotation()
39+ display_indicator.close()
32
40
41+ self.assertTrue(display_indicator.is_indicator_icon_visible())
42+
43+ def test_indicator_icon_must_not_be_visible_after_rotation_unlocked(self):
44+ rotation_locked = fixture_setup.DisplayRotationLock(True)
45+ self.useFixture(rotation_locked)
46+ display_indicator = indicators.DisplayIndicator(self.main_window)
47+ self.assertTrue(display_indicator.is_indicator_icon_visible())
48+
49+ display_indicator_page = display_indicator.open()
33 display_indicator_page.unlock_rotation()
50 display_indicator_page.unlock_rotation()
34− self.assertEqual(fixture._is_rotation_lock_enabled(), False)
51+ display_indicator.close()
35
52
36− display_indicator_page.lock_rotation()
53+ self.assertFalse(display_indicator.is_indicator_icon_visible())
37− self.assertEqual(fixture._is_rotation_lock_enabled(), True)
tests/autopilot/unity8/shell/emulators/main_window.py+11−3
@@ -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) 2012, 2013, 2014 Canonical
4+# Copyright (C) 2012, 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
@@ -19,14 +19,12 @@
19
19
20import logging
20import logging
21
21
22−import ubuntuuitoolkit
23from autopilot import logging as autopilot_logging
22from autopilot import logging as autopilot_logging
24from autopilot import input
23from autopilot import input
25
24
26from unity8.shell import emulators
25from unity8.shell import emulators
27from unity8.shell.emulators.greeter import Greeter
26from unity8.shell.emulators.greeter import Greeter
28from unity8.shell.emulators.launcher import Launcher
27from unity8.shell.emulators.launcher import Launcher
29−import unity8.indicators
30
28
31logger = logging.getLogger(__name__)
29logger = logging.getLogger(__name__)
32
30
@@ -90,6 +88,16 @@ class QQuickView(emulators.UnityEmulatorBase):
90 self.wait_select_single('IndicatorsMenu', fullyOpened=True)
88 self.wait_select_single('IndicatorsMenu', fullyOpened=True)
91 return self._get_indicator_page(indicator_name)
89 return self._get_indicator_page(indicator_name)
92
90
91+ @autopilot_logging.log_action(logger.info)
92+ def close_indicator_page(self):
93+ """Swipe to close the opened indicator, wait until it's closed."""
94+ indicators_menu = self.wait_select_single('IndicatorsMenu')
95+ end_x, end_y = input.get_center_point(indicators_menu)
96+ start_x = end_x
97+ start_y = self.height
98+ self.pointing_device.drag(start_x, start_y, end_x, end_y)
99+ indicators_menu.fullyClosed.wait_for(True)
100+
93 @autopilot_logging.log_action(logger.info)
101 @autopilot_logging.log_action(logger.info)
94 def show_dash_swiping(self):
102 def show_dash_swiping(self):
95 """Show the dash swiping from the left."""
103 """Show the dash swiping from the left."""