Merge lp:~carla-sella/ubuntu-rssreader-app/ubuntu-rssreader-test-add-view-feeds into lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk

Proposed by Carla Sella
Status: Work in progress
Proposed branch: lp:~carla-sella/ubuntu-rssreader-app/ubuntu-rssreader-test-add-view-feeds
Merge into: lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk
Diff against target: 388 lines (+285/-21)
5 files modified
FeedListPage.qml (+4/-0)
tests/autopilot/ubuntu_rssreader_app/emulators/main_window.py (+21/-7)
tests/autopilot/ubuntu_rssreader_app/emulators/ubuntusdk.py (+154/-0)
tests/autopilot/ubuntu_rssreader_app/tests/__init__.py (+7/-0)
tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py (+99/-14)
To merge this branch: bzr merge lp:~carla-sella/ubuntu-rssreader-app/ubuntu-rssreader-test-add-view-feeds
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Needs Fixing
Nicholas Skaggs (community) Approve
Francis Ginther Needs Fixing
Review via email: mp+173316@code.launchpad.net

Commit message

Autopilot test for ubuntu-rssreader-app.

Description of the change

Two Autopilot tests for ubuntu-rssreade-app: add_new_feed and view_feeds.
I could not avoid using one sleep at line 87 of test_rssreader.py, even with a couple of assertions if I cancel the sleep line the test fails.

To post a comment you must log in.
Revision history for this message
Joey Chan (qqworini) wrote :

Hi Carla,

Thanks for your Autopilot, but I know nothing about python. Seems the Autopilot will detect the "objectname" to use it for testing.

Note, we will have a huge update in following weeks, called "alpha release", some of current source files will become deprecated. Just let u know

:)

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Carla Sella (carla-sella) wrote :

On Jul 6, 2013 5:37 PM, "Joey Chan" <email address hidden> wrote:
>
> Hi Carla,

Hi Joey,

>
> Thanks for your Autopilot, but I know nothing about python. Seems the
Autopilot will detect the "objectname" to use it for testing.
>
> Note, we will have a huge update in following weeks, called "alpha
release", some of current source files will become deprecated. Just let u
know
>
> :)

Ok thanks :-)
But does this mean it's better to wait instead of writing other Autopilot
tests?
Or is it wise to continue writing them all the same and then fix them
afterwards?

Carla

Revision history for this message
Joey Chan (qqworini) wrote :

Pls keep waiting until we release the alpha :)

> On Jul 6, 2013 5:37 PM, "Joey Chan" <email address hidden> wrote:
> >
> > Hi Carla,
>
> Hi Joey,
>
> >
> > Thanks for your Autopilot, but I know nothing about python. Seems the
> Autopilot will detect the "objectname" to use it for testing.
> >
> > Note, we will have a huge update in following weeks, called "alpha
> release", some of current source files will become deprecated. Just let u
> know
> >
> > :)
>
> Ok thanks :-)
> But does this mean it's better to wait instead of writing other Autopilot
> tests?
> Or is it wise to continue writing them all the same and then fix them
> afterwards?
>
> Carla

Revision history for this message
Carla Sella (carla-sella) wrote :

Ok thanks :-D

Sent from my S3
Carla Sella
<email address hidden>
On Jul 7, 2013 3:11 AM, "Joey Chan" <email address hidden> wrote:

> Pls keep waiting until we release the alpha :)
>
>
> > On Jul 6, 2013 5:37 PM, "Joey Chan" <email address hidden> wrote:
> > >
> > > Hi Carla,
> >
> > Hi Joey,
> >
> > >
> > > Thanks for your Autopilot, but I know nothing about python. Seems the
> > Autopilot will detect the "objectname" to use it for testing.
> > >
> > > Note, we will have a huge update in following weeks, called "alpha
> > release", some of current source files will become deprecated. Just let u
> > know
> > >
> > > :)
> >
> > Ok thanks :-)
> > But does this mean it's better to wait instead of writing other Autopilot
> > tests?
> > Or is it wise to continue writing them all the same and then fix them
> > afterwards?
> >
> > Carla
> --
>
> https://code.launchpad.net/~carla-sella/ubuntu-rssreader-app/ubuntu-rssreader-test-add-view-feeds/+merge/173316
> You are the owner of
> lp:~carla-sella/ubuntu-rssreader-app/ubuntu-rssreader-test-add-view-feeds.
>

