Merge lp:~elopio/address-book-app/refactoring_tests1 into lp:address-book-app

Proposed by Leo Arias
Status: Superseded
Proposed branch: lp:~elopio/address-book-app/refactoring_tests1
Merge into: lp:address-book-app
Prerequisite: lp:~renatofilho/address-book-app/new-header
Diff against target: 1505 lines (+527/-519) (has conflicts)
19 files modified
tests/autopilot/address_book_app/__init__.py (+0/-8)
tests/autopilot/address_book_app/_errors.py (+21/-0)
tests/autopilot/address_book_app/emulators/__init__.py (+0/-6)
tests/autopilot/address_book_app/emulators/main_window.py (+0/-376)
tests/autopilot/address_book_app/emulators/page_with_bottom_edge.py (+0/-40)
tests/autopilot/address_book_app/pages/__init__.py (+25/-0)
tests/autopilot/address_book_app/pages/_common.py (+53/-0)
tests/autopilot/address_book_app/pages/_contact_editor.py (+272/-0)
tests/autopilot/address_book_app/pages/_contact_list_page.py (+35/-14)
tests/autopilot/address_book_app/pages/_contact_view.py (+28/-0)
tests/autopilot/address_book_app/tests/__init__.py (+7/-5)
tests/autopilot/address_book_app/tests/test_add_contact.py (+38/-36)
tests/autopilot/address_book_app/tests/test_contactlist.py (+1/-1)
tests/autopilot/address_book_app/tests/test_create_new_from_uri.py (+9/-9)
tests/autopilot/address_book_app/tests/test_custom_proxy_objects.py (+1/-3)
tests/autopilot/address_book_app/tests/test_delete_contact.py (+4/-4)
tests/autopilot/address_book_app/tests/test_edit_contact.py (+31/-15)
tests/autopilot/address_book_app/tests/test_multiple_pick_mode.py (+1/-1)
tests/autopilot/address_book_app/tests/test_single_pick_mode.py (+1/-1)
Text conflict in src/imports/ContactEdit/ContactDetailSyncTargetEditor.qml
Text conflict in src/imports/ContactEdit/TextInputDetail.qml
Text conflict in src/imports/Ubuntu/Contacts/ContactSimpleListView.qml
To merge this branch: bzr merge lp:~elopio/address-book-app/refactoring_tests1
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+220654@code.launchpad.net

This proposal has been superseded by a proposal from 2014-05-23.

To post a comment you must log in.
229. By Leo Arias

Merged with prerequisite.

230. By Leo Arias

Removed an unused import.

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

could you resubmit this proposal against the lp:~phablet-team/address-book-app/staging

231. By Leo Arias

