Merge lp:~rhuddie/address-book-app/add-photo-helper into lp:address-book-app

Proposed by Richard Huddie
Status: Needs review
Proposed branch: lp:~rhuddie/address-book-app/add-photo-helper
Merge into: lp:address-book-app
Diff against target: 206 lines (+94/-7)
6 files modified
debian/control (+1/-0)
src/imports/ContactEdit/ContactDetailAvatarEditor.qml (+1/-0)
tests/autopilot/address_book_app/pages/_contact_editor.py (+33/-4)
tests/autopilot/address_book_app/pages/_contact_list_page.py (+11/-0)
tests/autopilot/address_book_app/tests/__init__.py (+22/-0)
tests/autopilot/address_book_app/tests/test_edit_contact.py (+26/-3)
To merge this branch: bzr merge lp:~rhuddie/address-book-app/add-photo-helper
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Leo Arias (community) Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+227519@code.launchpad.net

Description of the change

New helper method and test for adding a photo to a contact.

Requires content-hub-test-exporter from content-hub-testability to be installed: lp:~ken-vandine/content-hub/testability

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:229
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~rhuddie/address-book-app/add-photo-helper/+merge/227519/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/address-book-app-ci/619/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-utopic-amd64-ci/72
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-utopic-armhf-ci/72
        deb: http://jenkins.qa.ubuntu.com/job/address-book-app-utopic-armhf-ci/72/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-utopic-i386-ci/72
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/2220/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/1851/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/2430/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3401
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/3401/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/10121
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/1555/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2070
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/2070/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/address-book-app-ci/619/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

This looks good, and we are likely going to need it next week to automate adding a picture from the camera.
Richard, can you please push it to the team branch, so somebody else can take over it and update it?

review: Needs Fixing
230. By Richard Huddie

merge from trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

230. By Richard Huddie

merge from trunk

229. By Richard Huddie

fix flake8

228. By Richard Huddie

test now working

227. By Richard Huddie

add content-hub-testability dependency

226. By Richard Huddie

add expected path validation

225. By Richard Huddie

move url conversion to contact editor

224. By Richard Huddie

merge trunk

223. By Richard Huddie

test updates and add def get_contact_avatar_file_path(self):

222. By Richard Huddie

add get_contact_avatar_file_path() to ContactListPage helper

221. By Richard Huddie