Revision history for this message
Francis Ginther (fginther) wrote :

Carla,

I ran into the same errors on my machine as jenkins encountered. I was able to fix them by dist-upgrading to the latest contents of ppa:ubuntu-sdk-team/ppa. The system running the generic-mediumtests does not have this PPA. My theory is that the 'opened' property is somewhat new and only available from the ppa version of the sdk.

So, the quick fix is to just add the ppa to the generic-mediumtests and rerun (please give me some time to get the updates made). It would be nice if we could identify the package and version that is required and add that to debian/control, but I'm not sure that's practical given the rapid development going on.

Francis

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

I retried the generic-mediumtests and saw different failures today :-(. Perhaps this is due to a change in the sdk?

http://91.189.93.70:8080/job/generic-mediumtests/51/

I'll try to debug some more later today.

Revision history for this message
Carla Sella (carla-sella) wrote :

Ok thanks.

--
Carla Sella
email: <email address hidden>
https://launchpad.net/~carla-sella
http://qa.ubuntu.com/

Revision history for this message
Francis Ginther (fginther) wrote :

AH HA!

I finally identified qtdeclarative5-localstorage-plugin as the missing dependency. After adding this to the test machine, I got the following results:
 - http://91.189.93.70:8080/job/generic-mediumtests/55/
 - http://91.189.93.70:8080/job/generic-mediumtests/56/

Note that only 56 passed in full. One of the tests failed in 55, possibly due to a timing issue (i.e. the new_Feed_Url was not yet visible when autopilot tried to access it).

I've filed the following bug for the missing dependency and submitted a merge proposal:
https://bugs.launchpad.net/ubuntu-rssreader-app/+bug/1199818

Revision history for this message
Carla Sella (carla-sella) wrote :

Cool thanks Francis.
For the timing issue do I have to do something ?

Revision history for this message
Francis Ginther (fginther) wrote :
Download full text (5.0 KiB)

I ended up rerunning the test several times. Here are all the runs:
** http://91.189.93.70:8080/job/generic-mediumtests/55/
 - http://91.189.93.70:8080/job/generic-mediumtests/56/
** http://91.189.93.70:8080/job/generic-mediumtests/61/
 - http://91.189.93.70:8080/job/generic-mediumtests/63/
** http://91.189.93.70:8080/job/generic-mediumtests/64/
 - http://91.189.93.70:8080/job/generic-mediumtests/65/

The tests marked with "**" had a failure, not always the same one. While we could say the tests pass, they'll likely end up blocking future MPs when they occasionally fail and the tests themselves will be ignored. (By the way, this is a common problem with the UI tests I've worked with). The tests often behave differently in jenkins because we're using VMs which don't have graphical acceleration. As a result the graphics rendering tends to go slower then autopilot. Also, it's difficult to get the tests to run perfectly, but if we can get them to run better, that should be good.

I did notice an issue with your tests that needs to be corrected and should help. For example:
317 + #click Canonical feed item
318 + canonical_feed = self.main_window.get_canonical_feed()
319 + #does it exist?
320 + lambda: self.assertThat(canonical_feed, NotEquals(None))
321 + #let's click it
322 + self.mouse.move_to_object(canonical_feed)

The "lambda: self.assertThat" isn't doing what you intend. The lambda is not actually running the assert, it's just being defined but never used. What you want to do is this:
317 + #click Canonical feed item
318 + canonical_feed = lambda: self.main_window.get_canonical_feed()
319 + #does it exist?
320 + self.assertThat(canonical_feed, Eventually(NotEquals(None)))
321 + #let's click it
322 + self.mouse.move_to_object(canonical_feed())

