Merge lp:~elopio/reminders-app/autopilot-add_notebook into lp:reminders-app
- autopilot-add_notebook
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Nicholas Skaggs |
Approved revision: | 144 |
Merged at revision: | 151 |
Proposed branch: | lp:~elopio/reminders-app/autopilot-add_notebook |
Merge into: | lp:reminders-app |
Diff against target: |
353 lines (+152/-26) 6 files modified
src/app/qml/components/NotebooksDelegate.qml (+4/-0) src/app/qml/ui/NotebooksPage.qml (+5/-0) tests/autopilot/reminders/__init__.py (+100/-0) tests/autopilot/reminders/credentials.py (+1/-1) tests/autopilot/reminders/tests/__init__.py (+17/-14) tests/autopilot/reminders/tests/test_reminders.py (+25/-11) |
To merge this branch: | bzr merge lp:~elopio/reminders-app/autopilot-add_notebook |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Carla Sella (community) | Approve | ||
David Planella | Pending | ||
Julia Palandri | Pending | ||
VĂctor R. Ruiz | Pending | ||
Allan LeSage | Pending | ||
Richard Huddie | Pending | ||
Nicholas Skaggs | Pending | ||
Ubuntu Notes app developers | Pending | ||
Review via email: mp+219237@code.launchpad.net |
Commit message
Added an autopiolot test to add a notebook.
Description of the change
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
Carla Sella (carla-sella) : | # |
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:138
http://
Executed test runs:
UNSTABLE: http://
deb: http://
UNSTABLE: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:139
http://
Executed test runs:
UNSTABLE: http://
deb: http://
UNSTABLE: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:140
http://
Executed test runs:
UNSTABLE: http://
deb: http://
UNSTABLE: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:141
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:142
http://
Executed test runs:
UNSTABLE: http://
deb: http://
UNSTABLE: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:142
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:143
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:144
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'src/app/qml/components/NotebooksDelegate.qml' |
2 | --- src/app/qml/components/NotebooksDelegate.qml 2014-05-07 19:11:05 +0000 |
3 | +++ src/app/qml/components/NotebooksDelegate.qml 2014-05-23 07:11:33 +0000 |
4 | @@ -58,16 +58,19 @@ |
5 | Layout.fillWidth: true |
6 | |
7 | Label { |
8 | + objectName: 'notebookTitleLabel' |
9 | text: model.name |
10 | color: root.notebookColor |
11 | fontSize: "large" |
12 | } |
13 | Label { |
14 | + objectName: 'notebookLastUpdatedLabel' |
15 | text: i18n.tr("Last edited %1").arg(model.lastUpdatedString) |
16 | fontSize: "small" |
17 | color: "black" |
18 | } |
19 | Label { |
20 | + objectName: 'notebookPublishedLabel' |
21 | Layout.fillHeight: true |
22 | text: model.published ? i18n.tr("Shared") : i18n.tr("Private") |
23 | color: model.published ? "black" : "#b3b3b3" |
24 | @@ -78,6 +81,7 @@ |
25 | } |
26 | |
27 | Label { |
28 | + objectName: 'notebookNoteCountLabel' |
29 | Layout.fillHeight: true |
30 | verticalAlignment: Text.AlignVCenter |
31 | text: "(" + model.noteCount + ")" |
32 | |
33 | === modified file 'src/app/qml/ui/NotebooksPage.qml' |
34 | --- src/app/qml/ui/NotebooksPage.qml 2014-05-14 10:31:49 +0000 |
35 | +++ src/app/qml/ui/NotebooksPage.qml 2014-05-23 07:11:33 +0000 |
36 | @@ -24,6 +24,7 @@ |
37 | |
38 | Page { |
39 | id: root |
40 | + objectName: 'notebooksPage' |
41 | |
42 | signal openNotebook(string title, string notebookGuid) |
43 | |
44 | @@ -62,6 +63,7 @@ |
45 | } |
46 | |
47 | ToolbarButton { |
48 | + objectName: "addNotebookButton" |
49 | text: i18n.tr("Add notebook") |
50 | iconName: "add" |
51 | onTriggered: { |
52 | @@ -108,12 +110,14 @@ |
53 | |
54 | TextField { |
55 | id: newNoteTitleTextField |
56 | + objectName: "newNoteTitleTextField" |
57 | anchors { left: parent.left; right: parent.right; margins: units.gu(2); verticalCenter: parent.verticalCenter } |
58 | } |
59 | } |
60 | |
61 | PulldownListView { |
62 | id: notebooksListView |
63 | + objectName: "notebooksListView" |
64 | model: notebooks |
65 | anchors { left: parent.left; right: parent.right } |
66 | height: parent.height - y - buttonRow.height - keyboardRect.height |
67 | @@ -168,6 +172,7 @@ |
68 | } |
69 | } |
70 | Button { |
71 | + objectName: "saveButton" |
72 | anchors { right: parent.right; verticalCenter: parent.verticalCenter } |
73 | text: i18n.tr("Save") |
74 | enabled: newNoteTitleTextField.text.length > 0 |
75 | |
76 | === modified file 'tests/autopilot/reminders/__init__.py' |
77 | --- tests/autopilot/reminders/__init__.py 2014-05-16 06:52:10 +0000 |
78 | +++ tests/autopilot/reminders/__init__.py 2014-05-23 07:11:33 +0000 |
79 | @@ -21,6 +21,8 @@ |
80 | import logging |
81 | from distutils import version |
82 | |
83 | +import ubuntuuitoolkit |
84 | + |
85 | import autopilot |
86 | from autopilot import logging as autopilot_logging |
87 | from autopilot.introspection import dbus |
88 | @@ -41,6 +43,16 @@ |
89 | self.app = app_proxy |
90 | self.main_view = self.app.select_single(MainView) |
91 | |
92 | + def open_notebooks(self): |
93 | + """Open the Notebooks page. |
94 | + |
95 | + :return: The autopilot custom proxy object for the NotebooksPage. |
96 | + |
97 | + """ |
98 | + self.main_view.switch_to_tab('NotebookTab') |
99 | + return self.main_view.select_single( |
100 | + NotebooksPage, objectName='notebooksPage') |
101 | + |
102 | |
103 | class MainView(toolkit_emulators.MainView): |
104 | """Autopilot custom proxy object for the MainView.""" |
105 | @@ -64,6 +76,7 @@ |
106 | |
107 | |
108 | class NoAccountDialog(toolkit_emulators.UbuntuUIToolkitEmulatorBase): |
109 | + """Autopilot custom proxy object for the no account dialog.""" |
110 | |
111 | @classmethod |
112 | def validate_dbus_object(cls, path, state): |
113 | @@ -85,3 +98,90 @@ |
114 | def open_account_settings(self): |
115 | button = self.select_single('Button', objectName='openAccountButton') |
116 | self.pointing_device.click_object(button) |
117 | + |
118 | + |
119 | +class _Page(toolkit_emulators.UbuntuUIToolkitEmulatorBase): |
120 | + |
121 | + def __init__(self, *args): |
122 | + super(_Page, self).__init__(*args) |
123 | + # XXX we need a better way to keep reference to the main view. |
124 | + # --elopio - 2014-02-26 |
125 | + self.main_view = self.get_root_instance().select_single(MainView) |
126 | + |
127 | + |
128 | +class PulldownListView(ubuntuuitoolkit.QQuickListView): |
129 | + """Autopilot custom proxy object for the PulldownListView.""" |
130 | + |
131 | + |
132 | +class NotebooksPage(_Page): |
133 | + """Autopilot custom proxy object for the Notebooks page.""" |
134 | + |
135 | + def add_notebook(self, title): |
136 | + """Add a notebook. |
137 | + |
138 | + :param title: The title of the Notebook that will be added. |
139 | + |
140 | + """ |
141 | + original_number_of_books = self._get_notebooks_listview().count |
142 | + self.main_view.open_toolbar().click_button('addNotebookButton') |
143 | + title_textfield = self.select_single( |
144 | + ubuntuuitoolkit.TextField, objectName='newNoteTitleTextField') |
145 | + title_textfield.write(title) |
146 | + self._click_save() |
147 | + self._get_notebooks_listview().count.wait_for( |
148 | + original_number_of_books + 1) |
149 | + |
150 | + def _get_notebooks_listview(self): |
151 | + return self.select_single( |
152 | + PulldownListView, objectName='notebooksListView') |
153 | + |
154 | + def _click_save(self): |
155 | + save_button = self.select_single('Button', objectName='saveButton') |
156 | + self.pointing_device.click_object(save_button) |
157 | + |
158 | + def get_notebooks(self): |
159 | + """Return the list of Notebooks. |
160 | + |
161 | + :return: A list with the the Notebooks. Every item of the list is a |
162 | + tuple with title, last updated value, published status and number |
163 | + of notes. The list is sorted in the same order as it is displayed |
164 | + on the application. |
165 | + |
166 | + """ |
167 | + listview = self._get_notebooks_listview() |
168 | + notebook_delegates = listview.select_many(NotebooksDelegate) |
169 | + # Sort by the position on the list. |
170 | + sorted_notebook_delegates = sorted( |
171 | + notebook_delegates, |
172 | + key=lambda delegate: delegate.globalRect.y) |
173 | + notebooks = [ |
174 | + (notebook.get_title(), notebook.get_last_updated(), |
175 | + notebook.get_published_status(), notebook.get_notes_count()) |
176 | + for notebook in sorted_notebook_delegates |
177 | + ] |
178 | + return notebooks |
179 | + |
180 | + |
181 | +class NotebooksDelegate(toolkit_emulators.UbuntuUIToolkitEmulatorBase): |
182 | + """Autopilot custom proxy object for the NotebooksDelegate.""" |
183 | + |
184 | + def get_title(self): |
185 | + """Return the title of the Notebook.""" |
186 | + return self._get_label_text('notebookTitleLabel') |
187 | + |
188 | + def _get_label_text(self, object_name): |
189 | + label = self.select_single('Label', objectName=object_name) |
190 | + return label.text |
191 | + |
192 | + def get_last_updated(self): |
193 | + """Return the last updated value of the Notebook.""" |
194 | + return self._get_label_text('notebookLastUpdatedLabel') |
195 | + |
196 | + def get_published_status(self): |
197 | + """Return the published status of the Notebook.""" |
198 | + return self._get_label_text('notebookPublishedLabel') |
199 | + |
200 | + def get_notes_count(self): |
201 | + """Return the number of notes in the Notebook.""" |
202 | + # The count is returned in paretheses, so we strip them. |
203 | + return int(self._get_label_text('notebookNoteCountLabel').strip('()')) |
204 | |
205 | === modified file 'tests/autopilot/reminders/credentials.py' |
206 | --- tests/autopilot/reminders/credentials.py 2014-05-08 18:10:01 +0000 |
207 | +++ tests/autopilot/reminders/credentials.py 2014-05-23 07:11:33 +0000 |
208 | @@ -28,7 +28,7 @@ |
209 | """Manager for online accounts.""" |
210 | |
211 | def __init__(self): |
212 | - self._manager = Accounts.Manager() |
213 | + self._manager = Accounts.Manager.new() |
214 | |
215 | def _start_main_loop(self): |
216 | self.error = None |
217 | |
218 | === modified file 'tests/autopilot/reminders/tests/__init__.py' |
219 | --- tests/autopilot/reminders/tests/__init__.py 2014-05-22 09:55:36 +0000 |
220 | +++ tests/autopilot/reminders/tests/__init__.py 2014-05-23 07:11:33 +0000 |
221 | @@ -45,14 +45,13 @@ |
222 | scenarios = [('with touch', dict(input_device_class=Touch))] |
223 | |
224 | local_location = os.path.dirname(os.path.dirname(os.getcwd())) |
225 | - local_location_qml = os.path.join(local_location, |
226 | - 'src/app/qml/reminders.qml') |
227 | + |
228 | + local_location_qml = os.path.join( |
229 | + local_location, 'src/app/qml/reminders.qml') |
230 | local_location_binary = os.path.join(local_location, 'src/app/reminders') |
231 | installed_location_binary = '/usr/bin/reminders' |
232 | installed_location_qml = '/usr/share/reminders/qml/reminders.qml' |
233 | |
234 | - home_dir = None |
235 | - |
236 | def get_launcher_and_type(self): |
237 | if os.path.exists(self.local_location_binary): |
238 | launcher = self.launch_test_local |
239 | @@ -67,8 +66,7 @@ |
240 | |
241 | def setUp(self): |
242 | launcher, test_type = self.get_launcher_and_type() |
243 | - if self.home_dir is None: |
244 | - self.home_dir = self._patch_home(test_type) |
245 | + self.home_dir = self._patch_home(test_type) |
246 | self.pointing_device = Pointer(self.input_device_class.create()) |
247 | super(RemindersAppTestCase, self).setUp() |
248 | |
249 | @@ -90,6 +88,7 @@ |
250 | temp_dir_fixture = fixtures.TempDir() |
251 | self.useFixture(temp_dir_fixture) |
252 | temp_dir = temp_dir_fixture.path |
253 | + temp_xdg_config_home = os.path.join(temp_dir, '.config') |
254 | |
255 | #If running under xvfb, as jenkins does, |
256 | #xsession will fail to start without xauthority file |
257 | @@ -100,21 +99,25 @@ |
258 | #click requires using initctl env (upstart), but the desktop can set |
259 | #an environment variable instead |
260 | if test_type == 'click': |
261 | - self.useFixture(toolkit_fixtures.InitctlEnvironmentVariable( |
262 | - HOME=temp_dir)) |
263 | + self.useFixture( |
264 | + toolkit_fixtures.InitctlEnvironmentVariable( |
265 | + HOME=temp_dir, XDG_CONFIG_HOME=temp_xdg_config_home)) |
266 | else: |
267 | - self.useFixture(fixtures.EnvironmentVariable('HOME', |
268 | - newvalue=temp_dir)) |
269 | + self.useFixture( |
270 | + fixtures.EnvironmentVariable('HOME', newvalue=temp_dir)) |
271 | + self.useFixture( |
272 | + fixtures.EnvironmentVariable( |
273 | + 'XDG_CONFIG_HOME', newvalue=temp_xdg_config_home)) |
274 | |
275 | - logger.debug("Patched home to fake home directory " + temp_dir) |
276 | + logger.debug('Patched home to fake home directory ' + temp_dir) |
277 | |
278 | return temp_dir |
279 | |
280 | @autopilot_logging.log_action(logger.info) |
281 | def launch_test_local(self): |
282 | - self.useFixture(fixtures.EnvironmentVariable('QML2_IMPORT_PATH', |
283 | - newvalue=os.path.join(self.local_location, |
284 | - 'src/plugin'))) |
285 | + self.useFixture(fixtures.EnvironmentVariable( |
286 | + 'QML2_IMPORT_PATH', |
287 | + newvalue=os.path.join(self.local_location, 'src/plugin'))) |
288 | return self.launch_test_application( |
289 | self.local_location_binary, |
290 | '-q', self.local_location_qml, |
291 | |
292 | === modified file 'tests/autopilot/reminders/tests/test_reminders.py' |
293 | --- tests/autopilot/reminders/tests/test_reminders.py 2014-05-08 23:52:39 +0000 |
294 | +++ tests/autopilot/reminders/tests/test_reminders.py 2014-05-23 07:11:33 +0000 |
295 | @@ -19,11 +19,11 @@ |
296 | from __future__ import absolute_import |
297 | |
298 | import logging |
299 | +import uuid |
300 | |
301 | from autopilot import platform |
302 | from autopilot.matchers import Eventually |
303 | from testtools.matchers import Equals |
304 | -from testtools import ExpectedException |
305 | |
306 | import reminders |
307 | from reminders import credentials, fixture_setup, tests |
308 | @@ -62,12 +62,10 @@ |
309 | class RemindersTestCaseWithAccount(tests.RemindersAppTestCase): |
310 | |
311 | def setUp(self): |
312 | - # We need to change the home dir before adding the account, otherwise |
313 | - # the account will not be found when the app is opened. |
314 | - _, test_type = self.get_launcher_and_type() |
315 | - self.home_dir = self._patch_home(test_type) |
316 | + super(RemindersTestCaseWithAccount, self).setUp() |
317 | + no_account_dialog = self.app.main_view.no_account_dialog |
318 | self.add_evernote_account() |
319 | - super(RemindersTestCaseWithAccount, self).setUp() |
320 | + no_account_dialog.wait_until_destroyed() |
321 | |
322 | def add_evernote_account(self): |
323 | account_manager = credentials.AccountManager() |
324 | @@ -77,8 +75,24 @@ |
325 | account = account_manager.add_evernote_account( |
326 | 'dummy', 'dummy', oauth_token) |
327 | self.addCleanup(account_manager.delete_account, account) |
328 | - |
329 | - def test_open_application_with_account(self): |
330 | - """Test that the No account dialog is not visible.""" |
331 | - with ExpectedException(reminders.RemindersAppException): |
332 | - self.app.main_view.no_account_dialog |
333 | + del account_manager._manager |
334 | + del account_manager |
335 | + |
336 | + def test_add_notebook_must_append_it_to_list(self): |
337 | + test_notebook_title = 'Test notebook {}'.format(uuid.uuid1()) |
338 | + |
339 | + notebooks_page = self.app.open_notebooks() |
340 | + # FIXME delete the added notebook. Otherwise, the test account will |
341 | + # fill up. See http://pad.lv/1318749 --elopio - 2014-05-12 |
342 | + notebooks_page.add_notebook(test_notebook_title) |
343 | + |
344 | + last_notebook = notebooks_page.get_notebooks()[-1] |
345 | + # TODO there's a bug with the last updated value: http://pad.lv/1318751 |
346 | + # so we can't check the full tuple. Uncomment this as soon as the bug |
347 | + # is fixed. --elopio - 2014-05-12 |
348 | + #self.assertEqual( |
349 | + # last_notebook, |
350 | + # (test_notebook_title, 'Last edited today', 'Private', 0)) |
351 | + self.assertEqual(last_notebook[0], test_notebook_title) |
352 | + self.assertEqual(last_notebook[2], 'Private') |
353 | + self.assertEqual(last_notebook[3], 0) |
FAILED: Continuous integration, rev:137 91.189. 93.70:8080/ job/reminders- app-ci/ 344/ 91.189. 93.70:8080/ job/generic- mediumtests- trusty/ 2612 91.189. 93.70:8080/ job/generic- mediumtests- trusty/ 2612/artifact/ work/output/ *zip*/output. zip 91.189. 93.70:8080/ job/generic- mediumtests- utopic/ 151 91.189. 93.70:8080/ job/generic- mediumtests- utopic/ 151/artifact/ work/output/ *zip*/output. zip 91.189. 93.70:8080/ job/reminders- app-trusty- amd64-ci/ 345 91.189. 93.70:8080/ job/reminders- app-utopic- amd64-ci/ 39
http://
Executed test runs:
UNSTABLE: http://
deb: http://
UNSTABLE: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/reminders- app-ci/ 344/rebuild
http://