added fake url dispatcher

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 2015-02-09 15:02:11 +0000
3+++ debian/control 2015-02-24 15:05:29 +0000
4@@ -92,5 +92,6 @@
5 ubuntu-ui-toolkit-autopilot (>= 0.1.46+14.10.20140527),
6 address-book-app (>= ${binary:Version}),
7 ubuntu-mobile-icons,
8+ content-hub-testability,
9 Description: Test package for address-book-app
10 Autopilot tests for the address-book-app package
11
12=== modified file 'src/imports/ContactEdit/ContactDetailAvatarEditor.qml'
13--- src/imports/ContactEdit/ContactDetailAvatarEditor.qml 2014-09-29 13:20:08 +0000
14+++ src/imports/ContactEdit/ContactDetailAvatarEditor.qml 2015-02-24 15:05:29 +0000
15@@ -74,6 +74,7 @@
16
17 Image {
18 id: avatarImage
19+ objectName: "avatarImage"
20
21 fillMode: Image.PreserveAspectCrop
22 asynchronous: true
23
24=== modified file 'tests/autopilot/address_book_app/pages/_contact_editor.py'
25--- tests/autopilot/address_book_app/pages/_contact_editor.py 2014-08-20 18:27:37 +0000
26+++ tests/autopilot/address_book_app/pages/_contact_editor.py 2015-02-24 15:05:29 +0000
27@@ -17,6 +17,8 @@
28 import collections
29 import logging
30 import time
31+import urllib.parse
32+import urllib.request
33
34 import autopilot.logging
35 import ubuntuuitoolkit
36@@ -61,12 +63,10 @@
37
38 @autopilot.logging.log_action(logger.info)
39 def add_field(self, detail_name):
40- """Create a new field into the edit contact form.
41-
42+ """
43+ Create a new field into the edit contact form.
44 :param detail_name: The detail field name
45-
46 """
47-
48 add_field_button = self.select_single(
49 'ComboButtonAddField', objectName='addNewFieldButton')
50 add_field_button.swipe_into_view()
51@@ -150,6 +150,35 @@
52 'QQuickFlickable', objectName='scrollArea')
53 flickable.flicking.wait_for(False)
54
55+ def _get_photo_icon(self):
56+ """Return the photo icon QQuickImage object"""
57+ photo_icon = self.select_single(
58+ 'QQuickImage', objectName='avatarImage')
59+ return photo_icon
60+
61+ def press_photo_icon(self):
62+ """Press the photo icon on the contact editor page"""
63+ self.pointing_device.click_object(self._get_photo_icon())
64+
65+ def _convert_file_url_to_file_path(self, file_url):
66+ """
67+ Convert the specified file url to a file path
68+
69+ :param file_url: url encoded file path
70+ :return: file path
71+ """
72+ path_decoded = urllib.request.url2pathname(file_url)
73+ return urllib.parse.urlparse(path_decoded).path
74+
75+ def get_contact_avatar_file_path(self):
76+ """
77+ Get the avatar file path for contact
78+ :return avatar file path:
79+ """
80+ avatar = self._get_photo_icon()
81+ return self._convert_file_url_to_file_path(
82+ avatar.get_properties()['source'])
83+
84
85 class TextInputDetail(ubuntuuitoolkit.TextField):
86 """Custom proxy object for the Text Input Detail field."""
87
88=== modified file 'tests/autopilot/address_book_app/pages/_contact_list_page.py'
89--- tests/autopilot/address_book_app/pages/_contact_list_page.py 2015-02-19 07:02:09 +0000
90+++ tests/autopilot/address_book_app/pages/_contact_list_page.py 2015-02-24 15:05:29 +0000
91@@ -126,6 +126,17 @@
92 ]
93 return [label.text for label in name_labels]
94
95+ def get_contact_avatar_file_path(self, display_name):
96+ """
97+ Get the avatar file path for contact
98+ :param display_name: Display name of contact
99+ :return avatar file path:
100+ """
101+ avatar = self.wait_select_single(
102+ 'ContactAvatar', displayName=display_name)
103+ return self._convert_file_url_to_file_path(
104+ avatar.get_properties()['avatarUrl'])
105+
106
107 class RemoveContactsDialog(
108 ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
109
110=== modified file 'tests/autopilot/address_book_app/tests/__init__.py'
111--- tests/autopilot/address_book_app/tests/__init__.py 2015-02-19 07:02:09 +0000
112+++ tests/autopilot/address_book_app/tests/__init__.py 2015-02-24 15:05:29 +0000
113@@ -93,6 +93,28 @@
114 if model() != "Desktop":
115 subprocess.check_call(["/sbin/initctl", "start", "maliit-server"])
116
117+ def _set_content_hub_default_picture_handler(self, app_identifier):
118+ subprocess.check_call([
119+ '/usr/bin/gsettings',
120+ 'set',
121+ 'com.ubuntu.content.hub.default',
122+ 'pictures',
123+ app_identifier])
124+
125+ def _get_content_hub_default_picture_handler(self):
126+ return subprocess.getoutput(
127+ '/usr/bin/gsettings get com.ubuntu.content.hub.default pictures')
128+
129+ def configure_content_hub_test_picture_handler(self):
130+ self.default_picture_handler = \
131+ self._get_content_hub_default_picture_handler()
132+ test_handler = '["content-hub-test-exporter", "", ""]'
133+ self._set_content_hub_default_picture_handler(test_handler)
134+
135+ def restore_default_content_hub_test_picture_handler(self):
136+ self._set_content_hub_default_picture_handler(
137+ self.default_picture_handler)
138+
139 def launch_test_local(self):
140 return self.launch_test_application(
141 self.app_bin,
142
143=== modified file 'tests/autopilot/address_book_app/tests/test_edit_contact.py'
144--- tests/autopilot/address_book_app/tests/test_edit_contact.py 2014-06-17 17:58:07 +0000
145+++ tests/autopilot/address_book_app/tests/test_edit_contact.py 2015-02-24 15:05:29 +0000
146@@ -7,7 +7,7 @@
147
148 """Tests for the Addressbook App"""
149
150-from testtools.matchers import Equals
151+from testtools.matchers import Equals, NotEquals
152 from autopilot.matchers import Eventually
153
154 from address_book_app import data
155@@ -19,6 +19,14 @@
156
157 PHONE_NUMBERS = ['(333) 123-4567', '(333) 123-4568', '(222) 222-2222']
158
159+ def setUp(self):
160+ self.configure_content_hub_test_picture_handler()
161+ super(TestEditContact, self).setUp()
162+
163+ def tearDown(self):
164+ self.restore_default_content_hub_test_picture_handler()
165+ super(TestEditContact, self).tearDown()
166+
167 def add_test_contact(self):
168 test_contact = data.Contact('test', 'test')
169 # TODO implement the filling of professional details.
170@@ -61,7 +69,8 @@
171 phone_label_1 = view_page.select_single(
172 "Label",
173 objectName="label_phoneNumber_1.0")
174- self.assertThat(phone_label_1.text, Eventually(Equals(self.PHONE_NUMBERS[1])))
175+ self.assertThat(
176+ phone_label_1.text, Eventually(Equals(self.PHONE_NUMBERS[1])))
177
178 def test_remove_phone(self):
179 contact_editor = self.app.main_window.go_to_add_contact()
180@@ -97,7 +106,8 @@
181 phone_label_1 = view_page.select_single(
182 "Label",
183 objectName="label_phoneNumber_0.0")
184- self.assertThat(phone_label_1.text, Eventually(Equals(self.PHONE_NUMBERS[1])))
185+ self.assertThat(
186+ phone_label_1.text, Eventually(Equals(self.PHONE_NUMBERS[1])))
187
188 def test_add_email(self):
189 self.add_contact("Fulano", "")
190@@ -214,3 +224,16 @@
191 "Label",
192 objectName="type_onlineAccount_0")
193 self.assertThat(im_type.text, Eventually(Equals("Aim")))
194+
195+ def test_add_photo(self):
196+ """Test to add a photo to a contact using content-hub-test-exporter"""
197+ # go to add a new contact
198+ contact_editor = self.main_window.go_to_add_contact()
199+ # get the default avatar file path
200+ original_file_path = contact_editor.get_contact_avatar_file_path()
201+ # this test uses content-hub-test-exporter to return a picture
202+ # instead of launching the gallery-app
203+ contact_editor.press_photo_icon()
204+ # check that the avatar file path has now been updated
205+ avatar_file_path = contact_editor.get_contact_avatar_file_path()
206+ self.assertThat(avatar_file_path, NotEquals(original_file_path))

Subscribers

People subscribed via source and target branches