Now, 'canonical_feed' is assigned to the lambda, making it a function and not an object. It can be used in the assertThat along with the 'Eventually' matcher to perform a check and wait on the status of the UI element. 'Eventually' requires a callable, which is why 'canonical_feed' is created as a lambda, and will keep retrying the assert until it becomes True or times out (default is 10 seconds). This technique can also be used to eliminate

Also, because 'canonical_feed' is now a function, we have to treat it like a function in the call to 'move_to_object' and add the '()'.

And to resolve the error seen in runs 56 and 61, you could use:
        #type feed in input field
        new_Feed_Url = lambda: self.main_window.get_new_event_name_input_box()
        self.assertThat(new_Feed_Url, Eventually(NotEquals(None)))
        self.pointing_device.click_object(new_Feed_Url())
        self.keyboard.type("http://www.canonical.com/rss.xml")

The Eventually matcher can also be used to eliminate the sleep call in this code:
348 + #check that feed is updated, not empty
349 + canonical_feed_before = self.main_window.get_individual_feed().text
350 + self.assertThat(canonical_feed_before, Eventually(Equals("http://www.canonical.com/rss.xml")))
351 + #had to put this sleep here otherwise test fails
352 ...

Read more...

review: Needs Fixing
Revision history for this message
Carla Sella (carla-sella) wrote :

Hi Francis,
I applied all your suggestions, thanks for the tips.
Hope everything is fine now.
Carla

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Approving to spin up the ole build bot again ;-)

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Some of my ideas can be found in here:

~nskaggs/ubuntu-rssreader-app/carla-feed-commit/

Sadly this doesn't run. I had one of two tests working, but wanted to refine it a bit more. anyways...

Revision history for this message
Joey Chan (qqworini) wrote :

Hi Carla,

Could u pls pause the merge proposal? because I got a "content conflicts" in my branch merge request, the bzr doc said this could happen when two branches are merging two different file with same file-ID.

Perhaps u can continue your autopilot test after we release the alpla, July 18th, I guess :)

> Ok thanks :-D
>
> Sent from my S3
> Carla Sella
> <email address hidden>
> On Jul 7, 2013 3:11 AM, "Joey Chan" <email address hidden> wrote:
>
> > Pls keep waiting until we release the alpha :)
> >
> >
> > > On Jul 6, 2013 5:37 PM, "Joey Chan" <email address hidden> wrote:
> > > >
> > > > Hi Carla,
> > >
> > > Hi Joey,
> > >
> > > >
> > > > Thanks for your Autopilot, but I know nothing about python. Seems the
> > > Autopilot will detect the "objectname" to use it for testing.
> > > >
> > > > Note, we will have a huge update in following weeks, called "alpha
> > > release", some of current source files will become deprecated. Just let u
> > > know
> > > >
> > > > :)
> > >
> > > Ok thanks :-)
> > > But does this mean it's better to wait instead of writing other Autopilot
> > > tests?
> > > Or is it wise to continue writing them all the same and then fix them
> > > afterwards?
> > >
> > > Carla
> > --
> >
> > https://code.launchpad.net/~carla-sella/ubuntu-rssreader-app/ubuntu-
> rssreader-test-add-view-feeds/+merge/173316
> > You are the owner of
> > lp:~carla-sella/ubuntu-rssreader-app/ubuntu-rssreader-test-add-view-feeds.
> >

Revision history for this message
Carla Sella (carla-sella) wrote :

Ok, thanks.

Revision history for this message
Francis Ginther (fginther) wrote :

The ubuntu-rssreader-app interface has been changed (drastically I might add). At the moment, I don't even see how to add new feeds or remove feeds. We could still try to get this code working with the old app code for our own satisfaction that we've figured things out, but it can't be merged in it's current context.

