Merge lp:~om26er/address-book-app/abook_navigation_favorites into lp:address-book-app

Proposed by Omer Akram
Status: Work in progress
Proposed branch: lp:~om26er/address-book-app/abook_navigation_favorites
Merge into: lp:address-book-app
Prerequisite: lp:~renatofilho/address-book-app/new-favorite-list
Diff against target: 726 lines (+446/-35)
15 files modified
src/imports/ContactView/ContactDetailFavoriteView.qml (+1/-0)
src/imports/Ubuntu/Contacts/ContactListView.qml (+2/-0)
tests/autopilot/address_book_app/emulators/__init__.py (+12/-0)
tests/autopilot/address_book_app/emulators/contact_list_page.py (+145/-26)
tests/autopilot/address_book_app/emulators/contact_view.py (+57/-0)
tests/autopilot/address_book_app/emulators/main_window.py (+27/-3)
tests/autopilot/address_book_app/helpers.py (+74/-0)
tests/autopilot/address_book_app/tests/__init__.py (+17/-6)
tests/autopilot/address_book_app/tests/test_add_contact.py (+4/-0)
tests/autopilot/address_book_app/tests/test_contactlist.py (+4/-0)
tests/autopilot/address_book_app/tests/test_delete_contact.py (+1/-0)
tests/autopilot/address_book_app/tests/test_edit_contact.py (+4/-0)
tests/autopilot/address_book_app/tests/test_favorites.py (+96/-0)
tests/autopilot/address_book_app/tests/test_multiple_pick_mode.py (+1/-0)
tests/autopilot/address_book_app/tests/test_single_pick_mode.py (+1/-0)
To merge this branch: bzr merge lp:~om26er/address-book-app/abook_navigation_favorites
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Allan LeSage Pending
Ubuntu Phablet Team Pending
Review via email: mp+211431@code.launchpad.net

This proposal supersedes a proposal from 2014-03-17.

Commit message

autopilot: add tests for favoriting contacts, using the new dummy backend service

Description of the change

Note: I only fixed the code to use the dummy backend service, no other changes are from me.

Depends on lp:~renatofilho/address-book-service/dummy-mode to be merged.

To post a comment you must log in.
163. By Omer Akram

remove syncevolution dep

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:163
http://jenkins.qa.ubuntu.com/job/address-book-app-ci/455/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-amd64-ci/165
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-armhf-ci/165
        deb: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-armhf-ci/165/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-i386-ci/165
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4001
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/3586/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3493
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4042
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4042/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3588
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3588/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/5918/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/4891

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

review: Needs Fixing (continuous-integration)
164. By Omer Akram

remove unused test code, fix things

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:164
http://jenkins.qa.ubuntu.com/job/address-book-app-ci/456/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-amd64-ci/166
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-armhf-ci/166
        deb: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-armhf-ci/166/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-i386-ci/166
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4005
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/3590/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3495
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4046
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4046/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3592
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3592/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/5922/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/4895

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

review: Needs Fixing (continuous-integration)
165. By Omer Akram

make dummy backend code reusable by other test cases

166. By Omer Akram

add docstrings for new tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:165
http://jenkins.qa.ubuntu.com/job/address-book-app-ci/458/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-amd64-ci/168
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-armhf-ci/168
        deb: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-armhf-ci/168/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-i386-ci/168
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4016
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/3601/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3507
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4057
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4057/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3603
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3603/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/5932/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/4907

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

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

FAILED: Continuous integration, rev:166
http://jenkins.qa.ubuntu.com/job/address-book-app-ci/460/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-amd64-ci/170
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-armhf-ci/170
        deb: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-armhf-ci/170/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/address-book-app-trusty-i386-ci/170
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4021
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/3606/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3512
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4062
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4062/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3608
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3608/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/5937/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/4912

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

review: Needs Fixing (continuous-integration)
167. By Omer Akram

make starting of dummy backend a reusable helper for other apps to consume

168. By Omer Akram

adapt autopilot tests to UI changes in trunk

169. By Omer Akram

merge trunk

Unmerged revisions

169. By Omer Akram

merge trunk

168. By Omer Akram

adapt autopilot tests to UI changes in trunk

167. By Omer Akram

make starting of dummy backend a reusable helper for other apps to consume

166. By Omer Akram

add docstrings for new tests

165. By Omer Akram

make dummy backend code reusable by other test cases

164. By Omer Akram

remove unused test code, fix things

163. By Omer Akram

remove syncevolution dep

162. By Omer Akram

fix pep8 and pyflakes warnings for test_favorite, did not touch other modules

161. By Omer Akram

remove unused test code

160. By Omer Akram

