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