I was still tinkering with my attempt (lp:~fginther/ubuntu-rssreader-app/test-update-take-2) but now I'm running into the problem of needing to remove an existing feed when the test begins. Maybe figure this out later, for now I need to break for my evening.

Revision history for this message
Joey Chan (qqworini) wrote :

Hi Francis,

Currently we just done the view functions, feeds and topics management are being coding, once they're done, we will let u guys know :)

> The ubuntu-rssreader-app interface has been changed (drastically I might add).
> At the moment, I don't even see how to add new feeds or remove feeds. We could
> still try to get this code working with the old app code for our own
> satisfaction that we've figured things out, but it can't be merged in it's
> current context.
>
> I was still tinkering with my attempt (lp:~fginther/ubuntu-rssreader-app/test-
> update-take-2) but now I'm running into the problem of needing to remove an
> existing feed when the test begins. Maybe figure this out later, for now I
> need to break for my evening.

Revision history for this message
Roman Shchekin (mrqtros) wrote :

Management functions are near to ready, w8 a little.
Today I'll finish them and merge with trunk =)

16.07.13 6:52 Joey Chan написал(а):

Hi Francis,

Currently we just done the view functions, feeds and topics management are being coding, once they're done, we will let u guys know :)

> The ubuntu-rssreader-app interface has been changed (drastically I might add).
> At the moment, I don't even see how to add new feeds or remove feeds. We could
> still try to get this code working with the old app code for our own
> satisfaction that we've figured things out, but it can't be merged in it's
> current context.
>
> I was still tinkering with my attempt (lp:~fginther/ubuntu-rssreader-app/test-
> update-take-2) but now I'm running into the problem of needing to remove an
> existing feed when the test begins. Maybe figure this out later, for now I
> need to break for my evening.

--
https://code.launchpad.net/~carla-sella/ubuntu-rssreader-app/ubuntu-rssreader-test-add-view-feeds/+merge/173316

Your team Ubuntu RSS Feed Reader Developers is subscribed to branch lp:ubuntu-rssreader-app.

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

I believe most of the major RSS reader changes have landed -- I *think* we can get back to fixing these up and merging :-)

Revision history for this message
Roman Shchekin (mrqtros) wrote :

Yep, Nick!
Big merge landed, we will use much more smaller merges next time :)

2013/7/23 Nicholas Skaggs <email address hidden>

> I believe most of the major RSS reader changes have landed -- I *think* we
> can get back to fixing these up and merging :-)
> --
>
> https://code.launchpad.net/~carla-sella/ubuntu-rssreader-app/ubuntu-rssreader-test-add-view-feeds/+merge/173316
> Your team Ubuntu RSS Feed Reader Developers is subscribed to branch
> lp:ubuntu-rssreader-app.
>

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

This appears to be blocked due to https://bugs.launchpad.net/ubuntu-rssreader-app/+bug/1203528

Can we fix the bug to allow adding a feed?

Revision history for this message
David Planella (dpm) wrote :

This bug was fixed a while ago. Is there anything else that is preventing this test to land?

Revision history for this message
Carla Sella (carla-sella) wrote :

I will check it again and see if it works now.

Revision history for this message
Carla Sella (carla-sella) wrote :

I sound this bug: https://bugs.launchpad.net/ubuntu-rssreader-app/+bug/1231137 and as I run my tests on a Desktop, first, I will wait for it to be fixed so to be able to carry on with the add feed test first.

Unmerged revisions

18. By Carla Sella

applied Francis Ginther's (fginther) suggestions/improvements

17. By Carla Sella

autopilot ubuntu_rssfeed_app test with two tests

16. By Carla Sella

