@@ -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 Canonical
4+# Copyright (C) 2012, 2013, 2014 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
@@ -17,22 +17,43 @@
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818#
1919
20−from unity8.shell.emulators import UnityEmulatorBase
21−from autopilot.input import Touch
20+import logging
2221
22+import autopilot.logging
2323
24−class Launcher(UnityEmulatorBase):
24+from unity8.shell import emulators
25+
26+
27+logger = logging.getLogger(__name__)
28+
29+
30+class Launcher(emulators.UnityEmulatorBase):
2531
2632 """An emulator that understands the Launcher."""
2733
34+ @autopilot.logging.log_action(logger.debug)
2835 def show(self):
29− """Swipes open the launcher."""
30− touch = Touch.create()
36+ """Show the launcher swiping it to the right."""
37+ if not self.shown:
38+ self._swipe_to_show_launcher()
39+ self.shown.wait_for(True)
40+ else:
41+ logger.debug('The launcher is already opened.')
3142
43+ def _swipe_to_show_launcher(self):
3244 view = self.get_root_instance().select_single('QQuickView')
45+ start_y = stop_y = view.y + view.height // 2
46+
3347 start_x = view.x + 1
34− start_y = view.y + view.height / 2
35− stop_x = start_x + self.panelWidth + 1
36− stop_y = start_y
37− touch.drag(start_x, start_y, stop_x, stop_y)
38− self.shown.wait_for(True)
48+ stop_x = start_x + self.panelWidth - 1
49+
50+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
51+
52+ @autopilot.logging.log_action(logger.debug)
53+ def click_dash_icon(self):
54+ if self.shown:
55+ dash_icon = self.select_single(
56+ 'QQuickImage', objectName='dashItem')
57+ self.pointing_device.click_object(dash_icon)
58+ else:
59+ raise emulators.UnityEmulatorException('The launcher is closed.')