Merge lp:~brendan-donegan/ubuntu-autopilot-tests/bug1297295 into lp:ubuntu-autopilot-tests/ubuntu-experience-tests

Proposed by Brendan Donegan
Status: Needs review
Proposed branch: lp:~brendan-donegan/ubuntu-autopilot-tests/bug1297295
Merge into: lp:ubuntu-autopilot-tests/ubuntu-experience-tests
Diff against target: 106 lines (+89/-0)
2 files modified
ubuntu_experience_tests/helpers.py (+14/-0)
ubuntu_experience_tests/tests/messaging_app/test_messaging_app.py (+75/-0)
To merge this branch: bzr merge lp:~brendan-donegan/ubuntu-autopilot-tests/bug1297295
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Leo Arias (community) Needs Fixing
Review via email: mp+221342@code.launchpad.net

This proposal supersedes a proposal from 2014-05-29.

Commit message

Add UX test for adding a number to a contact from an SMS message

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

Looks really nice. Just you have a lot of things to move to the messaging and address book apps. From your TODOs, I think you have that on your roadmap.

In the end, this tests should be nicely readable, just calling methods with names that represent user actions, like open_thread, or add_to_contacts

Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Thanks for the good feedback - yes my plan is to avoid any explicit calls to wait_select and so on in the test, so I will need to do some work in messaging-app and address-book-app. I'll ask for another review later when I've done that.

Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Followed up on most of the comments. The updates to messaging-app and address-book-app will take a bit longer.

Revision history for this message
Leo Arias (elopio) wrote :

contactsdb/main.cpp doesn't have tests. And this is not the right project for contacts helpers. Have you tried to merge them to the messaging app? Also, I would prefer the test helpers to be python, unless there's a good reason not to. Why did you chose cpp?

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

s/messaging app/address book

Revision history for this message
Leo Arias (elopio) :
35. By Brendan Donegan

Removed contactsdb directory since it wasn't used

Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

The contactsdb stuff is what I was writing before I realised there was a dbus service available for that. I removed it in my local branch but forgot to push it up. Deleted it now.

36. By Brendan Donegan

Tidy up comments

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)
37. By Brendan Donegan

Added test_mtp_transfer.py

38. By Brendan Donegan

Cleaned flake8 errors

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
Leo Arias (elopio) wrote :

You need to add messaging-app-autopilot to the dependencies. But that's py2, so we'll have to wait for the py3 branch to land.

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

I'm trying to understand why you are using the MainView as base class. I haven't found anything useful yet, but a couple of things:

86 +class MessagingAddressBookTestCase(messaging_tests.BaseMessagingTestCase):

Some of these tests will need to interact with unity, so we need to restart unity with testability. Currently, that's done telling jenkins to start without a shell. So on your test you will need to restart unity even if you are not interacting with unity. It might be a good idea to kill unity only if you need it, but I think it's good to start with a clean unity. What do you think?

Anyway, in order to run with the current jenkins job, you'll need to inherit from UbuntuExperienceTestCase.

In addition to that, it's probably a bad idea to inherit from that BaseMessagingTestCase. It's on the wrong file, because we should split that test_messaging.py in smaller suites that test the different parts of the app. I think that the right thing to do is to use Fixtures to set up the app environment you need instead of inherit from an app test case that's likely to change. Take a look at what omer is doing here:
https://code.launchpad.net/~om26er/messaging-app/use_fixture/+merge/225350

Revision history for this message
Leo Arias (elopio) wrote :

ahhh, I get it. Wow, it took me a long time.

108 + address_book = helpers.get_proxy_object_by_process_name(
109 + 'address-book-app'
110 + )

There what you are getting is an autopilot proxy object, that's like one level higher than the root of the QML tree. So with that proxy object you have access to the full tree.
So, what you should do is something like this

import address_book_app

[...]

address_book_proxy_object = helpers.get_proxy_object_by_process_name(...)
address_book = address_book_app.AddressBookApp(address_book_proxy_object)
address_book.main_view.contact_view_page.save()

So, please remove the _get_emulator_base method, and just hardcode the toolkit base class there.

39. By Brendan Donegan

Merged from trunk

40. By Brendan Donegan

Use toolkit base class to get proxy object, and fix the expected result of the test.

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

Use TestabilityEnvironment from this project

42. By Brendan Donegan

Use messaging fixture and UbuntuExperienceTestCase

43. By Brendan Donegan

Remove accidently added mtp test code

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

Update to use new helpers which will be in address-book-app and fix imports

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

Unmerged revisions

44. By Brendan Donegan

Update to use new helpers which will be in address-book-app and fix imports

43. By Brendan Donegan

Remove accidently added mtp test code

42. By Brendan Donegan

Use messaging fixture and UbuntuExperienceTestCase

41. By Brendan Donegan

Use TestabilityEnvironment from this project

40. By Brendan Donegan

Use toolkit base class to get proxy object, and fix the expected result of the test.

39. By Brendan Donegan

Merged from trunk

38. By Brendan Donegan

Cleaned flake8 errors

37. By Brendan Donegan

