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
=== modified file 'debian/control'
--- debian/control 2015-02-09 15:02:11 +0000
+++ debian/control 2015-02-24 15:05:29 +0000
@@ -92,5 +92,6 @@
92 ubuntu-ui-toolkit-autopilot (>= 0.1.46+14.10.20140527),92 ubuntu-ui-toolkit-autopilot (>= 0.1.46+14.10.20140527),
93 address-book-app (>= ${binary:Version}),93 address-book-app (>= ${binary:Version}),
94 ubuntu-mobile-icons,94 ubuntu-mobile-icons,
95 content-hub-testability,
95Description: Test package for address-book-app96Description: Test package for address-book-app
96 Autopilot tests for the address-book-app package97 Autopilot tests for the address-book-app package
9798
=== modified file 'src/imports/ContactEdit/ContactDetailAvatarEditor.qml'
--- src/imports/ContactEdit/ContactDetailAvatarEditor.qml 2014-09-29 13:20:08 +0000
+++ src/imports/ContactEdit/ContactDetailAvatarEditor.qml 2015-02-24 15:05:29 +0000
@@ -74,6 +74,7 @@
7474
75 Image {75 Image {
76 id: avatarImage76 id: avatarImage
77 objectName: "avatarImage"
7778
78 fillMode: Image.PreserveAspectCrop79 fillMode: Image.PreserveAspectCrop
79 asynchronous: true80 asynchronous: true
8081
=== modified file 'tests/autopilot/address_book_app/pages/_contact_editor.py'
--- tests/autopilot/address_book_app/pages/_contact_editor.py 2014-08-20 18:27:37 +0000
+++ tests/autopilot/address_book_app/pages/_contact_editor.py 2015-02-24 15:05:29 +0000
@@ -17,6 +17,8 @@
17import collections17import collections
18import logging18import logging
19import time19import time
20import urllib.parse
21import urllib.request
2022
21import autopilot.logging23import autopilot.logging
22import ubuntuuitoolkit24import ubuntuuitoolkit
@@ -61,12 +63,10 @@
6163
62 @autopilot.logging.log_action(logger.info)64 @autopilot.logging.log_action(logger.info)
63 def add_field(self, detail_name):65 def add_field(self, detail_name):
64 """Create a new field into the edit contact form.66 """
6567 Create a new field into the edit contact form.
66 :param detail_name: The detail field name68 :param detail_name: The detail field name
67
68 """69 """
69
70 add_field_button = self.select_single(70 add_field_button = self.select_single(
71 'ComboButtonAddField', objectName='addNewFieldButton')71 'ComboButtonAddField', objectName='addNewFieldButton')
72 add_field_button.swipe_into_view()72 add_field_button.swipe_into_view()
@@ -150,6 +150,35 @@
150 'QQuickFlickable', objectName='scrollArea')150 'QQuickFlickable', objectName='scrollArea')
151 flickable.flicking.wait_for(False)151 flickable.flicking.wait_for(False)
152152
153 def _get_photo_icon(self):
154 """Return the photo icon QQuickImage object"""
155 photo_icon = self.select_single(
156 'QQuickImage', objectName='avatarImage')
157 return photo_icon
158
159 def press_photo_icon(self):
160 """Press the photo icon on the contact editor page"""
161 self.pointing_device.click_object(self._get_photo_icon())
162
163 def _convert_file_url_to_file_path(self, file_url):
164 """
165 Convert the specified file url to a file path
166
167 :param file_url: url encoded file path
168 :return: file path
169 """
170 path_decoded = urllib.request.url2pathname(file_url)
171 return urllib.parse.urlparse(path_decoded).path
172
173 def get_contact_avatar_file_path(self):
174 """
175 Get the avatar file path for contact
176 :return avatar file path:
177 """
178 avatar = self._get_photo_icon()
179 return self._convert_file_url_to_file_path(
180 avatar.get_properties()['source'])
181
153182
154class TextInputDetail(ubuntuuitoolkit.TextField):183class TextInputDetail(ubuntuuitoolkit.TextField):
155 """Custom proxy object for the Text Input Detail field."""184 """Custom proxy object for the Text Input Detail field."""
156185
=== modified file 'tests/autopilot/address_book_app/pages/_contact_list_page.py'
--- tests/autopilot/address_book_app/pages/_contact_list_page.py 2015-02-19 07:02:09 +0000
+++ tests/autopilot/address_book_app/pages/_contact_list_page.py 2015-02-24 15:05:29 +0000
@@ -126,6 +126,17 @@
126 ]126 ]
127 return [label.text for label in name_labels]127 return [label.text for label in name_labels]
128128
129 def get_contact_avatar_file_path(self, display_name):
130 """
131 Get the avatar file path for contact
132 :param display_name: Display name of contact
133 :return avatar file path:
134 """
135 avatar = self.wait_select_single(
136 'ContactAvatar', displayName=display_name)
137 return self._convert_file_url_to_file_path(
138 avatar.get_properties()['avatarUrl'])
139
129140
130class RemoveContactsDialog(141class RemoveContactsDialog(
131 ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):142 ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
132143
=== modified file 'tests/autopilot/address_book_app/tests/__init__.py'
--- tests/autopilot/address_book_app/tests/__init__.py 2015-02-19 07:02:09 +0000
+++ tests/autopilot/address_book_app/tests/__init__.py 2015-02-24 15:05:29 +0000
@@ -93,6 +93,28 @@
93 if model() != "Desktop":93 if model() != "Desktop":
94 subprocess.check_call(["/sbin/initctl", "start", "maliit-server"])94 subprocess.check_call(["/sbin/initctl", "start", "maliit-server"])
9595
96 def _set_content_hub_default_picture_handler(self, app_identifier):
97 subprocess.check_call([
98 '/usr/bin/gsettings',
99 'set',
100 'com.ubuntu.content.hub.default',
101 'pictures',
102 app_identifier])
103
104 def _get_content_hub_default_picture_handler(self):
105 return subprocess.getoutput(
106 '/usr/bin/gsettings get com.ubuntu.content.hub.default pictures')
107
108 def configure_content_hub_test_picture_handler(self):
109 self.default_picture_handler = \
110 self._get_content_hub_default_picture_handler()
111 test_handler = '["content-hub-test-exporter", "", ""]'
112 self._set_content_hub_default_picture_handler(test_handler)
113
114 def restore_default_content_hub_test_picture_handler(self):
115 self._set_content_hub_default_picture_handler(
116 self.default_picture_handler)
117
96 def launch_test_local(self):118 def launch_test_local(self):
97 return self.launch_test_application(119 return self.launch_test_application(
98 self.app_bin,120 self.app_bin,
99121
=== modified file 'tests/autopilot/address_book_app/tests/test_edit_contact.py'
--- tests/autopilot/address_book_app/tests/test_edit_contact.py 2014-06-17 17:58:07 +0000
+++ tests/autopilot/address_book_app/tests/test_edit_contact.py 2015-02-24 15:05:29 +0000
@@ -7,7 +7,7 @@
77
8"""Tests for the Addressbook App"""8"""Tests for the Addressbook App"""
99
10from testtools.matchers import Equals10from testtools.matchers import Equals, NotEquals
11from autopilot.matchers import Eventually11from autopilot.matchers import Eventually
1212
13from address_book_app import data13from address_book_app import data
@@ -19,6 +19,14 @@
1919
20 PHONE_NUMBERS = ['(333) 123-4567', '(333) 123-4568', '(222) 222-2222']20 PHONE_NUMBERS = ['(333) 123-4567', '(333) 123-4568', '(222) 222-2222']
2121
22 def setUp(self):
23 self.configure_content_hub_test_picture_handler()
24 super(TestEditContact, self).setUp()
25
26 def tearDown(self):
27 self.restore_default_content_hub_test_picture_handler()
28 super(TestEditContact, self).tearDown()
29
22 def add_test_contact(self):30 def add_test_contact(self):
23 test_contact = data.Contact('test', 'test')31 test_contact = data.Contact('test', 'test')
24 # TODO implement the filling of professional details.32 # TODO implement the filling of professional details.
@@ -61,7 +69,8 @@
61 phone_label_1 = view_page.select_single(69 phone_label_1 = view_page.select_single(
62 "Label",70 "Label",
63 objectName="label_phoneNumber_1.0")71 objectName="label_phoneNumber_1.0")
64 self.assertThat(phone_label_1.text, Eventually(Equals(self.PHONE_NUMBERS[1])))72 self.assertThat(
73 phone_label_1.text, Eventually(Equals(self.PHONE_NUMBERS[1])))
6574
66 def test_remove_phone(self):75 def test_remove_phone(self):
67 contact_editor = self.app.main_window.go_to_add_contact()76 contact_editor = self.app.main_window.go_to_add_contact()
@@ -97,7 +106,8 @@
97 phone_label_1 = view_page.select_single(106 phone_label_1 = view_page.select_single(
98 "Label",107 "Label",
99 objectName="label_phoneNumber_0.0")108 objectName="label_phoneNumber_0.0")
100 self.assertThat(phone_label_1.text, Eventually(Equals(self.PHONE_NUMBERS[1])))109 self.assertThat(
110 phone_label_1.text, Eventually(Equals(self.PHONE_NUMBERS[1])))
101111
102 def test_add_email(self):112 def test_add_email(self):
103 self.add_contact("Fulano", "")113 self.add_contact("Fulano", "")
@@ -214,3 +224,16 @@
214 "Label",224 "Label",
215 objectName="type_onlineAccount_0")225 objectName="type_onlineAccount_0")
216 self.assertThat(im_type.text, Eventually(Equals("Aim")))226 self.assertThat(im_type.text, Eventually(Equals("Aim")))
227
228 def test_add_photo(self):
229 """Test to add a photo to a contact using content-hub-test-exporter"""
230 # go to add a new contact
231 contact_editor = self.main_window.go_to_add_contact()
232 # get the default avatar file path
233 original_file_path = contact_editor.get_contact_avatar_file_path()
234 # this test uses content-hub-test-exporter to return a picture
235 # instead of launching the gallery-app
236 contact_editor.press_photo_icon()
237 # check that the avatar file path has now been updated
238 avatar_file_path = contact_editor.get_contact_avatar_file_path()
239 self.assertThat(avatar_file_path, NotEquals(original_file_path))

Subscribers

People subscribed via source and target branches