ubuntu rssreader autopilot test - renamed test directory from rssreader_app to ubuntu_rssreader_app

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'FeedListPage.qml'
--- FeedListPage.qml 2013-06-16 07:43:59 +0000
+++ FeedListPage.qml 2013-07-12 20:14:27 +0000
@@ -145,6 +145,7 @@
145 } // header145 } // header
146146
147 delegate: ListItems.Subtitled {147 delegate: ListItems.Subtitled {
148 objectName: "feedItem"
148 text: (model.title == "")? model.source /*+ " " + model.status*/ : model.title /*+ " " + model.status*/ // Debug - displaying status149 text: (model.title == "")? model.source /*+ " " + model.status*/ : model.title /*+ " " + model.status*/ // Debug - displaying status
149 subText: (model.description != undefined)? model.description : "EMPTY"150 subText: (model.description != undefined)? model.description : "EMPTY"
150 progression: true151 progression: true
@@ -333,6 +334,7 @@
333 actions: ActionList {334 actions: ActionList {
334 id: popoverActionsList335 id: popoverActionsList
335 Action {336 Action {
337 objectName: "updateFeed"
336 id: nameActionUpdate338 id: nameActionUpdate
337 text: i18n.tr("Update")339 text: i18n.tr("Update")
338 onTriggered: {340 onTriggered: {
@@ -369,6 +371,7 @@
369 }371 }
370372
371 Action {373 Action {
374 objectName: "removeFeed"
372 text: i18n.tr("Remove")375 text: i18n.tr("Remove")
373 onTriggered: {376 onTriggered: {
374 PopupUtils.close(popover)377 PopupUtils.close(popover)
@@ -480,6 +483,7 @@
480 anchors.centerIn: parent483 anchors.centerIn: parent
481484
482 TextField {485 TextField {
486 objectName: "newFeedUrl"
483 id: tfFeedUrl487 id: tfFeedUrl
484 anchors.horizontalCenter: parent.horizontalCenter488 anchors.horizontalCenter: parent.horizontalCenter
485 width: parent.width489 width: parent.width
486490
=== modified file 'tests/autopilot/ubuntu_rssreader_app/emulators/main_window.py'
--- tests/autopilot/ubuntu_rssreader_app/emulators/main_window.py 2013-05-31 12:59:55 +0000
+++ tests/autopilot/ubuntu_rssreader_app/emulators/main_window.py 2013-07-12 20:14:27 +0000
@@ -15,10 +15,24 @@
15 """15 """
16 def __init__(self, app):16 def __init__(self, app):
17 self.app = app17 self.app = app
1818
19 def get_qml_view(self):19 def get_new_event_name_input_box(self):
20 """Get the main QML view"""20 return self.app.select_single("TextField", objectName="newFeedUrl")
21 return self.app.select_single("QQuickView")21
2222 def get_confirm_button(self):
23 def get_toolbar(self):23 return self.app.select_single('Button', text='confirm')
24 return self.app.select_single("Toolbar")24
25 def get_list_all_news(self):
26 return self.app.select_single('Subtitled', text='All news')
27
28 def get_individual_feed(self):
29 return self.app.select_single('Subtitled', objectName='feedItem')
30
31 def get_canonical_feed(self):
32 return self.app.select_single('Subtitled', text='Canonical')
33
34 def get_update_feed_context_menu_item(self):
35 return self.app.select_single("Empty", text="Update")
36
37 def get_remove_form_popOver(self):
38 return self.app.select_single("Empty", text="Remove")
25\ No newline at end of file39\ No newline at end of file
2640
=== added file 'tests/autopilot/ubuntu_rssreader_app/emulators/ubuntusdk.py'
--- tests/autopilot/ubuntu_rssreader_app/emulators/ubuntusdk.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntu_rssreader_app/emulators/ubuntusdk.py 2013-07-12 20:14:27 +0000
@@ -0,0 +1,154 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2013 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
7# published 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# Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com>
18
19from testtools.matchers import Equals, NotEquals, Not, Is
20from autopilot.matchers import Eventually
21
22class ubuntusdk(object):
23 """An emulator class that makes it easy to interact with the ubuntu sdk applications."""
24
25 def __init__(self, autopilot, app):
26 self.app = app
27 self.autopilot = autopilot
28
29 def get_qml_view(self):
30 """Get the main QML view"""
31 return self.app.select_single("QQuickView")
32
33 def get_object(self, typeName, name):
34 """Get a specific object"""
35 return self.app.select_single(typeName, objectName=name)
36
37 def get_objects(self, typeName, name):
38 """Get more than one object"""
39 return self.app.select_many(typeName, objectName=name)
40
41 def switch_to_tab(self, tab):
42 """Switch to the specified tab number"""
43 tabs = self.get_tabs()
44 currentTab = tabs.selectedTabIndex
45
46 #perform operations until tab == currentTab
47 while tab != currentTab:
48 if tab > currentTab:
49 self._previous_tab()
50 if tab < currentTab:
51 self._next_tab()
52 currentTab = tabs.selectedTabIndex
53
54 def toggle_toolbar(self):
55 """Toggle the toolbar between revealed and hidden"""
56 #check and see if the toolbar is open or not
57 if self.get_toolbar().opened:
58 self.hide_toolbar()
59 else:
60 self.open_toolbar()
61
62 def get_toolbar(self):
63 """Returns the toolbar in the main events view."""
64 return self.app.select_single("Toolbar")
65
66 def get_toolbar_button(self, buttonLabel):
67 """Returns the toolbar button at position index"""
68 toolbar = self.get_toolbar()
69 if not toolbar.opened:
70 self.open_toolbar()
71 row = toolbar.select_single("QQuickRow")
72 loaderList = row.select_many("QQuickLoader")
73 for loader in loaderList:
74 buttonList = loader.select_many("Button")
75 for button in buttonList:
76 if button.text == buttonLabel:
77 return button
78
79 def click_toolbar_button(self, buttonLabel):
80 """Clicks the toolbar button with buttonLabel"""
81 #The toolbar button is assumed to be the following format
82 #ToolbarActions {
83 # Action {
84 # objectName: "name"
85 # text: value
86 button = self.get_toolbar_button(buttonLabel)
87 self.autopilot.pointing_device.click_object(button)
88
89 def open_toolbar(self):
90 """Open the toolbar"""
91 qmlView = self.get_qml_view()
92
93 lineX = qmlView.x + qmlView.width * 0.50
94 startY = qmlView.y + qmlView.height - 1
95 stopY = qmlView.y + qmlView.height * 0.95
96
97 self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
98
99 def hide_toolbar(self):
100 """Hide the toolbar"""
101 qmlView = self.get_qml_view()
102
103 lineX = qmlView.x + qmlView.width * 0.50
104 startY = qmlView.y + qmlView.height * 0.95
105 stopY = qmlView.y + qmlView.height - 1
106
107 self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
108
109 def set_popup_value(self, popover, button, value):
110 """Changes the given popover selector to the request value
111 At the moment this only works for values that are currently visible. To
112 access the remaining items, a help method to drag and recheck is needed."""
113 #The popover is assumed to be the following format
114 # Popover {
115 # Column {
116 # ListView {
117 # delegate: Standard {
118 # objectName: "name"
119 # text: value
120
121 self.autopilot.pointing_device.click_object(button)
122 #we'll get all matching objects, incase the popover is reused between buttons
123 itemList = lambda: self.get_objects("Standard", popover)
124
125 for item in itemList():
126 if item.get_properties()['text'] == value:
127 self.autopilot.pointing_device.click_object(item)
128
129 def get_tabs(self):
130 """Return all tabs"""
131 return self.get_object("Tabs", "rootTabs")
132
133 def _previous_tab(self):
134 """Switch to the previous tab"""
135 qmlView = self.get_qml_view()
136
137 startX = qmlView.x + qmlView.width * 0.35
138 stopX = qmlView.x + qmlView.width * 0.50
139 lineY = qmlView.y + qmlView.height * 0.05
140
141 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
142 self.autopilot.pointing_device.click()
143 self.autopilot.pointing_device.click()
144
145 def _next_tab(self):
146 """Switch to the next tab"""
147 qmlView = self.get_qml_view()
148
149 startX = qmlView.x + qmlView.width * 0.50
150 stopX = qmlView.x + qmlView.width * 0.35
151 lineY = qmlView.y + qmlView.height * 0.05
152
153 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
154 self.autopilot.pointing_device.click()
0155
=== modified file 'tests/autopilot/ubuntu_rssreader_app/tests/__init__.py'
--- tests/autopilot/ubuntu_rssreader_app/tests/__init__.py 2013-05-31 12:59:55 +0000
+++ tests/autopilot/ubuntu_rssreader_app/tests/__init__.py 2013-07-12 20:14:27 +0000
@@ -12,8 +12,11 @@
12from autopilot.input import Mouse, Touch, Pointer12from autopilot.input import Mouse, Touch, Pointer
13from autopilot.platform import model13from autopilot.platform import model
14from autopilot.testcase import AutopilotTestCase14from autopilot.testcase import AutopilotTestCase
15from autopilot.matchers import Eventually
16from testtools.matchers import Equals, NotEquals
1517
16from ubuntu_rssreader_app.emulators.main_window import MainWindow18from ubuntu_rssreader_app.emulators.main_window import MainWindow
19from ubuntu_rssreader_app.emulators.ubuntusdk import ubuntusdk
1720
1821
19class RssreaderTestCase(AutopilotTestCase):22class RssreaderTestCase(AutopilotTestCase):
@@ -53,3 +56,7 @@
53 @property56 @property
54 def main_window(self):57 def main_window(self):
55 return MainWindow(self.app)58 return MainWindow(self.app)
59
60 @property
61 def ubuntusdk(self):
62 return ubuntusdk(self, self.app)
5663
=== modified file 'tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py'
--- tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py 2013-05-31 12:59:55 +0000
+++ tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py 2013-07-12 20:14:27 +0000
@@ -10,29 +10,114 @@
10from __future__ import absolute_import10from __future__ import absolute_import
1111
12from autopilot.matchers import Eventually12from autopilot.matchers import Eventually
13from testtools.matchers import Equals13from testtools.matchers import Equals, NotEquals
1414
15from ubuntu_rssreader_app.tests import RssreaderTestCase15from ubuntu_rssreader_app.tests import RssreaderTestCase
1616from time import sleep
1717
18class TestMainWindow(RssreaderTestCase):18class TestMainWindow(RssreaderTestCase):
1919
20 def setUp(self):20 def setUp(self):
21 super(TestMainWindow, self).setUp()21 super(TestMainWindow, self).setUp()
22 self.assertThat(22 self.assertThat(
23 self.main_window.get_qml_view().visible, Eventually(Equals(True)))23 self.ubuntusdk.get_qml_view().visible, Eventually(Equals(True)))
2424
25 def tearDown(self):25 def tearDown(self):
26 super(TestMainWindow, self).tearDown()26 super(TestMainWindow, self).tearDown()
2727
28 def test_toolbar_shows(self):28 def test_add_new_feed(self):
29 """Make sure that dragging from the bottom reveals the hidden29 event_view = self.ubuntusdk.get_qml_view()
30 toolbar."""30 self.insert_canonical_feed()
31 toolbar = self.main_window.get_toolbar()31 self.remove_canonical_feed(event_view)
3232
33 x, y, w, h = toolbar.globalRect33 def test_view_feeds(self):
34 tx = x + (w / 2)34 event_view = self.ubuntusdk.get_qml_view()
35 ty = y + (h - 2)35 #add Canonical feed
3636 self.insert_canonical_feed()
37 self.pointing_device.drag(tx, ty, tx, ty - h)37
38 self.assertThat(toolbar.state, Eventually(Equals("spread")))38 #-----> view all news:
39 #click list all news list item
40 list_all_news = self.main_window.get_list_all_news()
41 #does it exist?
42 self.assertThat(list_all_news, NotEquals(None))
43 #let's click it
44 self.mouse.move_to_object(list_all_news)
45 self.mouse.click()
46 #verify list all news page is open
47 lambda: self.assertThat(event_view, Eventually(Equals("ArticleListPage.qml")))
48 self.click_back_Toolbar_Button()
49
50 #-----> view individual feed:
51 event_view = self.ubuntusdk.get_qml_view()
52 #click Canonical feed item
53 self.select_and_click_canonical_feed(event_view)
54 self.click_back_Toolbar_Button()
55
56 self.remove_canonical_feed(event_view)
57
58 def select_and_click_canonical_feed(self,event_view):
59 canonical_feed = lambda: self.main_window.get_canonical_feed()
60 #does it exist?
61 self.assertThat(canonical_feed, Eventually(NotEquals(None)))
62 #click on Canonical feed
63 self.mouse.move_to_object(canonical_feed())
64 self.mouse.click()
65 #verify list all news page is open
66 lambda: self.assertThat(event_view, Eventually(Equals("ArticleListPage.qml")))
67
68
69 def insert_canonical_feed(self):
70 #toggle toolbar
71 self.ubuntusdk.toggle_toolbar()
72 #click on add feed button
73 self.ubuntusdk.click_toolbar_button('Add feed')
74 #type feed in input field
75 new_Feed_Url = lambda: self.main_window.get_new_event_name_input_box()
76 self.assertThat(new_Feed_Url, Eventually(NotEquals(None)))
77 self.pointing_device.click_object(new_Feed_Url())
78 self.keyboard.type("http://www.canonical.com/rss.xml")
79 #click confirm button to save RSS
80 confirm_btn = self.main_window.get_confirm_button()
81 #does it exist?
82 self.assertThat(confirm_btn, NotEquals(None))
83 #let's click it
84 self.mouse.move_to_object(confirm_btn)
85 self.mouse.click()
86 #verify Feed list page is open
87 lambda: self.assertThat(event_view, Eventually(Equals("FeedListPage.qml")))
88 #check that feed is updated, not empty
89 canonical_feed_before = "http://www.canonical.com/rss.xml"
90 self.assertThat(self._canonical_feed, Eventually(Equals(canonical_feed_before)))
91 #verify feed has been added
92 self.assertThat(self._canonical_feed, Eventually(Equals("Canonical")))
93
94 def _canonical_feed(self):
95 try:
96 return self.main_window.get_individual_feed().text
97 except StateNotFoundError:
98 return None
99
100 def remove_canonical_feed(self,event_view):
101 canonical_feed = self.main_window.get_canonical_feed()
102 #does it exist?
103 self.assertThat(canonical_feed, NotEquals(None))
104 #verify list all news page is open
105 lambda: self.assertThat(event_view, Eventually(Equals("ArticleListPage.qml")))
106 #let's click it
107 self.mouse.move_to_object(canonical_feed)
108 self.mouse.click_object(canonical_feed, button=1, press_duration=4)
109 #select remove feed from popover context menu
110 remove_in_context_menu = self.main_window.get_remove_form_popOver()
111 #let's click it
112 self.mouse.move_to_object(remove_in_context_menu)
113 self.mouse.click()
114 self.assertThat(self.main_window.get_canonical_feed, Eventually(Equals(None), timeout=30))
115
116 def click_back_Toolbar_Button(self):
117 #toggle toolbar
118 self.ubuntusdk.toggle_toolbar()
119 #click on back button
120 backTBButton = self.app.select_single('Button', text='Back')
121 #let's click it
122 self.mouse.move_to_object(backTBButton)
123 self.mouse.click()

Subscribers

People subscribed via source and target branches