Added test_mtp_transfer.py

36. By Brendan Donegan

Tidy up comments

35. By Brendan Donegan

Removed contactsdb directory since it wasn't used

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_experience_tests/helpers.py'
2--- ubuntu_experience_tests/helpers.py 2014-06-19 17:46:15 +0000
3+++ ubuntu_experience_tests/helpers.py 2014-07-24 09:16:04 +0000
4@@ -83,6 +83,20 @@
5 uid = match.group(1)
6 return uid
7
8+ def get_vcard_cell(self, vcard):
9+ """
10+ Return the mobile number of the provided vcard
11+ :param vcard: vcard formatted data
12+ :return: mobile number from vcard, else None
13+ """
14+ cell_pattern = re.compile(r'^.*TYPE=CELL,HOME:(?P<cell>\S*)\r?$',
15+ re.MULTILINE | re.IGNORECASE)
16+ cell = None
17+ match = cell_pattern.search(vcard)
18+ if match:
19+ cell = match.group('cell')
20+ return cell
21+
22 def delete_all_contacts(self):
23 """
24 Delete all contacts using the dbus service
25
26=== added directory 'ubuntu_experience_tests/tests/messaging_app'
27=== added file 'ubuntu_experience_tests/tests/messaging_app/__init__.py'
28=== added file 'ubuntu_experience_tests/tests/messaging_app/test_messaging_app.py'
29--- ubuntu_experience_tests/tests/messaging_app/test_messaging_app.py 1970-01-01 00:00:00 +0000
30+++ ubuntu_experience_tests/tests/messaging_app/test_messaging_app.py 2014-07-24 09:16:04 +0000
31@@ -0,0 +1,75 @@
32+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
33+#
34+# Copyright 2014 Canonical Ltd.
35+# Author: Brendan Donegan <brendan.donegan@canonical.com>
36+#
37+# This file is part of ubuntu-experience-tests.
38+#
39+# This program is free software; you can redistribute it and/or modify
40+# it under the terms of the GNU General Public License version 3, as published
41+# by the Free Software Foundation.
42+#
43+# This program is distributed in the hope that it will be useful,
44+# but WITHOUT ANY WARRANTY; without even the implied warranty of
45+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46+# GNU General Public License for more details.
47+#
48+# You should have received a copy of the GNU General Public License
49+# along with this program. If not, see <http://www.gnu.org/licenses/>
50+import address_book_app
51+import os
52+import time
53+
54+from messaging_app import helpers as messaging_helpers
55+from messaging_app import fixture_setup as messaging_fixtures
56+from ubuntu_experience_tests import helpers as ux_helpers
57+from ubuntu_experience_tests import fixture_setup as ux_fixtures
58+from ubuntu_experience_tests.tests import UbuntuExperienceTestCase
59+
60+CONTACT_NAME = 'Ubuntu'
61+CONTACT_NUMBER = '800800'
62+MESSAGE_BODY = 'Ubuntu Touch'
63+
64+CONTACT_VCARD = """
65+BEGIN:VCARD
66+VERSION:3.0
67+N:%s
68+END:VCARD
69+""" % CONTACT_NAME
70+
71+
72+class MessagingAddressBookTestCase(UbuntuExperienceTestCase):
73+
74+ def setUp(self):
75+ super(UbuntuExperienceTestCase, self).setUp()
76+ self.useFixture(ux_fixtures.TestabilityEnvironment())
77+ self.useFixture(messaging_fixtures.MessagingTestEnvironment())
78+ self.contacts_service = ux_helpers.ContactsDbusService()
79+ self.test_contact = self.contacts_service.create_contact(CONTACT_VCARD)
80+ self.addCleanup(self.contacts_service.delete_contact,
81+ [self.contacts_service.get_vcard_uid(
82+ self.test_contact)])
83+
84+ def test_add_phone_number_to_contact_from_message(self):
85+ messaging_helpers.receive_sms(CONTACT_NUMBER, MESSAGE_BODY)
86+ main = self.main_view.get_main_page()
87+ main.open_thread('800800')
88+ # Workaround the message notification covering the toolbar
89+ time.sleep(5)
90+ self.main_view.click_add_button()
91+ address_book_proxy = helpers.get_proxy_object_by_process_name(
92+ 'address-book-app'
93+ )
94+ self.addCleanup(os.system, 'ubuntu-app-stop address-book-app')
95+ #contact = self.main_view.wait_select_single('Label', text='Ubuntu')
96+ #self.app.pointing_device.click_object(contact)
97+ address_book = address_book_app.AddressBookApp(address_book_proxy)
98+ list_page = address_book.main_window.get_contact_list_page()
99+ edit_page = list_page.open_contact(0)
100+ # Save the contact
101+ address_book.main_window.save()
102+ # Verify that the number was saved in the contact
103+ updated_contact = self.contacts_service.query_contacts(
104+ 'uid', self.contacts_service.get_vcard_uid(self.test_contact))[0]
105+ self.assertEquals(self.contacts_service.get_vcard_cell(
106+ updated_contact), '800800')

Subscribers

People subscribed via source and target branches