Merge lp:~elopio/reminders-app/test_go_to_accounts into lp:reminders-app

Proposed by Leo Arias
Status: Merged
Approved by: David Planella
Approved revision: 104
Merged at revision: 98
Proposed branch: lp:~elopio/reminders-app/test_go_to_accounts
Merge into: lp:reminders-app
Prerequisite: lp:~elopio/reminders-app/autopilot-start_app
Diff against target: 243 lines (+66/-87)
6 files modified
debian/control (+1/-1)
src/app/qml/reminders.qml (+3/-1)
tests/autopilot/reminders/__init__.py (+47/-0)
tests/autopilot/reminders/emulators.py (+0/-60)
tests/autopilot/reminders/tests/__init__.py (+9/-11)
tests/autopilot/reminders/tests/test_reminders.py (+6/-14)
To merge this branch: bzr merge lp:~elopio/reminders-app/test_go_to_accounts
Reviewer Review Type Date Requested Status
Víctor R. Ruiz code review Needs Fixing
David Planella Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Allan LeSage Pending
Richard Huddie Pending
Julia Palandri Pending
Dan Chapman  Pending
Review via email: mp+214161@code.launchpad.net

Commit message

Added an initial autopilot test.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
David Planella (dpm) wrote :

This seems to fail with:

http://pastebin.ubuntu.com/7203598/

Revision history for this message
David Planella (dpm) wrote :

That was a mistake on my side. The branch assumes no account being set up and I had an active Evernote account.

I'll approve, but still, it'd be good if we could fail more gracefully

review: Approve
Revision history for this message
Leo Arias (elopio) wrote :
Revision history for this message
David Planella (dpm) wrote :

Excellent! I'll review some time this weekend
El dia 04/04/2014 19.51, "Leo Arias" <email address hidden> va escriure:

> Something like this David?
> https://code.launchpad.net/~elopio/reminders-app/test_go_to_accounts-fail_gracefully/+merge/214319
> --
>
> https://code.launchpad.net/~elopio/reminders-app/test_go_to_accounts/+merge/214161
> You are reviewing the proposed merge of
> lp:~elopio/reminders-app/test_go_to_accounts into lp:reminders-app.
>

Revision history for this message
Víctor R. Ruiz (vrruiz) wrote :

Leo: The application launch methods should be moved to the app class in reminders/__init__.py. There the app proxy object should be stored as self.app.

review: Needs Fixing (code review)
Revision history for this message
Leo Arias (elopio) wrote :