don't use memory backend for favorite tests, use the new dummy backend from the service

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/imports/ContactView/ContactDetailFavoriteView.qml'
--- src/imports/ContactView/ContactDetailFavoriteView.qml 2014-02-25 21:52:58 +0000
+++ src/imports/ContactView/ContactDetailFavoriteView.qml 2014-03-26 22:14:30 +0000
@@ -28,6 +28,7 @@
2828
29 Icon {29 Icon {
30 id: icon30 id: icon
31 objectName: 'favoriteIcon'
3132
32 anchors.fill: parent33 anchors.fill: parent
33 name: root.detail && root.detail.favorite ? "favorite-selected" : "favorite-unselected"34 name: root.detail && root.detail.favorite ? "favorite-selected" : "favorite-unselected"
3435
=== modified file 'src/imports/Ubuntu/Contacts/ContactListView.qml'
--- src/imports/Ubuntu/Contacts/ContactListView.qml 2014-02-25 20:20:21 +0000
+++ src/imports/Ubuntu/Contacts/ContactListView.qml 2014-03-26 22:14:30 +0000
@@ -57,6 +57,7 @@
57 anchors.fill: parent57 anchors.fill: parent
58 Label {58 Label {
59 id: lblAll59 id: lblAll
60 objectName: "labelAll"
6061
61 anchors {62 anchors {
62 top: parent.top63 top: parent.top
@@ -84,6 +85,7 @@
8485
85 Label {86 Label {
86 id: lblFavourites87 id: lblFavourites
88 objectName: "labelFavorite"
8789
88 anchors {90 anchors {
89 top: parent.top91 top: parent.top
9092
=== modified file 'tests/autopilot/address_book_app/emulators/__init__.py'
--- tests/autopilot/address_book_app/emulators/__init__.py 2013-07-09 18:42:30 +0000
+++ tests/autopilot/address_book_app/emulators/__init__.py 2014-03-26 22:14:30 +0000
@@ -4,3 +4,15 @@
4# This program is free software: you can redistribute it and/or modify it4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
7
8
9def get_nearest_parent_matching_type(child, desired_type):
10 """Climb down the widget tree, return first instance of desired_type"""
11 while type(child).__name__ != desired_type:
12 parent = child.get_parent()
13 if type(child).__name__ == 'AddressBookApp':
14 # we reached the root and found nothing
15 return None
16 else:
17 child = parent
18 return child
719
=== modified file 'tests/autopilot/address_book_app/emulators/contact_list_page.py'
--- tests/autopilot/address_book_app/emulators/contact_list_page.py 2014-02-13 16:44:12 +0000
+++ tests/autopilot/address_book_app/emulators/contact_list_page.py 2014-03-26 22:14:30 +0000
@@ -1,20 +1,24 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3""" ContactListPage emulator for Addressbook App tests """
4
5# Copyright 2014 Canonical2# Copyright 2014 Canonical
6#3#
7# This program is free software: you can redistribute it and/or modify it4# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU General Public License version 3, as published5# under the terms of the GNU General Public License version 3, as published
9# by the Free Software Foundation.6# by the Free Software Foundation.
107
8""" ContactListPage emulator for Addressbook App tests """
9
11import logging10import logging
11from time import sleep
1212
13from autopilot import logging as autopilot_logging
13from autopilot.introspection.dbus import StateNotFoundError14from autopilot.introspection.dbus import StateNotFoundError
15from autopilot.matchers import Eventually
16from testtools.matchers import GreaterThan
14from ubuntuuitoolkit import emulators as uitk17from ubuntuuitoolkit import emulators as uitk
1518
16LOGGER = logging.getLogger(__name__)19from address_book_app.emulators import get_nearest_parent_matching_type
17from time import sleep20
21logger = logging.getLogger(__name__)
1822
1923
20class ContactListPage(uitk.UbuntuUIToolkitEmulatorBase):24class ContactListPage(uitk.UbuntuUIToolkitEmulatorBase):
@@ -27,9 +31,12 @@
27 super(ContactListPage, self).__init__(*args)31 super(ContactListPage, self).__init__(*args)
2832
29 def get_contacts(self):33 def get_contacts(self):
30 """34 """Returns a list of ContactDelegate objects.
31 Returns a list of ContactDelegate objects and populate35
32 self.selection_marks36 Also populate self.selection_marks.
37
38 :return: The list of ContactDelegate objects.
39
33 """40 """
34 sleep(1)41 sleep(1)
35 self.contacts = self.select_many("ContactDelegate")42 self.contacts = self.select_many("ContactDelegate")
@@ -41,10 +48,12 @@
41 self.selection_marks.append(mark)48 self.selection_marks.append(mark)
42 return self.contacts49 return self.contacts
4350
51 @autopilot_logging.log_action(logger.info)
44 def select_contacts_by_index(self, indices):52 def select_contacts_by_index(self, indices):
45 """ Select contacts corresponding to the list of index in indices53 """Select contacts corresponding to the list of index in indices.
4654
47 :param indices: List of integers55 :param indices: List of integer indices of contacts to select.
56
48 """57 """
49 self.deselect_all()58 self.deselect_all()
5059
@@ -53,8 +62,9 @@
53 self.selected_marks.append(self.selection_marks[idx])62 self.selected_marks.append(self.selection_marks[idx])
54 self.pointing_device.click_object(self.selection_marks[idx])63 self.pointing_device.click_object(self.selection_marks[idx])
5564
65 @autopilot_logging.log_action(logger.info)
56 def deselect_all(self):66 def deselect_all(self):
57 """Deselect every contacts"""67 """Deselect every contact."""
58 contacts = self.select_many("ContactDelegate")68 contacts = self.select_many("ContactDelegate")
59 self.selected_marks = []69 self.selected_marks = []
60 for contact in contacts:70 for contact in contacts:
@@ -63,28 +73,137 @@
63 objectName="selectionMark")73 objectName="selectionMark")
64 self.pointing_device.click_object(mark)74 self.pointing_device.click_object(mark)
6575
76 @autopilot_logging.log_action(logger.info)
66 def click_button(self, objectname):77 def click_button(self, objectname):
67 """Press a button that matches objectname78 """Press a button that matches objectname
6879
69 :param objectname: Name of the object80 :param objectname: The name of the object.
81 :raise StateNotFoundError: When a matching button is not found.
82
70 """83 """
71 try:84 button = self.select_single("Button",
72 buttons = self.select_many("Button",85 objectName=objectname,
73 objectName=objectname)86 visible=True)
74 for button in buttons:87 self.pointing_device.click_object(button)
75 if button.visible:
76 self.pointing_device.click_object(button)
77 except StateNotFoundError:
78 LOGGER.error(
79 'Button with objectName "{0}" not found.'.format(objectname)
80 )
81 raise
8288
89 @autopilot_logging.log_action(logger.info)
83 def cancel(self):90 def cancel(self):
84 """Press the cancel button displayed when pick mode is enabled"""91 """Press the cancel button displayed when pick mode is enabled."""
85 self.click_button("DialogButtons.rejectButton")92 self.click_button("DialogButtons.rejectButton")
8693
94 @autopilot_logging.log_action(logger.info)
87 def delete(self):95 def delete(self):
88 """Press the delete button displayed when pick mode is enabled"""96 """Press the delete button displayed when pick mode is enabled."""
89 self.click_button("DialogButtons.acceptButton")97 self.click_button("DialogButtons.acceptButton")
90 self.get_contacts()98 self.get_contacts()
99
100 def get_contact_by_name(self,
101 contact_name,
102 parent_delegate_type='ContactDelegate'):
103 """Find a label with text matching contact name.
104
105 :param contact_name: The name of the contact, e.g. 'Fulano de Tal'.
106 :param parent_delegate_type: 'ContactDelegate' or 'FavoriteDelegate'.
107 :return: The label for a matching contact.
108 :raises StateNotFoundError: If the contact_name is not found.
109
110 """
111 try:
112 assert(lambda: len(self.select_many("Label",
113 text=contact_name)),
114 Eventually(GreaterThan(0)))
115 contact_name_labels = self.select_many(
116 "Label",
117 text=contact_name)
118 for contact_name_label in contact_name_labels:
119 # we could have a contact or a favorite
120 if get_nearest_parent_matching_type(
121 contact_name_label,
122 parent_delegate_type):
123 return contact_name_label
124 raise StateNotFoundError('Label')
125 except StateNotFoundError:
126 logger.error("Contact {} not found.".format(contact_name))
127 raise
128
129 def get_favorite_by_name(self, contact_name):
130 """Find a label with text matching contact name under Favorites.
131
132 :param contact_name: Name of the contact, e.g. 'Fulano de Tal'.
133 :return: The label for the metching favorite.
134 :raises StateNotFoundError: If the contact_name is not found.
135
136 """
137 return self.get_contact_by_name(contact_name).visible
138
139 @autopilot_logging.log_action(logger.info)
140 def click_contact_by_name(self,
141 contact_name,
142 parent_delegate_type='ContactDelegate'):
143 """Click a contact with label matching the given contact name.
144
145 :param contact_name: Name of a contact, e.g. 'Fulano de Tal'.
146 :param parent_delegate_type: 'ContactDelegate' or 'FavoriteDelegate'.
147 :raises StateNotFoundError: If the contact_name is not found.
148
149 """
150 contact_name_label = self.get_contact_by_name(
151 contact_name, parent_delegate_type)
152 self.pointing_device.click_object(contact_name_label)
153
154 @autopilot_logging.log_action(logger.info)
155 def open_contact_view_by_contact_name(self, contact_name):
156 """Open the contact view page for a contact with the given name.
157
158 :param contact_name: The name of the contact, e.g. 'Abe Lincoln'.
159 :return: The ContactView for the contact.
160 :raises StateNotFoundError: If the name is not found.
161
162 """
163 self.click_contact_by_name(contact_name)
164
165 @autopilot_logging.log_action(logger.info)
166 def click_favorite_by_name(self,
167 contact_name):
168 """Click a favorite with label matching the given contact name.
169
170 :param contact_name: Name of a contact, e.g. 'Fulano de Tal'
171 :raises StateNotFoundError: If the contact_name is not found.
172
173 """
174 contact_name_label = self.get_favorite_by_name(
175 contact_name)
176 self.pointing_device.click_object(contact_name_label)
177
178 @autopilot_logging.log_action(logger.info)
179 def open_contact_view_by_favorite_name(self, favorite_name):
180 """Open the contact view page for a favorite with the given name.
181
182 :param favorite_name: The name of the favorite, e.g. 'Abe Lincoln'.
183 :return: The ContactView for the contact.
184 :raises StateNotFoundError: If the name is not found.
185
186 """
187 self.click_favorite_by_name(favorite_name)
188
189 @autopilot_logging.log_action(logger.info)
190 def click_phone_number(self, phone_number):
191 """Click a label matching the given phone number.
192
193 :param phone_number: A phone number, e.g. '3321 1232'.
194 :raises StateNotFoundError: If the phone_number is not found.
195
196 """
197 phone_number_label = self.wait_select_single('Label',
198 text=phone_number)
199 self.pointing_device.click_object(phone_number_label)
200
201 def contact_is_favorite(self, name):
202 """Is the given contact name a favorite?
203
204 :param contact_name: The name of a contact e.g. John.
205 :raises StateNotFoundError: If the contact name is not found.
206 :returns: Boolean.
207
208 """
209 self.open_contact_view_by_contact_name(name)
91210
=== added file 'tests/autopilot/address_book_app/emulators/contact_view.py'
--- tests/autopilot/address_book_app/emulators/contact_view.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/address_book_app/emulators/contact_view.py 2014-03-26 22:14:30 +0000
@@ -0,0 +1,57 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2014 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
7
8""" ContactView emulator for Addressbook App tests """
9
10import logging
11
12from autopilot import logging as autopilot_logging
13from autopilot.introspection.dbus import StateNotFoundError
14from ubuntuuitoolkit import emulators as uitk
15
16logger = logging.getLogger(__name__)
17
18
19class ContactView(uitk.UbuntuUIToolkitEmulatorBase):
20 """ContactView emulator class"""
21
22 def __init__(self, *args):
23 super(ContactView, self).__init__(*args)
24
25 @autopilot_logging.log_action(logger.info)
26 def click_button(self, objectname):
27 """Press a button that matches objectname.
28
29 :param objectname: The name of the object.
30 :raises StateNotFoundError: If the matching object is not found.
31
32 """
33 buttons = self.select_single("Button",
34 objectName=objectname,
35 visible=True)
36 self.pointing_device.click_object(button)
37
38 @autopilot_logging.log_action(logger.info)
39 def cancel(self):
40 """Press the cancel button displayed when pick mode is enabled."""
41 self.click_button("DialogButtons.rejectButton")
42
43 @autopilot_logging.log_action(logger.info)
44 def delete(self):
45 """Press the delete button displayed when pick mode is enabled."""
46 self.click_button("DialogButtons.acceptButton")
47 self.get_contacts()
48
49 def favorite_icon(self):
50 return self.wait_select_single('Icon', objectName='favoriteIcon')
51
52 @autopilot_logging.log_action(logger.info)
53 def click_favorite_icon(self):
54 """Tap/click on the favorite icon to make a contact favorite."""
55 favorite_icon = self.favorite_icon()
56
57 self.pointing_device.click_object(favorite_icon)
058
=== modified file 'tests/autopilot/address_book_app/emulators/main_window.py'
--- tests/autopilot/address_book_app/emulators/main_window.py 2014-02-28 16:00:02 +0000
+++ tests/autopilot/address_book_app/emulators/main_window.py 2014-03-26 22:14:30 +0000
@@ -21,7 +21,7 @@
2121
22 def get_contact_list_page(self):22 def get_contact_list_page(self):
23 return self. wait_select_single("ContactListPage",23 return self. wait_select_single("ContactListPage",
24 objectName="contactListPage")24 objectName="contactListPage")
2525
26 def get_contact_edit_page(self):26 def get_contact_edit_page(self):
27 return self.wait_select_single(ContactEditor,27 return self.wait_select_single(ContactEditor,
@@ -43,7 +43,7 @@
43 """43 """
44 Returns a ContactListView iobject for the current window44 Returns a ContactListView iobject for the current window
45 """45 """
46 return self.wait_select_single( "ContactListView",46 return self.wait_select_single("ContactListView",
47 objectName="contactListView")47 objectName="contactListView")
4848
49 def get_button(self, name):49 def get_button(self, name):
@@ -53,7 +53,7 @@
53 Arguments:53 Arguments:
54 name: Name of the button54 name: Name of the button
55 """55 """
56 return self.wait_select_single( "Button", objectName=name)56 return self.wait_select_single("Button", objectName=name)
5757
58 def cancel(self):58 def cancel(self):
59 """59 """
@@ -67,6 +67,30 @@
67 """67 """
68 self.pointing_device.click_object(self.get_button("accept"))68 self.pointing_device.click_object(self.get_button("accept"))
6969
70 def _get_label(self, name):
71 """
72 Returns a Label object matching 'name'
73
74 Arguments:
75 name: objectName of the label
76 """
77 return self.wait_select_single('Label', objectName=name, visible=True)
78
79 def switch_to_favorites(self):
80 """
81 switch to the favorite contacts view
82 """
83 self.pointing_device.click_object(self._get_label('labelFavorite'))
84
85 def switch_to_all_contact(self):
86 """
87 Switch to all contacts view
88 """
89 self.pointing_device.click_object(self._get_label('labelAll'))
90
91 def are_favorites_shown(self):
92 return self.get_contact_list_view().showFavourites
93
70 @autopilot_logging.log_action(logger.info)94 @autopilot_logging.log_action(logger.info)
71 def go_to_add_contact(self):95 def go_to_add_contact(self):
72 """96 """
7397
=== added file 'tests/autopilot/address_book_app/helpers.py'
--- tests/autopilot/address_book_app/helpers.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/address_book_app/helpers.py 2014-03-26 22:14:30 +0000
@@ -0,0 +1,74 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2014 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
7
8import subprocess
9
10from autopilot.testcase import AutopilotTestCase
11from autopilot.matchers import Eventually
12from testtools.matchers import Equals
13
14import dbus
15
16DUMMY_BACKEND_ADDRESS = 'com.canonical.test.pim'
17
18
19class DummyServiceBackendSetup(AutopilotTestCase):
20
21 def _set_contact_service_dummy_backend_environment_variables(self):
22 self.patch_environment(
23 'CANONICAL_PIN_SERVICE_NAME', DUMMY_BACKEND_ADDRESS
24 )
25 self.patch_environment(
26 'FOLKS_BACKEND_PATH', self._get_dummy_backend_so_location()
27 )
28 self.patch_environment('FOLKS_BACKENDS_ALLOWED', 'dummy')
29 self.patch_environment('FOLKS_PRIMARY_STORE', 'dummy')
30
31 def _get_dummy_backend_so_location(self):
32 output = subprocess.check_output(
33 ['locate', '/usr/lib', '--basename', 'dummy.so']
34 ).split()
35
36 if len(output) is 1:
37 return output[0]
38 elif len(output) > 1:
39 for path in output:
40 if 'address-book-service' in path:
41 return path
42 else:
43 raise RuntimeError(
44 'Dummy backend .so not found is address-book-service-dummy'
45 'installed ?'
46 )
47
48 def _get_address_book_service_binary_location(self):
49 output = subprocess.check_output(
50 ['locate', '/usr/lib', '--basename', 'address-book-service']
51 ).split()
52
53 for path in output:
54 if 'address-book-service/address-book-service' in path:
55 return path
56
57 def _start_service_dummy_backend(self):
58 self.service = subprocess.Popen(
59 [self._get_address_book_service_binary_location()]
60 )
61 self.addCleanup(self.service.kill)
62
63 self.assertThat(
64 lambda: self._is_dummy_backend_up(), Eventually(Equals(True))
65 )
66
67 def _is_dummy_backend_up(self):
68 interfaces = dbus.SessionBus().list_names()
69
70 return DUMMY_BACKEND_ADDRESS in interfaces
71
72 def ensure_dummy_service_backend_running(self):
73 self._set_contact_service_dummy_backend_environment_variables()
74 self._start_service_dummy_backend()
075
=== modified file 'tests/autopilot/address_book_app/tests/__init__.py'
--- tests/autopilot/address_book_app/tests/__init__.py 2014-01-30 08:35:04 +0000
+++ tests/autopilot/address_book_app/tests/__init__.py 2014-03-26 22:14:30 +0000
@@ -18,6 +18,7 @@
18from testtools.matchers import Equals18from testtools.matchers import Equals
1919
20from address_book_app.emulators.main_window import MainWindow20from address_book_app.emulators.main_window import MainWindow
21
21from ubuntuuitoolkit import emulators as toolkit_emulators22from ubuntuuitoolkit import emulators as toolkit_emulators
2223
2324
@@ -31,6 +32,7 @@
31 VCARD_PATH_DEV = os.path.abspath("../data/vcard.vcf")32 VCARD_PATH_DEV = os.path.abspath("../data/vcard.vcf")
32 ARGS = []33 ARGS = []
33 PRELOAD_VCARD = False34 PRELOAD_VCARD = False
35 QTCONTACTS_MANAGER_OVERRIDE_MEMORY = True
3436
35 def setUp(self):37 def setUp(self):
36 self.pointing_device = toolkit_emulators.get_pointing_device()38 self.pointing_device = toolkit_emulators.get_pointing_device()
@@ -45,8 +47,17 @@
45 else:47 else:
46 self.app_bin = AddressBookAppTestCase.DEFAULT_DEV_LOCATION48 self.app_bin = AddressBookAppTestCase.DEFAULT_DEV_LOCATION
4749
48 os.environ['QTCONTACTS_MANAGER_OVERRIDE'] = 'memory'50 print "Running from: %s" % (self.app_bin)
51 # NOTE defeats favoriting: contacts don't show up in "Favorites" header
52 if AddressBookAppTestCase.QTCONTACTS_MANAGER_OVERRIDE_MEMORY:
53 os.environ['QTCONTACTS_MANAGER_OVERRIDE'] = 'memory'
54 else:
55 try:
56 del(os.environ['QTCONTACTS_MANAGER_OVERRIDE'])
57 except KeyError:
58 pass
49 vcard_data = ""59 vcard_data = ""
60
50 if AddressBookAppTestCase.PRELOAD_VCARD:61 if AddressBookAppTestCase.PRELOAD_VCARD:
51 # Use vcard from source tree and fallback on installed vcard (from62 # Use vcard from source tree and fallback on installed vcard (from
52 # address-book-app-autopilot package)63 # address-book-app-autopilot package)
@@ -55,16 +66,16 @@
55 else:66 else:
56 vcard_data = AddressBookAppTestCase.VCARD_PATH_BIN67 vcard_data = AddressBookAppTestCase.VCARD_PATH_BIN
5768
58 os.environ["ADDRESS_BOOK_TEST_DATA"] = vcard_data69 os.environ['ADDRESS_BOOK_TEST_DATA'] = vcard_data
59 if vcard_data != "": print "Using vcard %s" % vcard_data70 if vcard_data != '': print 'Using vcard %s' % vcard_data
60 if os.path.exists(self.app_bin):71 if os.path.exists(self.app_bin):
61 print "Running from: %s" % (self.app_bin)72 print 'Running from: %s' % (self.app_bin)
62 self.launch_test_local()73 self.launch_test_local()
63 elif os.path.exists(self.DEB_LOCALTION):74 elif os.path.exists(self.DEB_LOCALTION):
64 print "Running from: %s" % (self.DEB_LOCALTION)75 print 'Running from: %s' % (self.DEB_LOCALTION)
65 self.launch_test_installed()76 self.launch_test_installed()
66 else:77 else:
67 print "Running from click package: address-book-app"78 print 'Running from click package: address-book-app'
68 self.launch_click_installed()79 self.launch_click_installed()
6980
70 AddressBookAppTestCase.ARGS = []81 AddressBookAppTestCase.ARGS = []
7182
=== modified file 'tests/autopilot/address_book_app/tests/test_add_contact.py'
--- tests/autopilot/address_book_app/tests/test_add_contact.py 2014-02-28 15:36:09 +0000
+++ tests/autopilot/address_book_app/tests/test_add_contact.py 2014-03-26 22:14:30 +0000
@@ -20,6 +20,10 @@
20class TestAddContact(AddressBookAppTestCase):20class TestAddContact(AddressBookAppTestCase):
21 """ Tests the Add contact """21 """ Tests the Add contact """
2222
23 def setUp(self):
24 AddressBookAppTestCase.QTCONTACTS_MANAGER_OVERRIDE_MEMORY = True
25 super(TestAddContact, self).setUp()
26
23 def test_go_to_add_contact(self):27 def test_go_to_add_contact(self):
24 """Test to launch the add contact screen using emulator method"""28 """Test to launch the add contact screen using emulator method"""
25 self.assertRaises(29 self.assertRaises(
2630
=== modified file 'tests/autopilot/address_book_app/tests/test_contactlist.py'
--- tests/autopilot/address_book_app/tests/test_contactlist.py 2013-11-21 18:53:19 +0000
+++ tests/autopilot/address_book_app/tests/test_contactlist.py 2014-03-26 22:14:30 +0000
@@ -18,6 +18,10 @@
18class TestContactList(AddressBookAppTestCase):18class TestContactList(AddressBookAppTestCase):
19 """Tests the contact list features"""19 """Tests the contact list features"""
2020
21 def setUp(self):
22 AddressBookAppTestCase.QTCONTACTS_MANAGER_OVERRIDE_MEMORY = True
23 super(TestContactList, self).setUp()
24
21 def test_contact_list(self):25 def test_contact_list(self):
22 contact_list = self.main_window.get_contact_list_page()26 contact_list = self.main_window.get_contact_list_page()
23 self.assertThat(contact_list.visible, Eventually(Equals(True)))27 self.assertThat(contact_list.visible, Eventually(Equals(True)))
2428
=== modified file 'tests/autopilot/address_book_app/tests/test_delete_contact.py'
--- tests/autopilot/address_book_app/tests/test_delete_contact.py 2014-02-13 16:44:12 +0000
+++ tests/autopilot/address_book_app/tests/test_delete_contact.py 2014-03-26 22:14:30 +0000
@@ -40,6 +40,7 @@
40 ]40 ]
4141
42 def setUp(self):42 def setUp(self):
43 AddressBookAppTestCase.QTCONTACTS_MANAGER_OVERRIDE_MEMORY = True
43 AddressBookAppTestCase.PRELOAD_VCARD = True44 AddressBookAppTestCase.PRELOAD_VCARD = True
44 super(TestDeleteSelectContact, self).setUp()45 super(TestDeleteSelectContact, self).setUp()
4546
4647
=== modified file 'tests/autopilot/address_book_app/tests/test_edit_contact.py'
--- tests/autopilot/address_book_app/tests/test_edit_contact.py 2014-03-18 21:13:04 +0000
+++ tests/autopilot/address_book_app/tests/test_edit_contact.py 2014-03-26 22:14:30 +0000
@@ -17,6 +17,10 @@
17class TestEditContact(AddressBookAppTestCase):17class TestEditContact(AddressBookAppTestCase):
18 """Tests edit a contact"""18 """Tests edit a contact"""
1919
20 def setUp(self):
21 AddressBookAppTestCase.QTCONTACTS_MANAGER_OVERRIDE_MEMORY = True
22 super(TestEditContact, self).setUp()
23
20 def test_add_new_phone(self):24 def test_add_new_phone(self):
21 self.add_contact("Fulano", "de Tal", ["3321 2300"])25 self.add_contact("Fulano", "de Tal", ["3321 2300"])
22 edit_page = self.edit_contact(0)26 edit_page = self.edit_contact(0)
2327
=== added file 'tests/autopilot/address_book_app/tests/test_favorites.py'
--- tests/autopilot/address_book_app/tests/test_favorites.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/address_book_app/tests/test_favorites.py 2014-03-26 22:14:30 +0000
@@ -0,0 +1,96 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2014 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
7
8"""Tests of favoriting contacts for the Addressbook App"""
9
10from __future__ import absolute_import
11
12import subprocess
13
14from autopilot.introspection.dbus import StateNotFoundError
15from autopilot.matchers import Eventually
16from testtools.matchers import Equals
17
18from address_book_app.helpers import DummyServiceBackendSetup
19from address_book_app.tests import AddressBookAppTestCase
20from address_book_app.emulators.contact_list_page import ContactListPage
21from address_book_app.emulators.contact_view import ContactView
22
23
24class TestFavorite(AddressBookAppTestCase, DummyServiceBackendSetup):
25 """Test for favoriting contacts"""
26
27 def setUp(self):
28 AddressBookAppTestCase.QTCONTACTS_MANAGER_OVERRIDE_MEMORY = False
29 AddressBookAppTestCase.PRELOAD_VCARD = True
30 self.ensure_dummy_service_backend_running()
31 super(TestFavorite, self).setUp()
32
33 def _add_contact_as_favorite(self, name):
34 contact_list_page = self.main_window.get_contact_list_page()
35 contact_list_page.open_contact_view_by_contact_name(name)
36 contact_view = self.main_window.get_contact_view_page()
37 contact_view.click_favorite_icon()
38 self.main_window.go_back()
39 self._ensure_favorites_shown()
40
41 return contact_list_page
42
43 def _ensure_favorites_shown(self):
44 if not self.main_window.are_favorites_shown():
45 self.main_window.switch_to_favorites()
46 self.main_window.are_favorites_shown().wait_for(True)
47
48 def is_contact_favorite(self, name):
49 contact_list_page = self.main_window.get_contact_list_page()
50 contact_list_page.open_contact_view_by_contact_name(name)
51
52 contact_view = self.main_window.get_contact_view_page()
53 favorite_icon = contact_view.favorite_icon()
54
55 if favorite_icon.name == 'favorite-selected':
56 return True
57 else:
58 return False
59
60 def test_add_favorite(self):
61 """Ensure a contact can be made a favorite."""
62 self._add_contact_as_favorite('teste test34')
63
64 self.assertTrue(self.is_contact_favorite('teste test34'))
65
66 def test_save_multiple_favorites(self):
67 """Ensure multiple contacts can be made favorites."""
68 self._add_contact_as_favorite('teste test34')
69 self.assertTrue(self.is_contact_favorite('teste test34'))
70
71 self.main_window.go_back()
72 self.main_window.switch_to_all_contact()
73
74 contact_list_page = self._add_contact_as_favorite('teste teste2')
75 self.assertTrue(self.is_contact_favorite('teste teste2'))
76
77 def test_remove_favorite(self):
78 """Ensure an already favorite contact can be un-favorited."""
79 contact_list_page = self._add_contact_as_favorite('teste test34')
80 contact_list_page.open_contact_view_by_contact_name('teste test34')
81 contact_view = self.main_window.get_contact_view_page()
82 contact_view.click_favorite_icon()
83
84 self.assertFalse(contact_list_page.get_favorite_by_name('teste test34'))
85
86 def test_delete_favorite(self):
87 """Ensure deleting a favorite contact also removes it from favorite
88 category."""
89 contact_list_page = self._add_contact_as_favorite('teste test34')
90 contact_list_page.open_contact_view_by_contact_name('teste test34')
91 toolbar = self.main_window.open_toolbar()
92 toolbar.click_button('delete')
93
94 self.assertRaises(
95 StateNotFoundError,
96 lambda: contact_list_page.get_favorite_by_name('teste test34'))
097
=== modified file 'tests/autopilot/address_book_app/tests/test_multiple_pick_mode.py'
--- tests/autopilot/address_book_app/tests/test_multiple_pick_mode.py 2013-12-13 19:31:33 +0000
+++ tests/autopilot/address_book_app/tests/test_multiple_pick_mode.py 2014-03-26 22:14:30 +0000
@@ -20,6 +20,7 @@
2020
21 def setUp(self):21 def setUp(self):
22 self.ARGS.append("addressbook:///pick?single=false")22 self.ARGS.append("addressbook:///pick?single=false")
23 AddressBookAppTestCase.QTCONTACTS_MANAGER_OVERRIDE_MEMORY = True
23 AddressBookAppTestCase.PRELOAD_VCARD = True24 AddressBookAppTestCase.PRELOAD_VCARD = True
24 super(TestMultiplePickerMode, self).setUp()25 super(TestMultiplePickerMode, self).setUp()
2526
2627
=== modified file 'tests/autopilot/address_book_app/tests/test_single_pick_mode.py'
--- tests/autopilot/address_book_app/tests/test_single_pick_mode.py 2013-12-13 19:31:33 +0000
+++ tests/autopilot/address_book_app/tests/test_single_pick_mode.py 2014-03-26 22:14:30 +0000
@@ -21,6 +21,7 @@
21 def setUp(self):21 def setUp(self):
22 AddressBookAppTestCase.ARGS.append("addressbook:///pick?single=true")22 AddressBookAppTestCase.ARGS.append("addressbook:///pick?single=true")
23 AddressBookAppTestCase.PRELOAD_VCARD = True23 AddressBookAppTestCase.PRELOAD_VCARD = True
24 AddressBookAppTestCase.QTCONTACTS_MANAGER_OVERRIDE_MEMORY = True
24 super(TestSinglePickerMode, self).setUp()25 super(TestSinglePickerMode, self).setUp()
2526
26 def test_select_single_contact(self):27 def test_select_single_contact(self):

Subscribers

People subscribed via source and target branches

to all changes: