on xenial help sign in
Finished two full tests for the rotation lock.
commitfccd1228136c8773670a1fa81b2f1785ad4d7e00 authorLeo Arias <leo.arias@canonical.com> dateTue 20 Jan 2015, 22:01 (12 years ago) parentbe41887
4 files changed+41−10
tests/autopilot/unity8/fixture_setup.py+1−2 tests/autopilot/unity8/indicators/__init__.py+8 tests/autopilot/unity8/indicators/tests/test_display_indicator.py+21−5 tests/autopilot/unity8/shell/emulators/main_window.py+11−3
tests/autopilot/unity8/fixture_setup.py+1−2
@@ -73,7 +73,7 @@ class DisplayRotationLock(fixtures.Fixture):
7373 self.enable = enable
7474
7575 def setUp(self):
76− super(self, DisplayRotationLock).setUp()
76+ super(DisplayRotationLock, self).setUp()
7777 original_state = self._is_rotation_lock_enabled()
7878 if self.enable != original_state:
7979 self.addCleanup(self._set_rotation_lock, original_state)
@@ -86,7 +86,6 @@ class DisplayRotationLock(fixtures.Fixture):
8686 'rotation-lock'
8787 ]
8888 output = subprocess.check_output(command, universal_newlines=True)
89− print (output)
9089 return True if output.count('true') else False
9190
9291 def _set_rotation_lock(self, value):
tests/autopilot/unity8/indicators/__init__.py+8
@@ -38,6 +38,11 @@ class DisplayIndicator(object):
3838 def __init__(self, main_window):
3939 self._main_window = main_window
4040
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+
4146 def open(self):
4247 """Open the display indicator page.
4348
@@ -80,6 +85,9 @@ class DisplayIndicator(object):
8085 flickable.dragging.wait_for(False)
8186 flickable.moving.wait_for(False)
8287
88+ def close(self):
89+ self._main_window.close_indicator_page()
90+
8391
8492class DisplayIndicatorPage(IndicatorPage):
8593
tests/autopilot/unity8/indicators/tests/test_display_indicator.py+21−5
@@ -25,13 +25,29 @@ from unity8.indicators import tests
2525
2626class DisplayIndicatorTestCase(tests.IndicatorTestCase):
2727
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)
2934 display_indicator = indicators.DisplayIndicator(self.main_window)
35+ self.assertFalse(display_indicator.is_indicator_icon_visible())
36+
3037 display_indicator_page = display_indicator.open()
31− fixture = fixture_setup.DisplayRotationLock(False)
38+ display_indicator_page.lock_rotation()
39+ display_indicator.close()
3240
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()
3350 display_indicator_page.unlock_rotation()
34− self.assertEqual(fixture._is_rotation_lock_enabled(), False)
51+ display_indicator.close()
3552
36− display_indicator_page.lock_rotation()
37− self.assertEqual(fixture._is_rotation_lock_enabled(), True)
53+ self.assertFalse(display_indicator.is_indicator_icon_visible())
tests/autopilot/unity8/shell/emulators/main_window.py+11−3
@@ -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) 2012, 2013, 2014 Canonical
4+# Copyright (C) 2012, 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
@@ -19,14 +19,12 @@
1919
2020import logging
2121
22−import ubuntuuitoolkit
2322from autopilot import logging as autopilot_logging
2423from autopilot import input
2524
2625from unity8.shell import emulators
2726from unity8.shell.emulators.greeter import Greeter
2827from unity8.shell.emulators.launcher import Launcher
29−import unity8.indicators
3028
3129logger = logging.getLogger(__name__)
3230
@@ -90,6 +88,16 @@ class QQuickView(emulators.UnityEmulatorBase):
9088 self.wait_select_single('IndicatorsMenu', fullyOpened=True)
9189 return self._get_indicator_page(indicator_name)
9290
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+
93101 @autopilot_logging.log_action(logger.info)
94102 def show_dash_swiping(self):
95103 """Show the dash swiping from the left."""