Victor, I tried that but in the end I liked how the launch methods work like a fixture, adding a clean up to close the application when the test is done. So to keep that, I had to pass the test case as a parameter to the __init__ of RemindersApp which didn't look quite right. Lets talk on monday, I'll try to prepare a branch to try that approach to see if it's just what you mean, and discuss with the team what looks better. Thanks for the review.

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 2014-02-26 10:33:02 +0000
3+++ debian/control 2014-04-04 06:15:56 +0000
4@@ -3,7 +3,7 @@
5 Maintainer: Ubuntu App Cats <ubuntu-touch-coreapps@lists.launchpad.net>
6 Build-Depends: cmake,
7 debhelper (>= 9),
8- gettext,
9+ gettext,
10 libboost-dev,
11 libssl-dev,
12 python,
13
14=== modified file 'src/app/qml/reminders.qml'
15--- src/app/qml/reminders.qml 2014-03-13 18:12:25 +0000
16+++ src/app/qml/reminders.qml 2014-04-04 06:15:56 +0000
17@@ -283,12 +283,14 @@
18 id: noAccountDialog
19 Dialog {
20 id: noAccount
21+ objectName: "noAccountDialog"
22 title: i18n.tr("No account available")
23 text: i18n.tr("Please setup an account in the system settings")
24 Button {
25+ objectName: "openAccountButton"
26 text: i18n.tr("Open account settings")
27 color: UbuntuColors.orange
28- onClicked: Qt.openUrlExternally("settings:///system/online-accounts")
29+ onClicked: Qt.openUrlExternally("settings:///system/online-accounts")
30 }
31 }
32 }
33
34=== modified file 'tests/autopilot/reminders/__init__.py'
35--- tests/autopilot/reminders/__init__.py 2014-04-04 06:15:56 +0000
36+++ tests/autopilot/reminders/__init__.py 2014-04-04 06:15:56 +0000
37@@ -17,3 +17,50 @@
38 # along with this program. If not, see <http://www.gnu.org/licenses/>.
39
40 """Reminders app tests and emulators - top level package."""
41+
42+import logging
43+
44+from autopilot import logging as autopilot_logging
45+from autopilot.introspection import dbus
46+from ubuntuuitoolkit import emulators as toolkit_emulators
47+
48+
49+logger = logging.getLogger(__name__)
50+
51+
52+class RemindersApp(object):
53+ """Autopilot helper object for the Reminders application."""
54+
55+ def __init__(self, app_proxy):
56+ self.app = app_proxy
57+ self.main_view = self.app.select_single(MainView)
58+
59+
60+class MainView(toolkit_emulators.MainView):
61+ """Autopilot custom proxy object for the MainView."""
62+
63+ def __init__(self, *args):
64+ super(MainView, self).__init__(*args)
65+ self.visible.wait_for(True)
66+ try:
67+ self.no_account_dialog = self.select_single(
68+ objectName='noAccountDialog')
69+ except dbus.StateNotFoundError:
70+ # Just don't add the dialog as an attribute.
71+ pass
72+
73+
74+class NoAccountDialog(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
75+
76+ @classmethod
77+ def validate_dbus_object(cls, path, state):
78+ name = dbus.get_classname_from_path(path)
79+ if name == 'Dialog':
80+ if 'noAccountDialog' == state['objectName'][1]:
81+ return True
82+ return False
83+
84+ @autopilot_logging.log_action(logger.info)
85+ def open_account_settings(self):
86+ button = self.select_single('Button', objectName='openAccountButton')
87+ self.pointing_device.click_object(button)
88
89=== removed file 'tests/autopilot/reminders/emulators.py'
90--- tests/autopilot/reminders/emulators.py 2014-04-04 06:15:56 +0000
91+++ tests/autopilot/reminders/emulators.py 1970-01-01 00:00:00 +0000
92@@ -1,60 +0,0 @@
93-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
94-#
95-# Copyright (C) 2013, 2014 Canonical Ltd.
96-#
97-# This file is part of reminders
98-#
99-# reminders is free software: you can redistribute it and/or modify
100-# it under the terms of the GNU General Public License as published by
101-# the Free Software Foundation; version 3.
102-#
103-# reminders is distributed in the hope that it will be useful,
104-# but WITHOUT ANY WARRANTY; without even the implied warranty of
105-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
106-# GNU General Public License for more details.
107-#
108-# You should have received a copy of the GNU General Public License
109-# along with this program. If not, see <http://www.gnu.org/licenses/>.
110-
111-import logging
112-
113-from autopilot import logging as autopilot_logging
114-from ubuntuuitoolkit import emulators as toolkit_emulators
115-from time import sleep
116-
117-logger = logging.getLogger(__name__)
118-
119-
120-class MainView(toolkit_emulators.MainView):
121-
122- retry_delay = 0.2
123-
124- def select_many_retry(self, object_type, **kwargs):
125- """Returns the item that is searched for with app.select_many
126- In case of no item was not found (not created yet) a second attempt is
127- taken 1 second later"""
128- items = self.select_many(object_type, **kwargs)
129- tries = 10
130- while len(items) < 1 and tries > 0:
131- sleep(self.retry_delay)
132- items = self.select_many(object_type, **kwargs)
133- tries = tries - 1
134- return items
135-
136- #@autopilot_logging.log_action(logger.info)
137- #def get_evernote_account(self):
138- #"""Get Evernote account """
139- #return self.wait_select_single(
140- #"Standard", objectName="EvernoteAccount")
141-
142- #@autopilot_logging.log_action(logger.info)
143- #def get_accountselectorpage(self):
144- #"""Get Account selector page """
145- #return self.wait_select_single(
146- #"Page", objectName="Accountselectorpage")
147-
148- @autopilot_logging.log_action(logger.info)
149- def get_notespageListview(self):
150- """Get notes page list view """
151- return self.wait_select_single(
152- 'QQuickListView', objectName='notespageListview')
153
154=== modified file 'tests/autopilot/reminders/tests/__init__.py'
155--- tests/autopilot/reminders/tests/__init__.py 2014-04-04 06:15:56 +0000
156+++ tests/autopilot/reminders/tests/__init__.py 2014-04-04 06:15:56 +0000
157@@ -27,7 +27,7 @@
158 from autopilot.testcase import AutopilotTestCase
159 from ubuntuuitoolkit import emulators as toolkit_emulators
160
161-from reminders import emulators
162+import reminders
163
164 logger = logging.getLogger(__name__)
165
166@@ -50,24 +50,26 @@
167 super(RemindersAppTestCase, self).setUp()
168
169 if os.path.exists(self.local_location_binary):
170- self.launch_test_local()
171+ app_proxy = self.launch_test_local()
172 elif os.path.exists(self.installed_location_binary):
173- self.launch_test_installed()
174+ app_proxy = self.launch_test_installed()
175 else:
176- self.launch_test_click()
177+ app_proxy = self.launch_test_click()
178+
179+ self.app = reminders.RemindersApp(app_proxy)
180
181 @autopilot_logging.log_action(logger.info)
182 def launch_test_local(self):
183 self.useFixture(fixtures.EnvironmentVariable(
184 'QML2_IMPORT_PATH', newvalue='../../src/plugin'))
185- self.app = self.launch_test_application(
186+ return self.launch_test_application(
187 self.local_location_binary,
188 app_type='qt',
189 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
190
191 @autopilot_logging.log_action(logger.info)
192 def launch_test_installed(self):
193- self.app = self.launch_test_application(
194+ return self.launch_test_application(
195 self.installed_location_binary,
196 '-q ' + self.installed_location_qml,
197 '--desktop_file_hint=/usr/share/applications/'
198@@ -77,10 +79,6 @@
199
200 @autopilot_logging.log_action(logger.info)
201 def launch_test_click(self):
202- self.app = self.launch_click_package(
203+ return self.launch_click_package(
204 'com.ubuntu.reminders-app',
205 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
206-
207- @property
208- def main_view(self):
209- return self.app.select_single(emulators.MainView)
210
211=== modified file 'tests/autopilot/reminders/tests/test_reminders.py'
212--- tests/autopilot/reminders/tests/test_reminders.py 2014-04-04 06:15:56 +0000
213+++ tests/autopilot/reminders/tests/test_reminders.py 2014-04-04 06:15:56 +0000
214@@ -18,23 +18,15 @@
215
216 from __future__ import absolute_import
217
218-from autopilot.matchers import Eventually
219-from testtools.matchers import Equals
220-
221-from reminders.tests import RemindersAppTestCase
222+from reminders import tests
223
224 import logging
225
226 logger = logging.getLogger(__name__)
227
228
229-class TestMainWindow(RemindersAppTestCase):
230-
231- def setUp(self):
232- super(TestMainWindow, self).setUp()
233-
234- self.assertThat(self.main_view.visible, Eventually(Equals(True)))
235-
236- def test_blank(setup):
237- #jenkins requires at least one test
238- return 0
239+class RemindersTestCaseWithoutAccount(tests.RemindersAppTestCase):
240+
241+ def test_open_application_without_account(self):
242+ """Test that the No account dialog is visible."""
243+ self.assertTrue(self.app.main_view.no_account_dialog.visible)

Subscribers

People subscribed via source and target branches