Merge lp:~canonical-platform-qa/address-book-app/main_window_objectName into lp:address-book-app

Proposed by Leo Arias on 2015-02-19
Status: Merged
Approved by: Renato Araujo Oliveira Filho on 2015-02-20
Approved revision: 378
Merged at revision: 379
Proposed branch: lp:~canonical-platform-qa/address-book-app/main_window_objectName
Merge into: lp:address-book-app
Diff against target: 210 lines (+58/-34)
3 files modified
src/imports/MainWindow.qml (+2/-1)
tests/autopilot/address_book_app/__init__.py (+29/-14)
tests/autopilot/address_book_app/tests/__init__.py (+27/-19)
To merge this branch: bzr merge lp:~canonical-platform-qa/address-book-app/main_window_objectName
Reviewer Review Type Date Requested Status
Renato Araujo Oliveira Filho (community) 2015-02-19 Approve on 2015-02-19
PS Jenkins bot continuous-integration Approve on 2015-02-19
Review via email: mp+250259@code.launchpad.net

Commit Message

On autopilot tests, select the main window by object name.
Added a custom proxy object for the application.

Description of the Change

In order to test the address book's interactions with other applications, we need to set a unique object name to its MainWindow.

To post a comment you must log in.
378. By Leo Arias on 2015-02-19

Fixed the copyright headers.

