@@ -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,85 +17,103 @@
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/>.
22+from autopilot import logging as autopilot_logging
24+from unity8.shell import emulators
21from unity8.shell.emulators.greeter import Greeter
25from unity8.shell.emulators.greeter import Greeter
22from unity8.shell.emulators.hud import Hud
26from unity8.shell.emulators.hud import Hud
23from unity8.shell.emulators.dash import Dash
27from unity8.shell.emulators.dash import Dash
24from unity8.shell.emulators.launcher import Launcher
28from unity8.shell.emulators.launcher import Launcher
30+logger = logging.getLogger(__name__)
27−class MainWindow(object):
28− """An emulator class that makes it easy to interact with the shell"""
30− def __init__(self, app):
33− def get_qml_view(self):
33+class QQuickView(emulators.UnityEmulatorBase):
34− """Get the main QML view"""
34+ """An emulator class that makes it easy to interact with the shell"""
35− return self.app.select_single("QQuickView")
37 def get_greeter(self):
36 def get_greeter(self):
38− return self.app.select_single(Greeter)
37+ return self.select_single(Greeter)
40 def get_greeter_content_loader(self):
39 def get_greeter_content_loader(self):
41− return self.app.wait_select_single(
40+ return self.wait_select_single(
42 "QQuickLoader",
41 "QQuickLoader",
43 objectName="greeterContentLoader"
42 objectName="greeterContentLoader"
46 def get_greeter_background(self):
45 def get_greeter_background(self):
46+ return self.select_single(
47− return self.app.select_single("CrossFadeImage", objectName="greeterBackground")
47+ "CrossFadeImage", objectName="greeterBackground")
49 def get_login_loader(self):
49 def get_login_loader(self):
50− return self.app.select_single("QQuickLoader", objectName="loginLoader")
50+ return self.select_single("QQuickLoader", objectName="loginLoader")
52 def get_login_list(self):
52 def get_login_list(self):
53− return self.app.select_single("LoginList")
53+ return self.select_single("LoginList")
55 def get_hud(self):
55 def get_hud(self):
56− return self.app.select_single(Hud)
56+ return self.select_single(Hud)
58 def get_hud_showable(self):
58 def get_hud_showable(self):
59− return self.app.select_single("Showable", objectName="hudShowable")
59+ return self.select_single("Showable", objectName="hudShowable")
61 def get_hud_show_button(self):
61 def get_hud_show_button(self):
62− return self.app.select_single("HudButton")
62+ return self.select_single("HudButton")
64 def get_hud_edge_drag_area(self):
64 def get_hud_edge_drag_area(self):
65− return self.app.select_single(objectName="hudDragArea")
65+ return self.select_single(objectName="hudDragArea")
67 def get_dash(self):
67 def get_dash(self):
68− return self.app.select_single(Dash)
68+ return self.select_single(Dash)
70 def get_bottombar(self):
70 def get_bottombar(self):
71− return self.app.select_single("Bottombar")
71+ return self.select_single("Bottombar")
73 def get_launcher(self):
73 def get_launcher(self):
74− return self.app.select_single(Launcher)
74+ return self.select_single(Launcher)
76 def get_pinPadLoader(self):
76 def get_pinPadLoader(self):
77− return self.app.select_single(
77+ return self.select_single(
78 "QQuickLoader",
78 "QQuickLoader",
79 objectName="pinPadLoader"
79 objectName="pinPadLoader"
82 def get_pinPadButton(self, buttonId):
82 def get_pinPadButton(self, buttonId):
83− return self.app.select_single(
83+ return self.select_single(
84 "PinPadButton",
84 "PinPadButton",
85 objectName="pinPadButton%i" % buttonId
85 objectName="pinPadButton%i" % buttonId
88 def get_lockscreen(self):
88 def get_lockscreen(self):
89− return self.app.select_single("Lockscreen")
89+ return self.select_single("Lockscreen")
91 def get_pinentryField(self):
91 def get_pinentryField(self):
92− return self.app.select_single(objectName="pinentryField")
92+ return self.select_single(objectName="pinentryField")
94 def get_indicator(self, indicator_name):
94 def get_indicator(self, indicator_name):
95− return self.app.wait_select_single(
95+ return self.wait_select_single(
96 'DefaultIndicatorWidget',
96 'DefaultIndicatorWidget',
97 objectName=indicator_name+'-widget'
97 objectName=indicator_name+'-widget'
100 def get_shell_background(self):
100 def get_shell_background(self):
101+ return self.select_single(
101− return self.app.select_single("CrossFadeImage", objectName="backgroundImage")
102+ "CrossFadeImage", objectName="backgroundImage")
104+ @autopilot_logging.log_action(logger.info)
105+ def show_dash_swiping(self):
106+ """Show the dash swiping from the left."""
108+ height = self.height
110+ start_y = height // 2
114+ self.pointing_device.drag(start_x, start_y, end_x, end_y)
115+ return self.get_dash()
117+ def get_current_focused_app_id(self):
118+ """Return the id of the focused application."""
119+ return self.select_single('Shell').currentFocusedAppId