Merge lp:~om26er/ubuntu-terminal-app/initial_autopilot into lp:ubuntu-terminal-app

Proposed by Omer Akram
Status: Merged
Approved by: Michael Hall
Approved revision: 10
Merged at revision: 13
Proposed branch: lp:~om26er/ubuntu-terminal-app/initial_autopilot
Merge into: lp:ubuntu-terminal-app
Diff against target: 183 lines (+140/-0)
7 files modified
debian/control (+8/-0)
debian/ubuntu-terminal-app-autopilot.install (+1/-0)
tests/autopilot/ubuntu_terminal_app/__init__.py (+8/-0)
tests/autopilot/ubuntu_terminal_app/emulators/__init__.py (+6/-0)
tests/autopilot/ubuntu_terminal_app/emulators/main_window.py (+24/-0)
tests/autopilot/ubuntu_terminal_app/tests/__init__.py (+55/-0)
tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py (+38/-0)
To merge this branch: bzr merge lp:~om26er/ubuntu-terminal-app/initial_autopilot
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Michael Hall Approve
Review via email: mp+166789@code.launchpad.net

Commit message

add initial structure for autopilot testing

Description of the change

add initial structure for autopilot testing

To post a comment you must log in.
Revision history for this message
Omer Akram (om26er) wrote :

Could anyone review this one, please?

Revision history for this message
Michael Hall (mhall119) wrote :