looks good. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/imports/MainWindow.qml'
2--- src/imports/MainWindow.qml 2014-11-11 14:31:23 +0000
3+++ src/imports/MainWindow.qml 2015-02-19 07:06:21 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright (C) 2012-2013 Canonical, Ltd.
7+ * Copyright (C) 2012-2015 Canonical, Ltd.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11@@ -21,6 +21,7 @@
12
13 MainView {
14 id: mainWindow
15+ objectName: "addressBookAppMainWindow"
16
17 property string modelErrorMessage: ""
18 readonly property bool appActive: Qt.application.active
19
20=== modified file 'tests/autopilot/address_book_app/__init__.py'
21--- tests/autopilot/address_book_app/__init__.py 2014-09-02 19:23:05 +0000
22+++ tests/autopilot/address_book_app/__init__.py 2015-02-19 07:06:21 +0000
23@@ -1,6 +1,6 @@
24 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
25 #
26-# Copyright (C) 2014 Canonical Ltd.
27+# Copyright (C) 2014, 2015 Canonical Ltd.
28 #
29 # This program is free software; you can redistribute it and/or modify
30 # it under the terms of the GNU General Public License version 3, as published
31@@ -24,7 +24,10 @@
32
33 import autopilot.logging
34 import ubuntuuitoolkit
35-from autopilot.introspection import dbus
36+from autopilot import (
37+ exceptions,
38+ introspection
39+)
40
41 from address_book_app import pages
42
43@@ -32,17 +35,31 @@
44 logger = logging.getLogger(__name__)
45
46
47-class AddressBookApp(object):
48-
49- def __init__(self, app_proxy):
50- super(AddressBookApp, self).__init__()
51- self.app_proxy = app_proxy
52- self.main_window = self.app_proxy.select_single(MainWindow)
53-
54-
55-class MainWindow(ubuntuuitoolkit.MainView):
56+class AddressBookApp(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
57+
58+ """Autopilot custom proxy object for the address book app."""
59+
60+ @classmethod
61+ def validate_dbus_object(cls, path, state):
62+ name = introspection.get_classname_from_path(path)
63+ return (name == b'webbrowser-app' and
64+ state['applicationName'][1] == 'webbrowser-app')
65+
66+ @property
67+ def main_window(self):
68+ return self.select_single(objectName='addressBookAppMainWindow')
69+
70+
71+class AddressBookAppMainWindow(ubuntuuitoolkit.MainView):
72+
73 """An emulator class that makes it easy to interact with the app."""
74
75+ @classmethod
76+ def validate_dbus_object(cls, path, state):
77+ name = introspection.get_classname_from_path(path)
78+ return (name == b'MainWindow' and
79+ state['objectName'][1] == 'addressBookAppMainWindow')
80+
81 def get_contact_list_page(self):
82 # ContactListPage is the only page that can appears multiple times
83 # Ex.: During the pick mode we alway push a new contactListPage, to
84@@ -66,9 +83,7 @@
85 for p in contact_editor_pages:
86 if p.active:
87 return p
88- raise dbus.StateNotFoundError('contactEditorPage not found')
89- return None
90-
91+ raise exceptions.StateNotFoundError('contactEditorPage not found')
92
93 def get_contact_view_page(self):
94 return self.wait_select_single("ContactView",
95
96=== modified file 'tests/autopilot/address_book_app/tests/__init__.py'
97--- tests/autopilot/address_book_app/tests/__init__.py 2014-09-02 19:23:05 +0000
98+++ tests/autopilot/address_book_app/tests/__init__.py 2015-02-19 07:06:21 +0000
99@@ -1,9 +1,18 @@
100 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
101-# Copyright 2013 Canonical
102-#
103-# This program is free software: you can redistribute it and/or modify it
104-# under the terms of the GNU General Public License version 3, as published
105+#
106+# Copyright (C) 2013, 2014, 2015 Canonical Ltd.
107+#
108+# This program is free software; you can redistribute it and/or modify
109+# it under the terms of the GNU General Public License version 3, as published
110 # by the Free Software Foundation.
111+#
112+# This program is distributed in the hope that it will be useful,
113+# but WITHOUT ANY WARRANTY; without even the implied warranty of
114+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
115+# GNU General Public License for more details.
116+#
117+# You should have received a copy of the GNU General Public License
118+# along with this program. If not, see <http://www.gnu.org/licenses/>.
119
120 """address-book-app autopilot tests."""
121
122@@ -17,7 +26,6 @@
123 from testtools.matchers import Equals
124
125 import address_book_app
126-from address_book_app import MainWindow
127 from ubuntuuitoolkit import emulators as toolkit_emulators
128
129
130@@ -62,22 +70,21 @@
131
132 os.environ["ADDRESS_BOOK_TEST_DATA"] = vcard_data
133 os.environ["LANG"] = "en_US.UTF-8"
134- os.environ["LANGUAGE"] ="en_US"
135+ os.environ["LANGUAGE"] = "en_US"
136 if vcard_data != "":
137 print("Using vcard %s" % vcard_data)
138 if os.path.exists(self.app_bin):
139 print("Running from: %s" % (self.app_bin))
140- self.launch_test_local()
141+ self.app = self.launch_test_local()
142 elif os.path.exists(self.DEB_LOCALTION):
143 print("Running from: %s" % (self.DEB_LOCALTION))
144- self.launch_test_installed()
145+ self.app = self.launch_test_installed()
146 else:
147 print("Running from click package: address-book-app")
148- self.launch_click_installed()
149+ self.app = self.launch_click_installed()
150
151 AddressBookAppTestCase.ARGS = []
152 self.main_window.visible.wait_for(True)
153- self.app = address_book_app.AddressBookApp(self.app_proxy)
154
155 def tearDown(self):
156 super(AddressBookAppTestCase, self).tearDown()
157@@ -87,28 +94,29 @@
158 subprocess.check_call(["/sbin/initctl", "start", "maliit-server"])
159
160 def launch_test_local(self):
161- self.app_proxy = self.launch_test_application(
162+ return self.launch_test_application(
163 self.app_bin,
164 *AddressBookAppTestCase.ARGS,
165 app_type='qt',
166- emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
167+ emulator_base=address_book_app.AddressBookApp)
168
169 def launch_test_installed(self):
170 df = "/usr/share/applications/address-book-app.desktop"
171 self.ARGS.append("--desktop_file_hint=" + df)
172- self.app_proxy = self.launch_test_application(
173+ return self.launch_test_application(
174 "address-book-app",
175 *AddressBookAppTestCase.ARGS,
176 app_type='qt',
177- emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
178+ emulator_base=address_book_app.AddressBookApp)
179
180 def launch_click_installed(self):
181- self.app_proxy = self.launch_click_package(
182- "com.ubuntu.address-book")
183+ return self.launch_click_package(
184+ 'com.ubuntu.address-book',
185+ emulator_base=address_book_app.AddressBookApp)
186
187 @property
188 def main_window(self):
189- return self.app_proxy.select_single(MainWindow)
190+ return self.app.main_window
191
192 def select_a_value(self, field, value_selector, value):
193 # Make sure the field has focus
194@@ -239,14 +247,14 @@
195 self.type_on_field(last_name_field, last_name)
196
197 if phone_numbers:
198- phoneGroup = self.main_window.select_single(
199+ self.main_window.select_single(
200 "ContactDetailGroupWithTypeEditor",
201 objectName="phones")
202 for idx, number in enumerate(phone_numbers):
203 self.set_phone_number(idx, number)
204
205 if email_address:
206- emailGroup = self.main_window.select_single(
207+ self.main_window.select_single(
208 "ContactDetailGroupWithTypeEditor",
209 objectName="emails")
210 for idx, address in enumerate(email_address):

Subscribers

People subscribed via source and target branches