Merged with prerequisite.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== removed file 'tests/autopilot/address_book_app/__init__.py'
--- tests/autopilot/address_book_app/__init__.py 2013-07-09 18:42:30 +0000
+++ tests/autopilot/address_book_app/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013 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"""address-book-app autopilot tests and emulators - top level package."""
90
=== added file 'tests/autopilot/address_book_app/_errors.py'
--- tests/autopilot/address_book_app/_errors.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/address_book_app/_errors.py 2014-05-22 14:40:49 +0000
@@ -0,0 +1,21 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2014 Canonical Ltd.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17import ubuntuuitoolkit
18
19
20class AddressBookAppError(ubuntuuitoolkit.ToolkitException):
21 """Exception raised when there is an error with the emulator."""
022
=== removed directory 'tests/autopilot/address_book_app/emulators'
=== removed 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 1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013 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.
70
=== removed file 'tests/autopilot/address_book_app/emulators/main_window.py'
--- tests/autopilot/address_book_app/emulators/main_window.py 2014-05-22 14:40:49 +0000
+++ tests/autopilot/address_book_app/emulators/main_window.py 1970-01-01 00:00:00 +0000
@@ -1,376 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013, 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 collections
9import logging
10import time
11
12from autopilot import logging as autopilot_logging
13from autopilot.introspection.dbus import StateNotFoundError
14from ubuntuuitoolkit import emulators as uitk
15from address_book_app import data
16from address_book_app.emulators.page_with_bottom_edge import ContactListPage
17
18
19logger = logging.getLogger(__name__)
20
21
22_TEXT_FIELD_OBJECT_NAMES = {
23 'first_name': 'firstName',
24 'last_name': 'lastName',
25 'street': 'streetAddress_{}',
26 'locality': 'localityAddress_{}',
27 'region': 'regionAddress_{}',
28 'postal_code': 'postcodeAddress_{}',
29 'country': 'countryAddress_{}'
30}
31
32
33def _get_text_field(parent, field, index=None):
34 if field not in _TEXT_FIELD_OBJECT_NAMES:
35 raise AddressBookAppError('Unknown field: {}.'.format(field))
36
37 object_name = _TEXT_FIELD_OBJECT_NAMES[field]
38 if index is not None:
39 object_name = object_name.format(index)
40 return parent.select_single(TextInputDetail, objectName=object_name)
41
42
43class AddressBookAppError(uitk.ToolkitEmulatorException):
44 """Exception raised when there is an error with the emulator."""
45
46
47class MainWindow(uitk.MainView):
48 """An emulator class that makes it easy to interact with the app."""
49
50 def get_contact_list_page(self):
51 # ContactListPage is the only page that can appears multiple times
52 # Ex.: During the pick mode we alway push a new contactListPage, to
53 # preserve the current application status.
54 pages = self.select_many(ContactListPage,
55 objectName="contactListPage")
56
57 # alway return the page without pickMode
58 for p in pages:
59 if not p.pickMode:
60 return p
61 return None
62
63 def get_contact_edit_page(self):
64 # We can have two contact editor page because of bottom edge page
65 # but we will return only the actived one
66 list_page = self.get_contact_list_page()
67 list_page.bottomEdgePageLoaded.wait_for(True)
68 pages = self.select_many(ContactEditor,
69 objectName="contactEditorPage")
70 for p in pages:
71 if p.active:
72 return p
73 raise StateNotFoundError('contactEditorPage not found')
74 return None
75
76
77 def get_contact_view_page(self):
78 return self.wait_select_single("ContactView",
79 objectName="contactViewPage")
80
81 def get_contact_list_pick_page(self):
82 pages = self.select_many("ContactListPage",
83 objectName="contactListPage")
84 for p in pages:
85 if p.pickMode:
86 return p
87 return None
88
89 def get_contact_list_view(self):
90 """
91 Returns a ContactListView iobject for the current window
92 """
93 return self.wait_select_single("ContactListView",
94 objectName="contactListView")
95
96 def get_button(self, buttonName):
97 return self.get_header()._get_action_button(buttonName)
98
99 def open_header(self):
100 header = self.get_header()
101 if (header.y != 0):
102 edit_page = self.get_contact_edit_page()
103 flickable = edit_page.wait_select_single(
104 "QQuickFlickable",
105 objectName="scrollArea")
106
107 while (header.y != 0):
108 globalRect = flickable.globalRect
109 start_x = globalRect.x + (globalRect.width * 0.5)
110 start_y = globalRect.y + (flickable.height * 0.1)
111 stop_y = start_y + (flickable.height * 0.1)
112
113 self.pointing_device.drag(start_x, start_y, start_x, stop_y, rate=5)
114 # wait flicking stops to move to the next field
115 flickable.flicking.wait_for(False)
116
117 return header
118
119 def cancel(self):
120 """
121 Press the 'Cancel' button
122 """
123 header = self.open_header()
124 header.click_custom_back_button()
125
126 def save(self):
127 """
128 Press the 'Save' button
129 """
130 bottom_swipe_page = self.get_contact_list_page()
131 self.click_action_button("save")
132 bottom_swipe_page.isCollapsed.wait_for(True)
133
134 def done_selection(self):
135 """
136 Press the 'doneSelection' button
137 """
138 bottom_swipe_page = self.get_contact_list_page()
139 self.click_action_button("doneSelection")
140 bottom_swipe_page.isCollapsed.wait_for(True)
141
142 def get_toolbar(self):
143 """Override base class so we get our expected Toolbar subclass."""
144 return self.select_single(Toolbar)
145
146 @autopilot_logging.log_action(logger.info)
147 def go_to_add_contact(self):
148 """
149 Press the 'Add' button and return the contact editor page
150 """
151 bottom_swipe_page = self.get_contact_list_page()
152 bottom_swipe_page.revel_bottom_edge_page()
153 return self.get_contact_edit_page()
154
155
156class ContactEditor(uitk.UbuntuUIToolkitEmulatorBase):
157 """Custom proxy object for the Contact Editor."""
158
159 @autopilot_logging.log_action(logger.info)
160 def fill_form(self, contact_information):
161 """Fill the edit contact form.
162
163 :param contact_information: Values of the contact to fill the form.
164 :type contact_information: data object with the attributes first_name,
165 last_name, phones, emails, social_aliases, addresses and
166 professional_details
167
168 """
169 if contact_information.first_name is not None:
170 self._fill_first_name(contact_information.first_name)
171 if contact_information.last_name is not None:
172 self._fill_last_name(contact_information.last_name)
173
174 groups = collections.OrderedDict()
175 groups['phones'] = contact_information.phones
176 groups['emails'] = contact_information.emails
177 groups['ims'] = contact_information.social_aliases
178 groups['addresses'] = contact_information.addresses
179 groups['professionalDetails'] = (
180 contact_information.professional_details)
181
182 for key, information in groups.items():
183 if information:
184 self._fill_detail_group(
185 object_name=key, details=information)
186
187 def _fill_first_name(self, first_name):
188 text_field = _get_text_field(self, 'first_name')
189 text_field.write(first_name)
190
191 def _fill_last_name(self, last_name):
192 text_field = _get_text_field(self, 'last_name')
193 text_field.write(last_name)
194
195 def _fill_detail_group(self, object_name, details):
196 editor = self.select_single(
197 ContactDetailGroupWithTypeEditor, objectName=object_name)
198 editor.fill(details)
199
200 def _get_form_values(self):
201 first_name = _get_text_field(self, 'first_name').text
202 last_name = _get_text_field(self, 'last_name').text
203 phones = self._get_values_from_detail_group(object_name='phones')
204 emails = self._get_values_from_detail_group(object_name='emails')
205 social_aliases = self._get_values_from_detail_group(object_name='ims')
206 addresses = self._get_values_from_detail_group(object_name='addresses')
207 professional_details = self._get_values_from_detail_group(
208 object_name='professionalDetails')
209
210 return data.Contact(
211 first_name=first_name, last_name=last_name, phones=phones,
212 emails=emails, social_aliases=social_aliases, addresses=addresses,
213 professional_details=professional_details)
214
215 def _get_values_from_detail_group(self, object_name):
216 editor = self.select_single(
217 ContactDetailGroupWithTypeEditor, objectName=object_name)
218 return editor.get_values(object_name)
219
220 def wait_to_stop_moving(self):
221 flickable = self.select_single(
222 'QQuickFlickable', objectName='scrollArea')
223 flickable.flicking.wait_for(False)
224
225
226class TextInputDetail(uitk.TextField):
227 """Custom proxy object for the Text Input Detail field."""
228
229
230class ContactDetailGroupWithTypeEditor(uitk.UbuntuUIToolkitEmulatorBase):
231 """Custom proxy object for the ContactDetailGroupWithTypeEditor widget."""
232
233 _DETAIL_EDITORS = {
234 'phones': 'base_phoneNumber_{}',
235 'emails': 'base_email_{}',
236 'ims': 'base_onlineAccount_{}',
237 'addresses': 'base_address_{}',
238 # FIXME fix the unknown. --elopio - 2014-03-01
239 'professionalDetails': 'base_unknown_{}'
240 }
241
242 def fill(self, details):
243 """Fill a contact detail group."""
244 for index, detail in enumerate(details[:-1]):
245 self._fill_detail(index, detail)
246 self._add_detail()
247 self._fill_detail(len(details) - 1, details[-1])
248
249 def _fill_detail(self, index, detail):
250 detail_editor = self._get_detail_editor_by_index(index)
251 detail_editor.fill(field=self.objectName, index=index, detail=detail)
252
253 def _get_detail_editor_by_index(self, index):
254 object_name = self._get_contact_detail_editor_object_name(index)
255 return self.select_single(
256 ContactDetailWithTypeEditor, objectName=object_name)
257
258 def _get_contact_detail_editor_object_name(self, index):
259 return self._DETAIL_EDITORS[self.objectName].format(index)
260
261 def _add_detail(self):
262 # TODO --elopio - 2014-03-01
263 raise NotImplementedError('Add extra details not yet implemented.')
264
265 def get_values(self, object_name):
266 """Return the values of a contact detail group."""
267 values = []
268 for index in range(self.detailsCount):
269 detail_editor = self._get_detail_editor_by_index(index)
270 value = detail_editor.get_values(field=object_name, index=index)
271 if (value):
272 values.append(value)
273
274 return values
275
276
277class ContactDetailWithTypeEditor(uitk.UbuntuUIToolkitEmulatorBase):
278 """Custom proxy object for the ContactDetailWithTypeEditor widget."""
279
280 def __init__(self, *args):
281 super(ContactDetailWithTypeEditor, self).__init__(*args)
282 self.main_view = self.get_root_instance().select_single(MainWindow)
283
284 def fill(self, field, index, detail):
285 self._select_type(detail)
286 self._fill_value(field, index, detail)
287
288 def _select_type(self, detail):
289 type_index = detail.TYPES.index(detail.type)
290 selected_type_index = self._get_selected_type_index()
291 if type_index != selected_type_index:
292 # TODO --elopio - 2014-03-01
293 raise NotImplementedError('Type selection not yet implemented.')
294
295 def _get_selected_type_index(self):
296 value_selector = self.select_single('ValueSelector')
297 return value_selector.currentIndex
298
299 def _fill_value(self, field, index, detail):
300 single_values = {
301 'phones': 'number',
302 'emails': 'address',
303 'ims': 'alias'
304 }
305 if field in single_values:
306 self._fill_single_field(getattr(detail, single_values[field]))
307 elif field == 'addresses':
308 self._fill_address(index, detail)
309 elif field == 'professionalDetails':
310 self._fill_professional_details(index, detail)
311 else:
312 raise AddressBookAppError('Unknown field: {}.'.format(field))
313
314 def _fill_single_field(self, value):
315 text_field = self.select_single(TextInputDetail)
316 self._make_field_visible_and_write(text_field, value)
317
318 def _make_field_visible_and_write(self, text_field, value):
319 while not text_field.activeFocus:
320 # XXX We should just swipe the text field into view.
321 # Update this once bug http://pad.lv/1286479 is implemented.
322 # --elopio - 2014-03-01
323 text_field.keyboard.press_and_release('Tab')
324 time.sleep(0.1)
325 self.main_view.get_contact_edit_page().wait_to_stop_moving()
326
327 text_field.write(value)
328
329 def _fill_address(self, index, address):
330 fields = collections.OrderedDict()
331 fields['street'] = address.street
332 fields['locality'] = address.locality
333 fields['region'] = address.region
334 fields['postal_code'] = address.postal_code
335 fields['country'] = address.country
336 for key, value in fields.items():
337 text_field = _get_text_field(self, key, index)
338 self._make_field_visible_and_write(text_field, value)
339
340 def _fill_professional_details(self, index, address):
341 # TODO --elopio - 2014-03-01
342 raise NotImplementedError('Not yet implemented.')
343
344 def get_values(self, field, index):
345 if field == 'phones':
346 return data.Phone(
347 type_=data.Phone.TYPES[self._get_selected_type_index()],
348 number=self._get_single_field_value())
349 if field == 'emails':
350 return data.Email(
351 type_=data.Email.TYPES[self._get_selected_type_index()],
352 address=self._get_single_field_value())
353 if field == 'ims':
354 return data.SocialAlias(
355 type_=data.SocialAlias.TYPES[self._get_selected_type_index()],
356 alias=self._get_single_field_value())
357 if field == 'addresses':
358 return self._get_address_value(index)
359 if field == 'professionalDetails':
360 # TODO --elopio - 2014-03-01
361 return None
362 raise AddressBookAppError('Unknown field: {}.'.format(field))
363
364 def _get_single_field_value(self):
365 return self.select_single(TextInputDetail).text
366
367 def _get_address_value(self, index):
368 street = _get_text_field(self, 'street', index).text
369 locality = _get_text_field(self, 'locality', index).text
370 region = _get_text_field(self, 'region', index).text
371 postal_code = _get_text_field(self, 'postal_code', index).text
372 country = _get_text_field(self, 'country', index).text
373 return data.Address(
374 type_=data.Address.TYPES[self._get_selected_type_index()],
375 street=street, locality=locality, region=region,
376 postal_code=postal_code, country=country)
3770
=== removed file 'tests/autopilot/address_book_app/emulators/page_with_bottom_edge.py'
--- tests/autopilot/address_book_app/emulators/page_with_bottom_edge.py 2014-05-22 14:40:49 +0000
+++ tests/autopilot/address_book_app/emulators/page_with_bottom_edge.py 1970-01-01 00:00:00 +0000
@@ -1,40 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3""" PageWithBottomEdge emulator """
4
5# Copyright 2014 Canonical
6#
7# 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 published
9# by the Free Software Foundation.
10
11import logging
12from address_book_app.emulators.contact_list_page import ContactListPage
13from autopilot.introspection.dbus import StateNotFoundError
14from ubuntuuitoolkit import emulators as toolkit_emulators
15
16logger = logging.getLogger(__name__)
17
18class PageWithBottomEdge(ContactListPage):
19 """An emulator class that makes it easy to interact with the bottom edge
20 swipe page"""
21 def __init__(self, *args):
22 super(PageWithBottomEdge, self).__init__(*args)
23
24 def revel_bottom_edge_page(self):
25 """Bring the bottom edge page to the screen"""
26 self.bottomEdgePageLoaded.wait_for(True)
27 try:
28 action_item = self.wait_select_single('QQuickItem', objectName='bottomEdgeTip')
29 start_x = action_item.globalRect.x + (action_item.globalRect.width * 0.5)
30 start_y = action_item.globalRect.y + (action_item.height * 0.5)
31 stop_y = start_y - (self.height * 0.7)
32 self.pointing_device.drag(start_x, start_y, start_x, stop_y, rate=2)
33 self.isReady.wait_for(True)
34 except StateNotFoundError:
35 logger.error('ButtomEdge element not found.')
36 raise
37
38class ContactListPage(PageWithBottomEdge):
39 pass
40
410
=== added directory 'tests/autopilot/address_book_app/pages'
=== added file 'tests/autopilot/address_book_app/pages/__init__.py'
--- tests/autopilot/address_book_app/pages/__init__.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/address_book_app/pages/__init__.py 2014-05-22 14:40:49 +0000
@@ -0,0 +1,25 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2014 Canonical Ltd.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17__all__ = [
18 'ContactEditor',
19 'ContactListPage',
20 'ContactView',
21]
22
23from address_book_app.pages._contact_editor import ContactEditor
24from address_book_app.pages._contact_list_page import ContactListPage
25from address_book_app.pages._contact_view import ContactView
026
=== added file 'tests/autopilot/address_book_app/pages/_common.py'
--- tests/autopilot/address_book_app/pages/_common.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/address_book_app/pages/_common.py 2014-05-22 14:40:49 +0000
@@ -0,0 +1,53 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2014 Canonical Ltd.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17import logging
18
19import ubuntuuitoolkit
20from autopilot.introspection import dbus
21
22
23logger = logging.getLogger(__name__)
24
25
26class PageWithHeader(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
27
28 def get_header(self):
29 """Return the Header custom proxy object of the Page."""
30 return self.get_root_instance().select_single(
31 'Header', objectName='MainView_Header')
32
33
34class PageWithBottomEdge(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
35 """An emulator class that makes it easy to interact with the bottom edge
36 swipe page"""
37
38 def revel_bottom_edge_page(self):
39 """Bring the bottom edge page to the screen"""
40 self.bottomEdgePageLoaded.wait_for(True)
41 try:
42 action_item = self.wait_select_single(
43 'QQuickItem', objectName='bottomEdgeTip')
44 start_x = (action_item.globalRect.x +
45 (action_item.globalRect.width * 0.5))
46 start_y = action_item.globalRect.y + (action_item.height * 0.5)
47 stop_y = start_y - (self.height * 0.7)
48 self.pointing_device.drag(
49 start_x, start_y, start_x, stop_y, rate=2)
50 self.isReady.wait_for(True)
51 except dbus.StateNotFoundError:
52 logger.error('ButtomEdge element not found.')
53 raise
054
=== added file 'tests/autopilot/address_book_app/pages/_contact_editor.py'
--- tests/autopilot/address_book_app/pages/_contact_editor.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/address_book_app/pages/_contact_editor.py 2014-05-22 14:40:49 +0000
@@ -0,0 +1,272 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2014 Canonical Ltd.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17import collections
18import logging
19import time
20
21import autopilot.logging
22import ubuntuuitoolkit
23from address_book_app import data, _errors
24from address_book_app.pages import _common
25
26
27logger = logging.getLogger(__name__)
28
29
30_TEXT_FIELD_OBJECT_NAMES = {
31 'first_name': 'firstName',
32 'last_name': 'lastName',
33 'street': 'streetAddress_{}',
34 'locality': 'localityAddress_{}',
35 'region': 'regionAddress_{}',
36 'postal_code': 'postcodeAddress_{}',
37 'country': 'countryAddress_{}'
38}
39
40
41def _get_text_field(parent, field, index=None):
42 if field not in _TEXT_FIELD_OBJECT_NAMES:
43 raise _errors.AddressBookAppError('Unknown field: {}.'.format(field))
44
45 object_name = _TEXT_FIELD_OBJECT_NAMES[field]
46 if index is not None:
47 object_name = object_name.format(index)
48 return parent.select_single(TextInputDetail, objectName=object_name)
49
50
51class ContactEditor(_common.PageWithHeader):
52 """Custom proxy object for the Contact Editor."""
53
54 @autopilot.logging.log_action(logger.info)
55 def fill_form(self, contact_information):
56 """Fill the edit contact form.
57
58 :param contact_information: Values of the contact to fill the form.
59 :type contact_information: data object with the attributes first_name,
60 last_name, phones, emails, social_aliases, addresses and
61 professional_details
62
63 """
64 if contact_information.first_name is not None:
65 self._fill_first_name(contact_information.first_name)
66 if contact_information.last_name is not None:
67 self._fill_last_name(contact_information.last_name)
68
69 groups = collections.OrderedDict()
70 groups['phones'] = contact_information.phones
71 groups['emails'] = contact_information.emails
72 groups['ims'] = contact_information.social_aliases
73 groups['addresses'] = contact_information.addresses
74 groups['professionalDetails'] = (
75 contact_information.professional_details)
76
77 for key, information in groups.items():
78 if information:
79 self._fill_detail_group(
80 object_name=key, details=information)
81
82 def _fill_first_name(self, first_name):
83 text_field = _get_text_field(self, 'first_name')
84 text_field.write(first_name)
85
86 def _fill_last_name(self, last_name):
87 text_field = _get_text_field(self, 'last_name')
88 text_field.write(last_name)
89
90 def _fill_detail_group(self, object_name, details):
91 editor = self.select_single(
92 ContactDetailGroupWithTypeEditor, objectName=object_name)
93 editor.fill(details)
94
95 def _get_form_values(self):
96 first_name = _get_text_field(self, 'first_name').text
97 last_name = _get_text_field(self, 'last_name').text
98 phones = self._get_values_from_detail_group(object_name='phones')
99 emails = self._get_values_from_detail_group(object_name='emails')
100 social_aliases = self._get_values_from_detail_group(object_name='ims')
101 addresses = self._get_values_from_detail_group(object_name='addresses')
102 professional_details = self._get_values_from_detail_group(
103 object_name='professionalDetails')
104
105 return data.Contact(
106 first_name=first_name, last_name=last_name, phones=phones,
107 emails=emails, social_aliases=social_aliases, addresses=addresses,
108 professional_details=professional_details)
109
110 def _get_values_from_detail_group(self, object_name):
111 editor = self.select_single(
112 ContactDetailGroupWithTypeEditor, objectName=object_name)
113 return editor.get_values(object_name)
114
115 def wait_to_stop_moving(self):
116 flickable = self.select_single(
117 'QQuickFlickable', objectName='scrollArea')
118 flickable.flicking.wait_for(False)
119
120
121class TextInputDetail(ubuntuuitoolkit.TextField):
122 """Custom proxy object for the Text Input Detail field."""
123
124
125class ContactDetailGroupWithTypeEditor(
126 ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
127 """Custom proxy object for the ContactDetailGroupWithTypeEditor widget."""
128
129 _DETAIL_EDITORS = {
130 'phones': 'base_phoneNumber_{}',
131 'emails': 'base_email_{}',
132 'ims': 'base_onlineAccount_{}',
133 'addresses': 'base_address_{}',
134 # FIXME fix the unknown. --elopio - 2014-03-01
135 'professionalDetails': 'base_unknown_{}'
136 }
137
138 def fill(self, details):
139 """Fill a contact detail group."""
140 for index, detail in enumerate(details[:-1]):
141 self._fill_detail(index, detail)
142 self._add_detail()
143 self._fill_detail(len(details) - 1, details[-1])
144
145 def _fill_detail(self, index, detail):
146 detail_editor = self._get_detail_editor_by_index(index)
147 detail_editor.fill(field=self.objectName, index=index, detail=detail)
148
149 def _get_detail_editor_by_index(self, index):
150 object_name = self._get_contact_detail_editor_object_name(index)
151 return self.select_single(
152 ContactDetailWithTypeEditor, objectName=object_name)
153
154 def _get_contact_detail_editor_object_name(self, index):
155 return self._DETAIL_EDITORS[self.objectName].format(index)
156
157 def _add_detail(self):
158 # TODO --elopio - 2014-03-01
159 raise NotImplementedError('Add extra details not yet implemented.')
160
161 def get_values(self, object_name):
162 """Return the values of a contact detail group."""
163 values = []
164 for index in range(self.detailsCount):
165 detail_editor = self._get_detail_editor_by_index(index)
166 value = detail_editor.get_values(field=object_name, index=index)
167 if (value):
168 values.append(value)
169
170 return values
171
172
173class ContactDetailWithTypeEditor(
174 ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
175 """Custom proxy object for the ContactDetailWithTypeEditor widget."""
176
177 def fill(self, field, index, detail):
178 self._select_type(detail)
179 self._fill_value(field, index, detail)
180
181 def _select_type(self, detail):
182 type_index = detail.TYPES.index(detail.type)
183 selected_type_index = self._get_selected_type_index()
184 if type_index != selected_type_index:
185 # TODO --elopio - 2014-03-01
186 raise NotImplementedError('Type selection not yet implemented.')
187
188 def _get_selected_type_index(self):
189 value_selector = self.select_single('ValueSelector')
190 return value_selector.currentIndex
191
192 def _fill_value(self, field, index, detail):
193 single_values = {
194 'phones': 'number',
195 'emails': 'address',
196 'ims': 'alias'
197 }
198 if field in single_values:
199 self._fill_single_field(getattr(detail, single_values[field]))
200 elif field == 'addresses':
201 self._fill_address(index, detail)
202 elif field == 'professionalDetails':
203 self._fill_professional_details(index, detail)
204 else:
205 raise _errors.AddressBookAppError(
206 'Unknown field: {}.'.format(field))
207
208 def _fill_single_field(self, value):
209 text_field = self.select_single(TextInputDetail)
210 self._make_field_visible_and_write(text_field, value)
211
212 def _make_field_visible_and_write(self, text_field, value):
213 while not text_field.activeFocus:
214 # XXX We should just swipe the text field into view.
215 # Update this once bug http://pad.lv/1286479 is implemented.
216 # --elopio - 2014-03-01
217 text_field.keyboard.press_and_release('Tab')
218 time.sleep(0.1)
219 contact_editor = self.get_root_instance().select_single(
220 ContactEditor, objectName='contactEditorPage', active=True)
221 contact_editor.wait_to_stop_moving()
222
223 text_field.write(value)
224
225 def _fill_address(self, index, address):
226 fields = collections.OrderedDict()
227 fields['street'] = address.street
228 fields['locality'] = address.locality
229 fields['region'] = address.region
230 fields['postal_code'] = address.postal_code
231 fields['country'] = address.country
232 for key, value in fields.items():
233 text_field = _get_text_field(self, key, index)
234 self._make_field_visible_and_write(text_field, value)
235
236 def _fill_professional_details(self, index, address):
237 # TODO --elopio - 2014-03-01
238 raise NotImplementedError('Not yet implemented.')
239
240 def get_values(self, field, index):
241 if field == 'phones':
242 return data.Phone(
243 type_=data.Phone.TYPES[self._get_selected_type_index()],
244 number=self._get_single_field_value())
245 if field == 'emails':
246 return data.Email(
247 type_=data.Email.TYPES[self._get_selected_type_index()],
248 address=self._get_single_field_value())
249 if field == 'ims':
250 return data.SocialAlias(
251 type_=data.SocialAlias.TYPES[self._get_selected_type_index()],
252 alias=self._get_single_field_value())
253 if field == 'addresses':
254 return self._get_address_value(index)
255 if field == 'professionalDetails':
256 # TODO --elopio - 2014-03-01
257 return None
258 raise _errors.AddressBookAppError('Unknown field: {}.'.format(field))
259
260 def _get_single_field_value(self):
261 return self.select_single(TextInputDetail).text
262
263 def _get_address_value(self, index):
264 street = _get_text_field(self, 'street', index).text
265 locality = _get_text_field(self, 'locality', index).text
266 region = _get_text_field(self, 'region', index).text
267 postal_code = _get_text_field(self, 'postal_code', index).text
268 country = _get_text_field(self, 'country', index).text
269 return data.Address(
270 type_=data.Address.TYPES[self._get_selected_type_index()],
271 street=street, locality=locality, region=region,
272 postal_code=postal_code, country=country)
0273
=== renamed file 'tests/autopilot/address_book_app/emulators/contact_list_page.py' => 'tests/autopilot/address_book_app/pages/_contact_list_page.py'
--- tests/autopilot/address_book_app/emulators/contact_list_page.py 2014-05-22 14:40:49 +0000
+++ tests/autopilot/address_book_app/pages/_contact_list_page.py 2014-05-22 14:40:49 +0000
@@ -1,23 +1,33 @@
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# Copyright (C) 2014 Canonical Ltd.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
216
3""" ContactListPage emulator for Addressbook App tests """17""" ContactListPage emulator for Addressbook App tests """
418
5# Copyright 2014 Canonical
6#
7# 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 published
9# by the Free Software Foundation.
10
11import logging19import logging
20import time
1221
13from autopilot.introspection.dbus import StateNotFoundError22from autopilot.introspection.dbus import StateNotFoundError
14from ubuntuuitoolkit import emulators as uitk23
24from address_book_app.pages import _common, _contact_view
25
1526
16LOGGER = logging.getLogger(__name__)27LOGGER = logging.getLogger(__name__)
17from time import sleep28
1829
1930class ContactListPage(_common.PageWithHeader, _common.PageWithBottomEdge):
20class ContactListPage(uitk.UbuntuUIToolkitEmulatorBase):
21 """ ContactListPage emulator class """31 """ ContactListPage emulator class """
2232
23 def __init__(self, *args):33 def __init__(self, *args):
@@ -26,6 +36,18 @@
26 self.selected_marks = []36 self.selected_marks = []
27 super(ContactListPage, self).__init__(*args)37 super(ContactListPage, self).__init__(*args)
2838
39 def open_contact(self, index):
40 """Open the page with the contact information.
41
42 :param index: The index of the contact to open.
43 :return: The page with the contact information.
44
45 """
46 contacts = self.get_contacts()
47 self.pointing_device.click_object(contacts[index])
48 return self.get_root_instance().select_single(
49 _contact_view.ContactView, objectName='contactViewPage')
50
29 def _get_list_view(self):51 def _get_list_view(self):
30 return self.wait_select_single("ContactListView",52 return self.wait_select_single("ContactListView",
31 objectName="contactListView")53 objectName="contactListView")
@@ -35,7 +57,7 @@
35 Returns a list of ContactDelegate objects and populate57 Returns a list of ContactDelegate objects and populate
36 self.selection_marks58 self.selection_marks
37 """59 """
38 sleep(1)60 time.sleep(1)
39 self.contacts = self.select_many("ContactDelegate")61 self.contacts = self.select_many("ContactDelegate")
40 self.selection_marks = []62 self.selection_marks = []
41 for contact in self.contacts:63 for contact in self.contacts:
@@ -52,7 +74,7 @@
52 self.selected_marks.append(self.selection_marks[idx])74 self.selected_marks.append(self.selection_marks[idx])
53 self.pointing_device.move_to_object(self.contacts[idx])75 self.pointing_device.move_to_object(self.contacts[idx])
54 self.pointing_device.press()76 self.pointing_device.press()
55 sleep(2.0)77 time.sleep(2.0)
56 self.pointing_device.release()78 self.pointing_device.release()
57 view.isInSelectionMode.wait_for(True)79 view.isInSelectionMode.wait_for(True)
58 else:80 else:
@@ -110,4 +132,3 @@
110 dialog = main_window.wait_select_single("RemoveContactsDialog",132 dialog = main_window.wait_select_single("RemoveContactsDialog",
111 objectName="removeContactsDialog")133 objectName="removeContactsDialog")
112 self.click_button(main_window, "removeContactsDialog.Yes")134 self.click_button(main_window, "removeContactsDialog.Yes")
113
114135
=== added file 'tests/autopilot/address_book_app/pages/_contact_view.py'
--- tests/autopilot/address_book_app/pages/_contact_view.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/address_book_app/pages/_contact_view.py 2014-05-22 14:40:49 +0000
@@ -0,0 +1,28 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2014 Canonical Ltd.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17from address_book_app.pages import _common, _contact_editor
18
19
20class ContactView(_common.PageWithHeader):
21 """Autopilot helper for the ContactView page."""
22
23 def go_to_edit_contact(self):
24 self.get_header().click_action_button('edit')
25 return self.get_root_instance().select_single(
26 _contact_editor.ContactEditor,
27 objectName='contactEditorPage',
28 active=True)
029
=== modified file 'tests/autopilot/address_book_app/tests/__init__.py'
--- tests/autopilot/address_book_app/tests/__init__.py 2014-05-22 14:40:49 +0000
+++ tests/autopilot/address_book_app/tests/__init__.py 2014-05-22 14:40:49 +0000
@@ -16,7 +16,8 @@
16from autopilot.platform import model16from autopilot.platform import model
17from testtools.matchers import Equals17from testtools.matchers import Equals
1818
19from address_book_app.emulators.main_window import MainWindow19import address_book_app
20from address_book_app import MainWindow
20from ubuntuuitoolkit import emulators as toolkit_emulators21from ubuntuuitoolkit import emulators as toolkit_emulators
2122
2223
@@ -71,6 +72,7 @@
71 AddressBookAppTestCase.ARGS = []72 AddressBookAppTestCase.ARGS = []
72 AddressBookAppTestCase.PRELOAD_VCARD = False73 AddressBookAppTestCase.PRELOAD_VCARD = False
73 self.main_window.visible.wait_for(True)74 self.main_window.visible.wait_for(True)
75 self.app = address_book_app.AddressBookApp(self.app_proxy)
7476
75 def tearDown(self):77 def tearDown(self):
76 super(AddressBookAppTestCase, self).tearDown()78 super(AddressBookAppTestCase, self).tearDown()
@@ -80,7 +82,7 @@
80 subprocess.check_call(["/sbin/initctl", "start", "maliit-server"])82 subprocess.check_call(["/sbin/initctl", "start", "maliit-server"])
8183
82 def launch_test_local(self):84 def launch_test_local(self):
83 self.app = self.launch_test_application(85 self.app_proxy = self.launch_test_application(
84 self.app_bin,86 self.app_bin,
85 *AddressBookAppTestCase.ARGS,87 *AddressBookAppTestCase.ARGS,
86 app_type='qt',88 app_type='qt',
@@ -89,19 +91,19 @@
89 def launch_test_installed(self):91 def launch_test_installed(self):
90 df = "/usr/share/applications/address-book-app.desktop"92 df = "/usr/share/applications/address-book-app.desktop"
91 self.ARGS.append("--desktop_file_hint=" + df)93 self.ARGS.append("--desktop_file_hint=" + df)
92 self.app = self.launch_test_application(94 self.app_proxy = self.launch_test_application(
93 "address-book-app",95 "address-book-app",
94 *AddressBookAppTestCase.ARGS,96 *AddressBookAppTestCase.ARGS,
95 app_type='qt',97 app_type='qt',
96 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)98 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
9799
98 def launch_click_installed(self):100 def launch_click_installed(self):
99 self.app = self.launch_click_package(101 self.app_proxy = self.launch_click_package(
100 "com.ubuntu.address-book")102 "com.ubuntu.address-book")
101103
102 @property104 @property
103 def main_window(self):105 def main_window(self):
104 return self.app.select_single(MainWindow)106 return self.app_proxy.select_single(MainWindow)
105107
106 def select_a_value(self, field, value_selector, value):108 def select_a_value(self, field, value_selector, value):
107 # Make sure the field has focus109 # Make sure the field has focus
108110
=== modified file 'tests/autopilot/address_book_app/tests/test_add_contact.py'
--- tests/autopilot/address_book_app/tests/test_add_contact.py 2014-05-22 14:40:49 +0000
+++ tests/autopilot/address_book_app/tests/test_add_contact.py 2014-05-22 14:40:49 +0000
@@ -11,9 +11,9 @@
11from autopilot.matchers import Eventually11from autopilot.matchers import Eventually
12from autopilot.introspection import dbus12from autopilot.introspection import dbus
1313
14import address_book_app
14from address_book_app import data15from address_book_app import data
15from address_book_app.tests import AddressBookAppTestCase16from address_book_app.tests import AddressBookAppTestCase
16from address_book_app.emulators import main_window
1717
1818
19class TestAddContact(AddressBookAppTestCase):19class TestAddContact(AddressBookAppTestCase):
@@ -22,37 +22,39 @@
22 def test_go_to_add_contact(self):22 def test_go_to_add_contact(self):
23 """Test to launch the add contact screen using emulator method"""23 """Test to launch the add contact screen using emulator method"""
24 self.assertRaises(24 self.assertRaises(
25 dbus.StateNotFoundError, self.main_window.get_contact_edit_page)25 dbus.StateNotFoundError,
26 contact_editor = self.main_window.go_to_add_contact()26 self.app.main_window.get_contact_edit_page)
27 contact_editor = self.app.main_window.go_to_add_contact()
27 self.assertTrue(contact_editor.visible)28 self.assertTrue(contact_editor.visible)
28 self.assertIsInstance(contact_editor, main_window.ContactEditor)29 self.assertIsInstance(
30 contact_editor, address_book_app.pages.ContactEditor)
2931
30 def test_add_and_cancel_contact(self):32 def test_add_and_cancel_contact(self):
31 list_page = self.main_window.get_contact_list_page()33 list_page = self.app.main_window.get_contact_list_page()
3234
33 # execute add new contact35 # execute add new contact
34 contact_editor = self.main_window.go_to_add_contact()36 contact_editor = self.app.main_window.go_to_add_contact()
3537
36 # Check if the contact list disapear and contact editor appears38 # Check if the contact list disapear and contact editor appears
37 self.assertThat(list_page.visible, Eventually(Equals(False)))39 self.assertThat(list_page.visible, Eventually(Equals(False)))
38 self.assertThat(contact_editor.visible, Eventually(Equals(True)))40 self.assertThat(contact_editor.visible, Eventually(Equals(True)))
3941
40 # cancel new contact without save42 # cancel new contact without save
41 self.main_window.cancel()43 self.app.main_window.cancel()
4244
43 # Check if the contact list is visible again45 # Check if the contact list is visible again
44 self.assertThat(list_page.visible, Eventually(Equals(True)))46 self.assertThat(list_page.visible, Eventually(Equals(True)))
4547
46 # Check if the contact list still empty48 # Check if the contact list still empty
47 list_view = self.main_window.get_contact_list_view()49 list_view = self.app.main_window.get_contact_list_view()
48 self.assertThat(list_view.count, Eventually(Equals(0)))50 self.assertThat(list_view.count, Eventually(Equals(0)))
4951
50 def test_add_contact_without_name(self):52 def test_add_contact_without_name(self):
51 # execute add new contact53 # execute add new contact
52 contact_editor = self.main_window.go_to_add_contact()54 contact_editor = self.app.main_window.go_to_add_contact()
5355
54 # Try to save a empty contact56 # Try to save a empty contact
55 acceptButton = self.main_window.get_button("save")57 acceptButton = self.app.main_window.get_button("save")
5658
57 # Save button must be disabled59 # Save button must be disabled
58 self.assertThat(acceptButton.enabled, Eventually(Equals(False)))60 self.assertThat(acceptButton.enabled, Eventually(Equals(False)))
@@ -82,59 +84,59 @@
82 self.pointing_device.click_object(acceptButton)84 self.pointing_device.click_object(acceptButton)
8385
84 # Check if the contact editor still visbile86 # Check if the contact editor still visbile
85 list_page = self.main_window.get_contact_list_page()87 list_page = self.app.main_window.get_contact_list_page()
8688
87 self.assertThat(list_page.visible, Eventually(Equals(False)))89 self.assertThat(list_page.visible, Eventually(Equals(False)))
88 self.assertThat(contact_editor.visible, Eventually(Equals(True)))90 self.assertThat(contact_editor.visible, Eventually(Equals(True)))
8991
90 # Check if the contact list still empty92 # Check if the contact list still empty
91 list_view = self.main_window.get_contact_list_view()93 list_view = self.app.main_window.get_contact_list_view()
92 self.assertThat(list_view.count, Eventually(Equals(0)))94 self.assertThat(list_view.count, Eventually(Equals(0)))
9395
94 def test_add_contact_with_full_name(self):96 def test_add_contact_with_full_name(self):
95 test_contact = data.Contact(first_name='Fulano', last_name='de Tal')97 test_contact = data.Contact(first_name='Fulano', last_name='de Tal')
9698
97 # execute add new contact99 # execute add new contact
98 contact_editor = self.main_window.go_to_add_contact()100 contact_editor = self.app.main_window.go_to_add_contact()
99 contact_editor.fill_form(test_contact)101 contact_editor.fill_form(test_contact)
100102
101 # Save contact103 # Save contact
102 self.main_window.save()104 self.app.main_window.save()
103105
104 # Check if the contact list is visible again106 # Check if the contact list is visible again
105 list_page = self.main_window.get_contact_list_page()107 list_page = self.app.main_window.get_contact_list_page()
106 self.assertThat(list_page.visible, Eventually(Equals(True)))108 self.assertThat(list_page.visible, Eventually(Equals(True)))
107109
108 # Check if contact was added110 # Check if contact was added
109 list_view = self.main_window.get_contact_list_view()111 list_view = self.app.main_window.get_contact_list_view()
110 self.assertThat(list_view.count, Eventually(Equals(1)))112 self.assertThat(list_view.count, Eventually(Equals(1)))
111113
112 def test_add_contact_with_first_name(self):114 def test_add_contact_with_first_name(self):
113 test_contact = data.Contact(first_name='Fulano')115 test_contact = data.Contact(first_name='Fulano')
114116
115 # execute add new contact117 # execute add new contact
116 contact_editor = self.main_window.go_to_add_contact()118 contact_editor = self.app.main_window.go_to_add_contact()
117 contact_editor.fill_form(test_contact)119 contact_editor.fill_form(test_contact)
118120
119 # Save contact121 # Save contact
120 self.main_window.save()122 self.app.main_window.save()
121123
122 # Check if contact was added124 # Check if contact was added
123 list_view = self.main_window.get_contact_list_view()125 list_view = self.app.main_window.get_contact_list_view()
124 self.assertThat(list_view.count, Eventually(Equals(1)))126 self.assertThat(list_view.count, Eventually(Equals(1)))
125127
126 def test_add_contact_with_last_name(self):128 def test_add_contact_with_last_name(self):
127 test_contact = data.Contact(last_name='de Tal')129 test_contact = data.Contact(last_name='de Tal')
128130
129 # execute add new contact131 # execute add new contact
130 contact_editor = self.main_window.go_to_add_contact()132 contact_editor = self.app.main_window.go_to_add_contact()
131 contact_editor.fill_form(test_contact)133 contact_editor.fill_form(test_contact)
132134
133 # Save contact135 # Save contact
134 self.main_window.save()136 self.app.main_window.save()
135137
136 # Check if contact was added138 # Check if contact was added
137 list_view = self.main_window.get_contact_list_view()139 list_view = self.app.main_window.get_contact_list_view()
138 self.assertThat(list_view.count, Eventually(Equals(1)))140 self.assertThat(list_view.count, Eventually(Equals(1)))
139141
140 def test_add_contact_with_name_and_phone(self):142 def test_add_contact_with_name_and_phone(self):
@@ -143,14 +145,14 @@
143 phones=[data.Phone.make()])145 phones=[data.Phone.make()])
144146
145 # execute add new contact147 # execute add new contact
146 contact_editor = self.main_window.go_to_add_contact()148 contact_editor = self.app.main_window.go_to_add_contact()
147 contact_editor.fill_form(test_contact)149 contact_editor.fill_form(test_contact)
148150
149 # Save contact151 # Save contact
150 self.main_window.save()152 self.app.main_window.save()
151153
152 # Check if contact was added154 # Check if contact was added
153 list_view = self.main_window.get_contact_list_view()155 list_view = self.app.main_window.get_contact_list_view()
154 self.assertThat(list_view.count, Eventually(Equals(1)))156 self.assertThat(list_view.count, Eventually(Equals(1)))
155157
156 def test_add_full_contact(self):158 def test_add_full_contact(self):
@@ -160,19 +162,19 @@
160 test_contact.professional_details = []162 test_contact.professional_details = []
161163
162 # execute add new contact164 # execute add new contact
163 contact_editor = self.main_window.go_to_add_contact()165 contact_editor = self.app.main_window.go_to_add_contact()
164 contact_editor.fill_form(test_contact)166 contact_editor.fill_form(test_contact)
165167
166 # Save contact168 # Save contact
167 self.main_window.save()169 self.app.main_window.save()
168170
169 # Check if contact was added171 # Check if contact was added
170 list_view = self.main_window.get_contact_list_view()172 list_view = self.app.main_window.get_contact_list_view()
171 self.assertThat(list_view.count, Eventually(Equals(1)))173 self.assertThat(list_view.count, Eventually(Equals(1)))
172174
173 def test_email_label_save(self):175 def test_email_label_save(self):
174 # execute add new contact176 # execute add new contact
175 contact_editor = self.main_window.go_to_add_contact()177 contact_editor = self.app.main_window.go_to_add_contact()
176178
177 # fill name179 # fill name
178 contact_editor.fill_form(180 contact_editor.fill_form(
@@ -186,13 +188,13 @@
186 self.set_email_address(2, "other@email.com", 2)188 self.set_email_address(2, "other@email.com", 2)
187189
188 # Save contact190 # Save contact
189 self.main_window.save()191 self.app.main_window.save()
190192
191 contacts = self.main_window.select_many("ContactDelegate")193 contacts = self.app.main_window.select_many("ContactDelegate")
192 self.pointing_device.click_object(contacts[0])194 self.pointing_device.click_object(contacts[0])
193195
194 # check if contacts was saved with the correct labels196 # check if contacts was saved with the correct labels
195 view_page = self.main_window.get_contact_view_page()197 view_page = self.app.main_window.get_contact_view_page()
196 self.assertThat(view_page.visible, Eventually(Equals(True)))198 self.assertThat(view_page.visible, Eventually(Equals(True)))
197199
198 # check if we have 3 emails"""200 # check if we have 3 emails"""
@@ -222,7 +224,7 @@
222224
223 def test_phone_label_save(self):225 def test_phone_label_save(self):
224 # execute add new contact226 # execute add new contact
225 contact_editor = self.main_window.go_to_add_contact()227 contact_editor = self.app.main_window.go_to_add_contact()
226228
227 # fill name229 # fill name
228 contact_editor.fill_form(230 contact_editor.fill_form(
@@ -240,13 +242,13 @@
240 self.set_phone_number(4, "(000) 000-0004", 4)242 self.set_phone_number(4, "(000) 000-0004", 4)
241243
242 # Save contact244 # Save contact
243 self.main_window.save()245 self.app.main_window.save()
244246
245 contacts = self.main_window.select_many("ContactDelegate")247 contacts = self.app.main_window.select_many("ContactDelegate")
246 self.pointing_device.click_object(contacts[0])248 self.pointing_device.click_object(contacts[0])
247249
248 # check if contacts was saved with the correct labels250 # check if contacts was saved with the correct labels
249 view_page = self.main_window.get_contact_view_page()251 view_page = self.app.main_window.get_contact_view_page()
250 self.assertThat(view_page.visible, Eventually(Equals(True)))252 self.assertThat(view_page.visible, Eventually(Equals(True)))
251253
252 # check if we have five phones"""254 # check if we have five phones"""
253255
=== modified file 'tests/autopilot/address_book_app/tests/test_contactlist.py'
--- tests/autopilot/address_book_app/tests/test_contactlist.py 2014-03-12 20:35:16 +0000
+++ tests/autopilot/address_book_app/tests/test_contactlist.py 2014-05-22 14:40:49 +0000
@@ -17,6 +17,6 @@
17 """Tests the contact list features"""17 """Tests the contact list features"""
1818
19 def test_contact_list(self):19 def test_contact_list(self):
20 contact_list = self.main_window.get_contact_list_page()20 contact_list = self.app.main_window.get_contact_list_page()
21 self.assertThat(contact_list.visible, Eventually(Equals(True)))21 self.assertThat(contact_list.visible, Eventually(Equals(True)))
22 pass22 pass
2323
=== modified file 'tests/autopilot/address_book_app/tests/test_create_new_from_uri.py'
--- tests/autopilot/address_book_app/tests/test_create_new_from_uri.py 2014-05-22 14:40:49 +0000
+++ tests/autopilot/address_book_app/tests/test_create_new_from_uri.py 2014-05-22 14:40:49 +0000
@@ -23,17 +23,17 @@
23 super(TestCreateNewContactFromURI, self).setUp()23 super(TestCreateNewContactFromURI, self).setUp()
2424
25 def test_save_new_contact(self):25 def test_save_new_contact(self):
26 list_page = self.main_window.get_contact_list_page()26 list_page = self.app.main_window.get_contact_list_page()
27 list_page.isReady.wait_for(True)27 list_page.isReady.wait_for(True)
28 28
29 edit_page = self.main_window.get_contact_edit_page()29 edit_page = self.app.main_window.get_contact_edit_page()
30 self.assertThat(edit_page.visible, Eventually(Equals(True)))30 self.assertThat(edit_page.visible, Eventually(Equals(True)))
3131
32 # add name to the contact32 # add name to the contact
33 firstNameField = self.main_window.wait_select_single(33 firstNameField = self.app.main_window.wait_select_single(
34 "TextInputDetail",34 "TextInputDetail",
35 objectName="firstName")35 objectName="firstName")
36 lastNameField = self.main_window.wait_select_single(36 lastNameField = self.app.main_window.wait_select_single(
37 "TextInputDetail",37 "TextInputDetail",
38 objectName="lastName")38 objectName="lastName")
3939
@@ -41,14 +41,14 @@
41 self.type_on_field(lastNameField, "de Tal")41 self.type_on_field(lastNameField, "de Tal")
4242
43 # save the contact43 # save the contact
44 acceptButton = self.main_window.save()44 self.app.main_window.save()
4545
46 # open contact view46 # open contact view
47 contacts = self.main_window.select_many("ContactDelegate")47 contacts = self.app.main_window.select_many("ContactDelegate")
48 self.pointing_device.click_object(contacts[0])48 self.pointing_device.click_object(contacts[0])
49 view_page = self.main_window.get_contact_view_page()49 view_page = self.app.main_window.get_contact_view_page()
50 self.assertThat(view_page.visible, Eventually(Equals(True)))50 self.assertThat(view_page.visible, Eventually(Equals(True)))
51 51
5252
53 # check if we have the new phone"""53 # check if we have the new phone"""
54 phone_group = view_page.select_single(54 phone_group = view_page.select_single(
5555
=== renamed file 'tests/autopilot/address_book_app/tests/test_emulators.py' => 'tests/autopilot/address_book_app/tests/test_custom_proxy_objects.py'
--- tests/autopilot/address_book_app/tests/test_emulators.py 2014-03-01 11:03:45 +0000
+++ tests/autopilot/address_book_app/tests/test_custom_proxy_objects.py 2014-05-22 14:40:49 +0000
@@ -17,8 +17,6 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.17# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
19from address_book_app import data, tests19from address_book_app import data, tests
20from address_book_app.emulators import main_window
21
2220
23class ContactEditorTestCase(tests.AddressBookAppTestCase):21class ContactEditorTestCase(tests.AddressBookAppTestCase):
2422
@@ -29,7 +27,7 @@
29 # --elopio - 2014-03-0127 # --elopio - 2014-03-01
30 test_contact.professional_details = []28 test_contact.professional_details = []
3129
32 contact_editor = self.main_window.go_to_add_contact()30 contact_editor = self.app.main_window.go_to_add_contact()
3331
34 contact_editor.fill_form(test_contact)32 contact_editor.fill_form(test_contact)
3533
3634
=== modified file 'tests/autopilot/address_book_app/tests/test_delete_contact.py'
--- tests/autopilot/address_book_app/tests/test_delete_contact.py 2014-05-22 14:40:49 +0000
+++ tests/autopilot/address_book_app/tests/test_delete_contact.py 2014-05-22 14:40:49 +0000
@@ -35,7 +35,7 @@
35 def setUp(self):35 def setUp(self):
36 AddressBookAppTestCase.PRELOAD_VCARD = True36 AddressBookAppTestCase.PRELOAD_VCARD = True
37 super(TestDeleteSelectContact, self).setUp()37 super(TestDeleteSelectContact, self).setUp()
38 38
39 def test_select(self):39 def test_select(self):
40 """40 """
41 Delete a contact in pick mode41 Delete a contact in pick mode
@@ -45,15 +45,15 @@
45 contact in the list before and after the action.45 contact in the list before and after the action.
46 Note that it doesn't check which contact has been deleted.46 Note that it doesn't check which contact has been deleted.
47 """47 """
48 listpage = self.main_window.get_contact_list_page()48 listpage = self.app.main_window.get_contact_list_page()
49 contacts_before = listpage.get_contacts()49 contacts_before = listpage.get_contacts()
5050
51 listpage.select_contacts_by_index(self.select)51 listpage.select_contacts_by_index(self.select)
52 deleted = []52 deleted = []
53 if self.action == "cancel":53 if self.action == "cancel":
54 self.main_window.cancel()54 self.app.main_window.cancel()
55 elif self.action == "delete":55 elif self.action == "delete":
56 listpage.delete(self.main_window)56 listpage.delete(self.app.main_window)
57 deleted = self.select57 deleted = self.select
5858
59 contacts_after = listpage.get_contacts()59 contacts_after = listpage.get_contacts()
6060
=== modified file 'tests/autopilot/address_book_app/tests/test_edit_contact.py'
--- tests/autopilot/address_book_app/tests/test_edit_contact.py 2014-05-22 14:40:49 +0000
+++ tests/autopilot/address_book_app/tests/test_edit_contact.py 2014-05-22 14:40:49 +0000
@@ -10,6 +10,7 @@
10from testtools.matchers import Equals10from testtools.matchers import Equals
11from autopilot.matchers import Eventually11from autopilot.matchers import Eventually
1212
13from address_book_app import data
13from address_book_app.tests import AddressBookAppTestCase14from address_book_app.tests import AddressBookAppTestCase
1415
1516
@@ -17,6 +18,21 @@
17 """Tests edit a contact"""18 """Tests edit a contact"""
18 PHONE_NUMBERS = ['(333) 123-4567', '(333) 123-4568', '(222) 222-2222']19 PHONE_NUMBERS = ['(333) 123-4567', '(333) 123-4568', '(222) 222-2222']
1920
21 PHONE_NUMBERS = ['(333) 123-4567', '(333) 123-4568', '(222) 222-2222']
22
23 def add_test_contact(self):
24 test_contact = data.Contact('test', 'test')
25 # TODO implement the filling of professional details.
26 # --elopio - 2014-03-01
27 test_contact.professional_details = []
28
29 # execute add new contact
30 contact_editor = self.main_window.go_to_add_contact()
31 contact_editor.fill_form(test_contact)
32
33 # Save contact
34 self.main_window.save()
35
20 def test_add_new_phone(self):36 def test_add_new_phone(self):
21 self.add_contact("Fulano", "de Tal", [self.PHONE_NUMBERS[0]])37 self.add_contact("Fulano", "de Tal", [self.PHONE_NUMBERS[0]])
22 edit_page = self.edit_contact(0)38 edit_page = self.edit_contact(0)
@@ -28,15 +44,15 @@
28 self.create_new_detail(phoneGroup)44 self.create_new_detail(phoneGroup)
2945
30 # fill phone number46 # fill phone number
31 phone_number_1 = self.main_window.select_single(47 phone_number_1 = self.app.main_window.select_single(
32 "TextInputDetail",48 "TextInputDetail",
33 objectName="phoneNumber_1")49 objectName="phoneNumber_1")
34 self.type_on_field(phone_number_1, self.PHONE_NUMBERS[1])50 self.type_on_field(phone_number_1, self.PHONE_NUMBERS[1])
3551
36 self.main_window.save()52 self.app.main_window.save()
3753
38 # go back to view page54 # go back to view page
39 view_page = self.main_window.get_contact_view_page()55 view_page = self.app.main_window.get_contact_view_page()
40 self.assertThat(view_page.visible, Eventually(Equals(True)))56 self.assertThat(view_page.visible, Eventually(Equals(True)))
4157
42 # check if we have two phones"""58 # check if we have two phones"""
@@ -62,10 +78,10 @@
62 self.clear_text_on_field(phone_number_1)78 self.clear_text_on_field(phone_number_1)
6379
64 # Save contact80 # Save contact
65 self.main_window.save()81 self.app.main_window.save()
6682
67 # check if we have onlye one phone83 # check if we have onlye one phone
68 view_page = self.main_window.get_contact_view_page()84 view_page = self.app.main_window.get_contact_view_page()
69 phone_group = view_page.select_single(85 phone_group = view_page.select_single(
70 "ContactDetailGroupWithTypeView",86 "ContactDetailGroupWithTypeView",
71 objectName="phones")87 objectName="phones")
@@ -92,10 +108,10 @@
92 objectName="emailAddress_0")108 objectName="emailAddress_0")
93 self.type_on_field(email_field, "fulano@internet.com.br")109 self.type_on_field(email_field, "fulano@internet.com.br")
94110
95 self.main_window.save()111 self.app.main_window.save()
96112
97 # go back to view page113 # go back to view page
98 view_page = self.main_window.get_contact_view_page()114 view_page = self.app.main_window.get_contact_view_page()
99 self.assertThat(view_page.visible, Eventually(Equals(True)))115 self.assertThat(view_page.visible, Eventually(Equals(True)))
100116
101 # check if we have a new email117 # check if we have a new email
@@ -122,10 +138,10 @@
122 self.clear_text_on_field(email_address_0)138 self.clear_text_on_field(email_address_0)
123139
124 # Save contact140 # Save contact
125 self.main_window.save()141 self.app.main_window.save()
126142
127 # check if the email list is empty143 # check if the email list is empty
128 view_page = self.main_window.get_contact_view_page()144 view_page = self.app.main_window.get_contact_view_page()
129 emails_group = view_page.select_single(145 emails_group = view_page.select_single(
130 "ContactDetailGroupWithTypeView",146 "ContactDetailGroupWithTypeView",
131 objectName="emails")147 objectName="emails")
@@ -147,15 +163,15 @@
147 self.clear_text_on_field(last_name_field)163 self.clear_text_on_field(last_name_field)
148164
149 # check if is possible to save a contact without name165 # check if is possible to save a contact without name
150 self.main_window.save()166 self.app.main_window.save()
151 accept_button = self.main_window.get_button("save")167 accept_button = self.app.main_window.get_button("save")
152 self.assertThat(accept_button.enabled, Eventually(Equals(False)))168 self.assertThat(accept_button.enabled, Eventually(Equals(False)))
153169
154 # Cancel edit170 # Cancel edit
155 self.main_window.cancel()171 self.app.main_window.cancel()
156172
157 # Check if the names still there173 # Check if the names still there
158 view_page = self.main_window.get_contact_view_page()174 view_page = self.app.main_window.get_contact_view_page()
159 self.assertThat(view_page.title, Eventually(Equals("Fulano de Tal")))175 self.assertThat(view_page.title, Eventually(Equals("Fulano de Tal")))
160176
161 def test_im_type(self):177 def test_im_type(self):
@@ -177,9 +193,9 @@
177 self.select_a_value(im_address_0, im_value_selector, 0)193 self.select_a_value(im_address_0, im_value_selector, 0)
178194
179 # save contact195 # save contact
180 self.main_window.save()196 self.app.main_window.save()
181197
182 view_page = self.main_window.get_contact_view_page()198 view_page = self.app.main_window.get_contact_view_page()
183199
184 # check if the type was saved correct200 # check if the type was saved correct
185 im_type = view_page.select_single(201 im_type = view_page.select_single(
186202
=== modified file 'tests/autopilot/address_book_app/tests/test_multiple_pick_mode.py'
--- tests/autopilot/address_book_app/tests/test_multiple_pick_mode.py 2014-03-12 20:35:16 +0000
+++ tests/autopilot/address_book_app/tests/test_multiple_pick_mode.py 2014-05-22 14:40:49 +0000
@@ -22,7 +22,7 @@
22 super(TestMultiplePickerMode, self).setUp()22 super(TestMultiplePickerMode, self).setUp()
2323
24 def test_select_contacts(self):24 def test_select_contacts(self):
25 pick_page = self.main_window.get_contact_list_pick_page()25 pick_page = self.app.main_window.get_contact_list_pick_page()
26 contacts = pick_page.select_many("ContactDelegate")26 contacts = pick_page.select_many("ContactDelegate")
27 # all selection marks should be visible27 # all selection marks should be visible
28 selection_marks = []28 selection_marks = []
2929
=== modified file 'tests/autopilot/address_book_app/tests/test_single_pick_mode.py'
--- tests/autopilot/address_book_app/tests/test_single_pick_mode.py 2014-03-12 20:35:16 +0000
+++ tests/autopilot/address_book_app/tests/test_single_pick_mode.py 2014-05-22 14:40:49 +0000
@@ -22,7 +22,7 @@
22 super(TestSinglePickerMode, self).setUp()22 super(TestSinglePickerMode, self).setUp()
2323
24 def test_select_single_contact(self):24 def test_select_single_contact(self):
25 pick_page = self.main_window.get_contact_list_pick_page()25 pick_page = self.app.main_window.get_contact_list_pick_page()
26 contacts = pick_page.select_many("ContactDelegate")26 contacts = pick_page.select_many("ContactDelegate")
27 # all selection marks should be visible27 # all selection marks should be visible
28 selection_marks = []28 selection_marks = []
2929
=== renamed file 'tests/autopilot/address_book_app/emulators/toolbar.py' => 'tests/autopilot/address_book_app/toolbar.py'

Subscribers

People subscribed via source and target branches