Looks good

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-05-01 16:22:10 +0000
3+++ debian/control 2013-05-31 13:16:57 +0000
4@@ -17,3 +17,11 @@
5 qtdeclarative5-konsole-qml-plugin
6 Description: Terminal application
7 Core Terminal application
8+
9+Package: ubuntu-terminal-app-autopilot
10+Architecture: all
11+Depends: libautopilot-qt,
12+ libqt5test5,
13+ ubuntu-terminal-app (= ${source:Version})
14+Description: Autopilot tests for Terminal Application
15+ This package contains the autopilot tests for the Terminal
16
17=== added file 'debian/ubuntu-terminal-app-autopilot.install'
18--- debian/ubuntu-terminal-app-autopilot.install 1970-01-01 00:00:00 +0000
19+++ debian/ubuntu-terminal-app-autopilot.install 2013-05-31 13:16:57 +0000
20@@ -0,0 +1,1 @@
21+tests/autopilot/ubuntu_terminal_app/* usr/lib/python2.7/dist-packages/ubuntu_terminal_app/
22\ No newline at end of file
23
24=== added directory 'tests'
25=== added directory 'tests/autopilot'
26=== added directory 'tests/autopilot/ubuntu_terminal_app'
27=== added file 'tests/autopilot/ubuntu_terminal_app/__init__.py'
28--- tests/autopilot/ubuntu_terminal_app/__init__.py 1970-01-01 00:00:00 +0000
29+++ tests/autopilot/ubuntu_terminal_app/__init__.py 2013-05-31 13:16:57 +0000
30@@ -0,0 +1,8 @@
31+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
32+# Copyright 2013 Canonical
33+#
34+# This program is free software: you can redistribute it and/or modify it
35+# under the terms of the GNU General Public License version 3, as published
36+# by the Free Software Foundation.
37+
38+"""terminal-app tests and emulators - top level package."""
39
40=== added directory 'tests/autopilot/ubuntu_terminal_app/emulators'
41=== added file 'tests/autopilot/ubuntu_terminal_app/emulators/__init__.py'
42--- tests/autopilot/ubuntu_terminal_app/emulators/__init__.py 1970-01-01 00:00:00 +0000
43+++ tests/autopilot/ubuntu_terminal_app/emulators/__init__.py 2013-05-31 13:16:57 +0000
44@@ -0,0 +1,6 @@
45+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
46+# Copyright 2013 Canonical
47+#
48+# This program is free software: you can redistribute it and/or modify it
49+# under the terms of the GNU General Public License version 3, as published
50+# by the Free Software Foundation.
51
52=== added file 'tests/autopilot/ubuntu_terminal_app/emulators/main_window.py'
53--- tests/autopilot/ubuntu_terminal_app/emulators/main_window.py 1970-01-01 00:00:00 +0000
54+++ tests/autopilot/ubuntu_terminal_app/emulators/main_window.py 2013-05-31 13:16:57 +0000
55@@ -0,0 +1,24 @@
56+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
57+# Copyright 2013 Canonical
58+#
59+# This program is free software: you can redistribute it and/or modify it
60+# under the terms of the GNU General Public License version 3, as published
61+# by the Free Software Foundation.
62+
63+"""Terminal app autopilot emulators."""
64+
65+
66+class MainWindow(object):
67+ """An emulator class that makes it easy to interact with the
68+ terminal-app.
69+
70+ """
71+ def __init__(self, app):
72+ self.app = app
73+
74+ def get_qml_view(self):
75+ """Get the main QML view"""
76+ return self.app.select_single("QQuickView")
77+
78+ def get_toolbar(self):
79+ return self.app.select_single("Toolbar")
80
81=== added directory 'tests/autopilot/ubuntu_terminal_app/tests'
82=== added file 'tests/autopilot/ubuntu_terminal_app/tests/__init__.py'
83--- tests/autopilot/ubuntu_terminal_app/tests/__init__.py 1970-01-01 00:00:00 +0000
84+++ tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2013-05-31 13:16:57 +0000
85@@ -0,0 +1,55 @@
86+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
87+# Copyright 2013 Canonical
88+#
89+# This program is free software: you can redistribute it and/or modify it
90+# under the terms of the GNU General Public License version 3, as published
91+# by the Free Software Foundation.
92+
93+"""Terminal app autopilot tests."""
94+
95+import os.path
96+
97+from autopilot.input import Mouse, Touch, Pointer
98+from autopilot.platform import model
99+from autopilot.testcase import AutopilotTestCase
100+
101+from ubuntu_terminal_app.emulators.main_window import MainWindow
102+
103+
104+class TerminalTestCase(AutopilotTestCase):
105+
106+ """A common test case class that provides several useful methods for
107+ terminal-app tests.
108+
109+ """
110+ if model() == 'Desktop':
111+ scenarios = [('with mouse', dict(input_device_class=Mouse))]
112+ else:
113+ scenarios = [('with touch', dict(input_device_class=Touch))]
114+
115+ local_location = "../../ubuntu-terminal-app.qml"
116+
117+ def setUp(self):
118+ self.pointing_device = Pointer(self.input_device_class.create())
119+ super(TerminalTestCase, self).setUp()
120+ if os.path.exists(self.local_location):
121+ self.launch_test_local()
122+ else:
123+ self.launch_test_installed()
124+
125+ def launch_test_local(self):
126+ self.app = self.launch_test_application(
127+ "qmlscene",
128+ self.local_location,
129+ app_type='qt')
130+
131+ def launch_test_installed(self):
132+ self.app = self.launch_test_application(
133+ "qmlscene",
134+ "/usr/share/ubuntu-terminal-app/ubuntu-terminal-app.qml",
135+ "--desktop_file_hint=/usr/share/applications/ubuntu-terminal-app.desktop",
136+ app_type='qt')
137+
138+ @property
139+ def main_window(self):
140+ return MainWindow(self.app)
141
142=== added file 'tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py'
143--- tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 1970-01-01 00:00:00 +0000
144+++ tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2013-05-31 13:16:57 +0000
145@@ -0,0 +1,38 @@
146+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
147+# Copyright 2013 Canonical
148+#
149+# This program is free software: you can redistribute it and/or modify it
150+# under the terms of the GNU General Public License version 3, as published
151+# by the Free Software Foundation.
152+
153+"""Terminal app autopilot tests."""
154+
155+from __future__ import absolute_import
156+
157+from autopilot.matchers import Eventually
158+from testtools.matchers import Equals
159+
160+from ubuntu_terminal_app.tests import TerminalTestCase
161+
162+
163+class TestMainWindow(TerminalTestCase):
164+
165+ def setUp(self):
166+ super(TestMainWindow, self).setUp()
167+ self.assertThat(
168+ self.main_window.get_qml_view().visible, Eventually(Equals(True)))
169+
170+ def tearDown(self):
171+ super(TestMainWindow, self).tearDown()
172+
173+ def test_toolbar_shows(self):
174+ """Make sure that dragging from the bottom reveals the hidden
175+ toolbar."""
176+ toolbar = self.main_window.get_toolbar()
177+
178+ x, y, w, h = toolbar.globalRect
179+ tx = x + (w / 2)
180+ ty = y + (h - 2)
181+
182+ self.pointing_device.drag(tx, ty, tx, ty - h)
183+ self.assertThat(toolbar.state, Eventually(Equals("spread")))

Subscribers

People subscribed via source and target branches