Merge lp:~elopio/reminders-app/autopilot-add_notebook into lp:reminders-app

Proposed by Leo Arias
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
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.

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
Carla Sella (carla-sella) :
review: Approve
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: Needs Fixing (continuous-integration)
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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
142. By Leo Arias

Merged with trunk.

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: Needs Fixing (continuous-integration)
143. By Leo Arias

Kick jenkins one more time.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
144. By Leo Arias

Merged with trunk.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/app/qml/components/NotebooksDelegate.qml'
--- src/app/qml/components/NotebooksDelegate.qml 2014-05-07 19:11:05 +0000
+++ src/app/qml/components/NotebooksDelegate.qml 2014-05-23 07:11:33 +0000
@@ -58,16 +58,19 @@
58 Layout.fillWidth: true58 Layout.fillWidth: true
5959
60 Label {60 Label {
61 objectName: 'notebookTitleLabel'
61 text: model.name62 text: model.name
62 color: root.notebookColor63 color: root.notebookColor
63 fontSize: "large"64 fontSize: "large"
64 }65 }
65 Label {66 Label {
67 objectName: 'notebookLastUpdatedLabel'
66 text: i18n.tr("Last edited %1").arg(model.lastUpdatedString)68 text: i18n.tr("Last edited %1").arg(model.lastUpdatedString)
67 fontSize: "small"69 fontSize: "small"
68 color: "black"70 color: "black"
69 }71 }
70 Label {72 Label {
73 objectName: 'notebookPublishedLabel'
71 Layout.fillHeight: true74 Layout.fillHeight: true
72 text: model.published ? i18n.tr("Shared") : i18n.tr("Private")75 text: model.published ? i18n.tr("Shared") : i18n.tr("Private")
73 color: model.published ? "black" : "#b3b3b3"76 color: model.published ? "black" : "#b3b3b3"
@@ -78,6 +81,7 @@
78 }81 }
7982
80 Label {83 Label {
84 objectName: 'notebookNoteCountLabel'
81 Layout.fillHeight: true85 Layout.fillHeight: true
82 verticalAlignment: Text.AlignVCenter86 verticalAlignment: Text.AlignVCenter
83 text: "(" + model.noteCount + ")"87 text: "(" + model.noteCount + ")"
8488
=== modified file 'src/app/qml/ui/NotebooksPage.qml'
--- src/app/qml/ui/NotebooksPage.qml 2014-05-14 10:31:49 +0000
+++ src/app/qml/ui/NotebooksPage.qml 2014-05-23 07:11:33 +0000
@@ -24,6 +24,7 @@
2424
25Page {25Page {
26 id: root26 id: root
27 objectName: 'notebooksPage'
2728
28 signal openNotebook(string title, string notebookGuid)29 signal openNotebook(string title, string notebookGuid)
2930
@@ -62,6 +63,7 @@
62 }63 }
6364
64 ToolbarButton {65 ToolbarButton {
66 objectName: "addNotebookButton"
65 text: i18n.tr("Add notebook")67 text: i18n.tr("Add notebook")
66 iconName: "add"68 iconName: "add"
67 onTriggered: {69 onTriggered: {
@@ -108,12 +110,14 @@
108110
109 TextField {111 TextField {
110 id: newNoteTitleTextField112 id: newNoteTitleTextField
113 objectName: "newNoteTitleTextField"
111 anchors { left: parent.left; right: parent.right; margins: units.gu(2); verticalCenter: parent.verticalCenter }114 anchors { left: parent.left; right: parent.right; margins: units.gu(2); verticalCenter: parent.verticalCenter }
112 }115 }
113 }116 }
114117
115 PulldownListView {118 PulldownListView {
116 id: notebooksListView119 id: notebooksListView
120 objectName: "notebooksListView"
117 model: notebooks121 model: notebooks
118 anchors { left: parent.left; right: parent.right }122 anchors { left: parent.left; right: parent.right }
119 height: parent.height - y - buttonRow.height - keyboardRect.height123 height: parent.height - y - buttonRow.height - keyboardRect.height
@@ -168,6 +172,7 @@
168 }172 }
169 }173 }
170 Button {174 Button {
175 objectName: "saveButton"
171 anchors { right: parent.right; verticalCenter: parent.verticalCenter }176 anchors { right: parent.right; verticalCenter: parent.verticalCenter }
172 text: i18n.tr("Save")177 text: i18n.tr("Save")
173 enabled: newNoteTitleTextField.text.length > 0178 enabled: newNoteTitleTextField.text.length > 0
174179
=== modified file 'tests/autopilot/reminders/__init__.py'
--- tests/autopilot/reminders/__init__.py 2014-05-16 06:52:10 +0000
+++ tests/autopilot/reminders/__init__.py 2014-05-23 07:11:33 +0000
@@ -21,6 +21,8 @@
21import logging21import logging
22from distutils import version22from distutils import version
2323
24import ubuntuuitoolkit
25
24import autopilot26import autopilot
25from autopilot import logging as autopilot_logging27from autopilot import logging as autopilot_logging
26from autopilot.introspection import dbus28from autopilot.introspection import dbus
@@ -41,6 +43,16 @@
41 self.app = app_proxy43 self.app = app_proxy
42 self.main_view = self.app.select_single(MainView)44 self.main_view = self.app.select_single(MainView)
4345
46 def open_notebooks(self):
47 """Open the Notebooks page.
48
49 :return: The autopilot custom proxy object for the NotebooksPage.
50
51 """
52 self.main_view.switch_to_tab('NotebookTab')
53 return self.main_view.select_single(
54 NotebooksPage, objectName='notebooksPage')
55
4456
45class MainView(toolkit_emulators.MainView):57class MainView(toolkit_emulators.MainView):
46 """Autopilot custom proxy object for the MainView."""58 """Autopilot custom proxy object for the MainView."""
@@ -64,6 +76,7 @@
6476
6577
66class NoAccountDialog(toolkit_emulators.UbuntuUIToolkitEmulatorBase):78class NoAccountDialog(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
79 """Autopilot custom proxy object for the no account dialog."""
6780
68 @classmethod81 @classmethod
69 def validate_dbus_object(cls, path, state):82 def validate_dbus_object(cls, path, state):
@@ -85,3 +98,90 @@
85 def open_account_settings(self):98 def open_account_settings(self):
86 button = self.select_single('Button', objectName='openAccountButton')99 button = self.select_single('Button', objectName='openAccountButton')
87 self.pointing_device.click_object(button)100 self.pointing_device.click_object(button)
101
102
103class _Page(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
104
105 def __init__(self, *args):
106 super(_Page, self).__init__(*args)
107 # XXX we need a better way to keep reference to the main view.
108 # --elopio - 2014-02-26
109 self.main_view = self.get_root_instance().select_single(MainView)
110
111
112class PulldownListView(ubuntuuitoolkit.QQuickListView):
113 """Autopilot custom proxy object for the PulldownListView."""
114
115
116class NotebooksPage(_Page):
117 """Autopilot custom proxy object for the Notebooks page."""
118
119 def add_notebook(self, title):
120 """Add a notebook.
121
122 :param title: The title of the Notebook that will be added.
123
124 """
125 original_number_of_books = self._get_notebooks_listview().count
126 self.main_view.open_toolbar().click_button('addNotebookButton')
127 title_textfield = self.select_single(
128 ubuntuuitoolkit.TextField, objectName='newNoteTitleTextField')
129 title_textfield.write(title)
130 self._click_save()
131 self._get_notebooks_listview().count.wait_for(
132 original_number_of_books + 1)
133
134 def _get_notebooks_listview(self):
135 return self.select_single(
136 PulldownListView, objectName='notebooksListView')
137
138 def _click_save(self):
139 save_button = self.select_single('Button', objectName='saveButton')
140 self.pointing_device.click_object(save_button)
141
142 def get_notebooks(self):
143 """Return the list of Notebooks.
144
145 :return: A list with the the Notebooks. Every item of the list is a
146 tuple with title, last updated value, published status and number
147 of notes. The list is sorted in the same order as it is displayed
148 on the application.
149
150 """
151 listview = self._get_notebooks_listview()
152 notebook_delegates = listview.select_many(NotebooksDelegate)
153 # Sort by the position on the list.
154 sorted_notebook_delegates = sorted(
155 notebook_delegates,
156 key=lambda delegate: delegate.globalRect.y)
157 notebooks = [
158 (notebook.get_title(), notebook.get_last_updated(),
159 notebook.get_published_status(), notebook.get_notes_count())
160 for notebook in sorted_notebook_delegates
161 ]
162 return notebooks
163
164
165class NotebooksDelegate(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
166 """Autopilot custom proxy object for the NotebooksDelegate."""
167
168 def get_title(self):
169 """Return the title of the Notebook."""
170 return self._get_label_text('notebookTitleLabel')
171
172 def _get_label_text(self, object_name):
173 label = self.select_single('Label', objectName=object_name)
174 return label.text
175
176 def get_last_updated(self):
177 """Return the last updated value of the Notebook."""
178 return self._get_label_text('notebookLastUpdatedLabel')
179
180 def get_published_status(self):
181 """Return the published status of the Notebook."""
182 return self._get_label_text('notebookPublishedLabel')
183
184 def get_notes_count(self):
185 """Return the number of notes in the Notebook."""
186 # The count is returned in paretheses, so we strip them.
187 return int(self._get_label_text('notebookNoteCountLabel').strip('()'))
88188
=== modified file 'tests/autopilot/reminders/credentials.py'
--- tests/autopilot/reminders/credentials.py 2014-05-08 18:10:01 +0000
+++ tests/autopilot/reminders/credentials.py 2014-05-23 07:11:33 +0000
@@ -28,7 +28,7 @@
28 """Manager for online accounts."""28 """Manager for online accounts."""
2929
30 def __init__(self):30 def __init__(self):
31 self._manager = Accounts.Manager()31 self._manager = Accounts.Manager.new()
3232
33 def _start_main_loop(self):33 def _start_main_loop(self):
34 self.error = None34 self.error = None
3535
=== modified file 'tests/autopilot/reminders/tests/__init__.py'
--- tests/autopilot/reminders/tests/__init__.py 2014-05-22 09:55:36 +0000
+++ tests/autopilot/reminders/tests/__init__.py 2014-05-23 07:11:33 +0000
@@ -45,14 +45,13 @@
45 scenarios = [('with touch', dict(input_device_class=Touch))]45 scenarios = [('with touch', dict(input_device_class=Touch))]
4646
47 local_location = os.path.dirname(os.path.dirname(os.getcwd()))47 local_location = os.path.dirname(os.path.dirname(os.getcwd()))
48 local_location_qml = os.path.join(local_location,48
49 'src/app/qml/reminders.qml')49 local_location_qml = os.path.join(
50 local_location, 'src/app/qml/reminders.qml')
50 local_location_binary = os.path.join(local_location, 'src/app/reminders')51 local_location_binary = os.path.join(local_location, 'src/app/reminders')
51 installed_location_binary = '/usr/bin/reminders'52 installed_location_binary = '/usr/bin/reminders'
52 installed_location_qml = '/usr/share/reminders/qml/reminders.qml'53 installed_location_qml = '/usr/share/reminders/qml/reminders.qml'
5354
54 home_dir = None
55
56 def get_launcher_and_type(self):55 def get_launcher_and_type(self):
57 if os.path.exists(self.local_location_binary):56 if os.path.exists(self.local_location_binary):
58 launcher = self.launch_test_local57 launcher = self.launch_test_local
@@ -67,8 +66,7 @@
6766
68 def setUp(self):67 def setUp(self):
69 launcher, test_type = self.get_launcher_and_type()68 launcher, test_type = self.get_launcher_and_type()
70 if self.home_dir is None:69 self.home_dir = self._patch_home(test_type)
71 self.home_dir = self._patch_home(test_type)
72 self.pointing_device = Pointer(self.input_device_class.create())70 self.pointing_device = Pointer(self.input_device_class.create())
73 super(RemindersAppTestCase, self).setUp()71 super(RemindersAppTestCase, self).setUp()
7472
@@ -90,6 +88,7 @@
90 temp_dir_fixture = fixtures.TempDir()88 temp_dir_fixture = fixtures.TempDir()
91 self.useFixture(temp_dir_fixture)89 self.useFixture(temp_dir_fixture)
92 temp_dir = temp_dir_fixture.path90 temp_dir = temp_dir_fixture.path
91 temp_xdg_config_home = os.path.join(temp_dir, '.config')
9392
94 #If running under xvfb, as jenkins does,93 #If running under xvfb, as jenkins does,
95 #xsession will fail to start without xauthority file94 #xsession will fail to start without xauthority file
@@ -100,21 +99,25 @@
100 #click requires using initctl env (upstart), but the desktop can set99 #click requires using initctl env (upstart), but the desktop can set
101 #an environment variable instead100 #an environment variable instead
102 if test_type == 'click':101 if test_type == 'click':
103 self.useFixture(toolkit_fixtures.InitctlEnvironmentVariable(102 self.useFixture(
104 HOME=temp_dir))103 toolkit_fixtures.InitctlEnvironmentVariable(
104 HOME=temp_dir, XDG_CONFIG_HOME=temp_xdg_config_home))
105 else:105 else:
106 self.useFixture(fixtures.EnvironmentVariable('HOME',106 self.useFixture(
107 newvalue=temp_dir))107 fixtures.EnvironmentVariable('HOME', newvalue=temp_dir))
108 self.useFixture(
109 fixtures.EnvironmentVariable(
110 'XDG_CONFIG_HOME', newvalue=temp_xdg_config_home))
108111
109 logger.debug("Patched home to fake home directory " + temp_dir)112 logger.debug('Patched home to fake home directory ' + temp_dir)
110113
111 return temp_dir114 return temp_dir
112115
113 @autopilot_logging.log_action(logger.info)116 @autopilot_logging.log_action(logger.info)
114 def launch_test_local(self):117 def launch_test_local(self):
115 self.useFixture(fixtures.EnvironmentVariable('QML2_IMPORT_PATH',118 self.useFixture(fixtures.EnvironmentVariable(
116 newvalue=os.path.join(self.local_location,119 'QML2_IMPORT_PATH',
117 'src/plugin')))120 newvalue=os.path.join(self.local_location, 'src/plugin')))
118 return self.launch_test_application(121 return self.launch_test_application(
119 self.local_location_binary,122 self.local_location_binary,
120 '-q', self.local_location_qml,123 '-q', self.local_location_qml,
121124
=== modified file 'tests/autopilot/reminders/tests/test_reminders.py'
--- tests/autopilot/reminders/tests/test_reminders.py 2014-05-08 23:52:39 +0000
+++ tests/autopilot/reminders/tests/test_reminders.py 2014-05-23 07:11:33 +0000
@@ -19,11 +19,11 @@
19from __future__ import absolute_import19from __future__ import absolute_import
2020
21import logging21import logging
22import uuid
2223
23from autopilot import platform24from autopilot import platform
24from autopilot.matchers import Eventually25from autopilot.matchers import Eventually
25from testtools.matchers import Equals26from testtools.matchers import Equals
26from testtools import ExpectedException
2727
28import reminders28import reminders
29from reminders import credentials, fixture_setup, tests29from reminders import credentials, fixture_setup, tests
@@ -62,12 +62,10 @@
62class RemindersTestCaseWithAccount(tests.RemindersAppTestCase):62class RemindersTestCaseWithAccount(tests.RemindersAppTestCase):
6363
64 def setUp(self):64 def setUp(self):
65 # We need to change the home dir before adding the account, otherwise65 super(RemindersTestCaseWithAccount, self).setUp()
66 # the account will not be found when the app is opened.66 no_account_dialog = self.app.main_view.no_account_dialog
67 _, test_type = self.get_launcher_and_type()
68 self.home_dir = self._patch_home(test_type)
69 self.add_evernote_account()67 self.add_evernote_account()
70 super(RemindersTestCaseWithAccount, self).setUp()68 no_account_dialog.wait_until_destroyed()
7169
72 def add_evernote_account(self):70 def add_evernote_account(self):
73 account_manager = credentials.AccountManager()71 account_manager = credentials.AccountManager()
@@ -77,8 +75,24 @@
77 account = account_manager.add_evernote_account(75 account = account_manager.add_evernote_account(
78 'dummy', 'dummy', oauth_token)76 'dummy', 'dummy', oauth_token)
79 self.addCleanup(account_manager.delete_account, account)77 self.addCleanup(account_manager.delete_account, account)
8078 del account_manager._manager
81 def test_open_application_with_account(self):79 del account_manager
82 """Test that the No account dialog is not visible."""80
83 with ExpectedException(reminders.RemindersAppException):81 def test_add_notebook_must_append_it_to_list(self):
84 self.app.main_view.no_account_dialog82 test_notebook_title = 'Test notebook {}'.format(uuid.uuid1())
83
84 notebooks_page = self.app.open_notebooks()
85 # FIXME delete the added notebook. Otherwise, the test account will
86 # fill up. See http://pad.lv/1318749 --elopio - 2014-05-12
87 notebooks_page.add_notebook(test_notebook_title)
88
89 last_notebook = notebooks_page.get_notebooks()[-1]
90 # TODO there's a bug with the last updated value: http://pad.lv/1318751
91 # so we can't check the full tuple. Uncomment this as soon as the bug
92 # is fixed. --elopio - 2014-05-12
93 #self.assertEqual(
94 # last_notebook,
95 # (test_notebook_title, 'Last edited today', 'Private', 0))
96 self.assertEqual(last_notebook[0], test_notebook_title)
97 self.assertEqual(last_notebook[2], 'Private')
98 self.assertEqual(last_notebook[3], 0)

Subscribers

People subscribed via source and target branches