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
1=== modified file 'FeedListPage.qml'
2--- FeedListPage.qml 2013-06-16 07:43:59 +0000
3+++ FeedListPage.qml 2013-07-12 20:14:27 +0000
4@@ -145,6 +145,7 @@
5 } // header
6
7 delegate: ListItems.Subtitled {
8+ objectName: "feedItem"
9 text: (model.title == "")? model.source /*+ " " + model.status*/ : model.title /*+ " " + model.status*/ // Debug - displaying status
10 subText: (model.description != undefined)? model.description : "EMPTY"
11 progression: true
12@@ -333,6 +334,7 @@
13 actions: ActionList {
14 id: popoverActionsList
15 Action {
16+ objectName: "updateFeed"
17 id: nameActionUpdate
18 text: i18n.tr("Update")
19 onTriggered: {
20@@ -369,6 +371,7 @@
21 }
22
23 Action {
24+ objectName: "removeFeed"
25 text: i18n.tr("Remove")
26 onTriggered: {
27 PopupUtils.close(popover)
28@@ -480,6 +483,7 @@
29 anchors.centerIn: parent
30
31 TextField {
32+ objectName: "newFeedUrl"
33 id: tfFeedUrl
34 anchors.horizontalCenter: parent.horizontalCenter
35 width: parent.width
36
37=== modified file 'tests/autopilot/ubuntu_rssreader_app/emulators/main_window.py'
38--- tests/autopilot/ubuntu_rssreader_app/emulators/main_window.py 2013-05-31 12:59:55 +0000
39+++ tests/autopilot/ubuntu_rssreader_app/emulators/main_window.py 2013-07-12 20:14:27 +0000
40@@ -15,10 +15,24 @@
41 """
42 def __init__(self, app):
43 self.app = app
44-
45- def get_qml_view(self):
46- """Get the main QML view"""
47- return self.app.select_single("QQuickView")
48-
49- def get_toolbar(self):
50- return self.app.select_single("Toolbar")
51+
52+ def get_new_event_name_input_box(self):
53+ return self.app.select_single("TextField", objectName="newFeedUrl")
54+
55+ def get_confirm_button(self):
56+ return self.app.select_single('Button', text='confirm')
57+
58+ def get_list_all_news(self):
59+ return self.app.select_single('Subtitled', text='All news')
60+
61+ def get_individual_feed(self):
62+ return self.app.select_single('Subtitled', objectName='feedItem')
63+
64+ def get_canonical_feed(self):
65+ return self.app.select_single('Subtitled', text='Canonical')
66+
67+ def get_update_feed_context_menu_item(self):
68+ return self.app.select_single("Empty", text="Update")
69+
70+ def get_remove_form_popOver(self):
71+ return self.app.select_single("Empty", text="Remove")
72\ No newline at end of file
73
74=== added file 'tests/autopilot/ubuntu_rssreader_app/emulators/ubuntusdk.py'
75--- tests/autopilot/ubuntu_rssreader_app/emulators/ubuntusdk.py 1970-01-01 00:00:00 +0000
76+++ tests/autopilot/ubuntu_rssreader_app/emulators/ubuntusdk.py 2013-07-12 20:14:27 +0000
77@@ -0,0 +1,154 @@
78+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
79+#
80+# Copyright (C) 2013 Canonical Ltd
81+#
82+# This program is free software: you can redistribute it and/or modify
83+# it under the terms of the GNU General Public License version 3 as
84+# published by the Free Software Foundation.
85+#
86+# This program is distributed in the hope that it will be useful,
87+# but WITHOUT ANY WARRANTY; without even the implied warranty of
88+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
89+# GNU General Public License for more details.
90+#
91+# You should have received a copy of the GNU General Public License
92+# along with this program. If not, see <http://www.gnu.org/licenses/>.
93+#
94+# Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com>
95+
96+from testtools.matchers import Equals, NotEquals, Not, Is
97+from autopilot.matchers import Eventually
98+
99+class ubuntusdk(object):
100+ """An emulator class that makes it easy to interact with the ubuntu sdk applications."""
101+
102+ def __init__(self, autopilot, app):
103+ self.app = app
104+ self.autopilot = autopilot
105+
106+ def get_qml_view(self):
107+ """Get the main QML view"""
108+ return self.app.select_single("QQuickView")
109+
110+ def get_object(self, typeName, name):
111+ """Get a specific object"""
112+ return self.app.select_single(typeName, objectName=name)
113+
114+ def get_objects(self, typeName, name):
115+ """Get more than one object"""
116+ return self.app.select_many(typeName, objectName=name)
117+
118+ def switch_to_tab(self, tab):
119+ """Switch to the specified tab number"""
120+ tabs = self.get_tabs()
121+ currentTab = tabs.selectedTabIndex
122+
123+ #perform operations until tab == currentTab
124+ while tab != currentTab:
125+ if tab > currentTab:
126+ self._previous_tab()
127+ if tab < currentTab:
128+ self._next_tab()
129+ currentTab = tabs.selectedTabIndex
130+
131+ def toggle_toolbar(self):
132+ """Toggle the toolbar between revealed and hidden"""
133+ #check and see if the toolbar is open or not
134+ if self.get_toolbar().opened:
135+ self.hide_toolbar()
136+ else:
137+ self.open_toolbar()
138+
139+ def get_toolbar(self):
140+ """Returns the toolbar in the main events view."""
141+ return self.app.select_single("Toolbar")
142+
143+ def get_toolbar_button(self, buttonLabel):
144+ """Returns the toolbar button at position index"""
145+ toolbar = self.get_toolbar()
146+ if not toolbar.opened:
147+ self.open_toolbar()
148+ row = toolbar.select_single("QQuickRow")
149+ loaderList = row.select_many("QQuickLoader")
150+ for loader in loaderList:
151+ buttonList = loader.select_many("Button")
152+ for button in buttonList:
153+ if button.text == buttonLabel:
154+ return button
155+
156+ def click_toolbar_button(self, buttonLabel):
157+ """Clicks the toolbar button with buttonLabel"""
158+ #The toolbar button is assumed to be the following format
159+ #ToolbarActions {
160+ # Action {
161+ # objectName: "name"
162+ # text: value
163+ button = self.get_toolbar_button(buttonLabel)
164+ self.autopilot.pointing_device.click_object(button)
165+
166+ def open_toolbar(self):
167+ """Open the toolbar"""
168+ qmlView = self.get_qml_view()
169+
170+ lineX = qmlView.x + qmlView.width * 0.50
171+ startY = qmlView.y + qmlView.height - 1
172+ stopY = qmlView.y + qmlView.height * 0.95
173+
174+ self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
175+
176+ def hide_toolbar(self):
177+ """Hide the toolbar"""
178+ qmlView = self.get_qml_view()
179+
180+ lineX = qmlView.x + qmlView.width * 0.50
181+ startY = qmlView.y + qmlView.height * 0.95
182+ stopY = qmlView.y + qmlView.height - 1
183+
184+ self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
185+
186+ def set_popup_value(self, popover, button, value):
187+ """Changes the given popover selector to the request value
188+ At the moment this only works for values that are currently visible. To
189+ access the remaining items, a help method to drag and recheck is needed."""
190+ #The popover is assumed to be the following format
191+ # Popover {
192+ # Column {
193+ # ListView {
194+ # delegate: Standard {
195+ # objectName: "name"
196+ # text: value
197+
198+ self.autopilot.pointing_device.click_object(button)
199+ #we'll get all matching objects, incase the popover is reused between buttons
200+ itemList = lambda: self.get_objects("Standard", popover)
201+
202+ for item in itemList():
203+ if item.get_properties()['text'] == value:
204+ self.autopilot.pointing_device.click_object(item)
205+
206+ def get_tabs(self):
207+ """Return all tabs"""
208+ return self.get_object("Tabs", "rootTabs")
209+
210+ def _previous_tab(self):
211+ """Switch to the previous tab"""
212+ qmlView = self.get_qml_view()
213+
214+ startX = qmlView.x + qmlView.width * 0.35
215+ stopX = qmlView.x + qmlView.width * 0.50
216+ lineY = qmlView.y + qmlView.height * 0.05
217+
218+ self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
219+ self.autopilot.pointing_device.click()
220+ self.autopilot.pointing_device.click()
221+
222+ def _next_tab(self):
223+ """Switch to the next tab"""
224+ qmlView = self.get_qml_view()
225+
226+ startX = qmlView.x + qmlView.width * 0.50
227+ stopX = qmlView.x + qmlView.width * 0.35
228+ lineY = qmlView.y + qmlView.height * 0.05
229+
230+ self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
231+ self.autopilot.pointing_device.click()
232
233=== modified file 'tests/autopilot/ubuntu_rssreader_app/tests/__init__.py'
234--- tests/autopilot/ubuntu_rssreader_app/tests/__init__.py 2013-05-31 12:59:55 +0000
235+++ tests/autopilot/ubuntu_rssreader_app/tests/__init__.py 2013-07-12 20:14:27 +0000
236@@ -12,8 +12,11 @@
237 from autopilot.input import Mouse, Touch, Pointer
238 from autopilot.platform import model
239 from autopilot.testcase import AutopilotTestCase
240+from autopilot.matchers import Eventually
241+from testtools.matchers import Equals, NotEquals
242
243 from ubuntu_rssreader_app.emulators.main_window import MainWindow
244+from ubuntu_rssreader_app.emulators.ubuntusdk import ubuntusdk
245
246
247 class RssreaderTestCase(AutopilotTestCase):
248@@ -53,3 +56,7 @@
249 @property
250 def main_window(self):
251 return MainWindow(self.app)
252+
253+ @property
254+ def ubuntusdk(self):
255+ return ubuntusdk(self, self.app)
256
257=== modified file 'tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py'
258--- tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py 2013-05-31 12:59:55 +0000
259+++ tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py 2013-07-12 20:14:27 +0000
260@@ -10,29 +10,114 @@
261 from __future__ import absolute_import
262
263 from autopilot.matchers import Eventually
264-from testtools.matchers import Equals
265+from testtools.matchers import Equals, NotEquals
266
267 from ubuntu_rssreader_app.tests import RssreaderTestCase
268-
269+from time import sleep
270
271 class TestMainWindow(RssreaderTestCase):
272
273 def setUp(self):
274 super(TestMainWindow, self).setUp()
275 self.assertThat(
276- self.main_window.get_qml_view().visible, Eventually(Equals(True)))
277+ self.ubuntusdk.get_qml_view().visible, Eventually(Equals(True)))
278
279 def tearDown(self):
280 super(TestMainWindow, self).tearDown()
281
282- def test_toolbar_shows(self):
283- """Make sure that dragging from the bottom reveals the hidden
284- toolbar."""
285- toolbar = self.main_window.get_toolbar()
286-
287- x, y, w, h = toolbar.globalRect
288- tx = x + (w / 2)
289- ty = y + (h - 2)
290-
291- self.pointing_device.drag(tx, ty, tx, ty - h)
292- self.assertThat(toolbar.state, Eventually(Equals("spread")))
293+ def test_add_new_feed(self):
294+ event_view = self.ubuntusdk.get_qml_view()
295+ self.insert_canonical_feed()
296+ self.remove_canonical_feed(event_view)
297+
298+ def test_view_feeds(self):
299+ event_view = self.ubuntusdk.get_qml_view()
300+ #add Canonical feed
301+ self.insert_canonical_feed()
302+
303+ #-----> view all news:
304+ #click list all news list item
305+ list_all_news = self.main_window.get_list_all_news()
306+ #does it exist?
307+ self.assertThat(list_all_news, NotEquals(None))
308+ #let's click it
309+ self.mouse.move_to_object(list_all_news)
310+ self.mouse.click()
311+ #verify list all news page is open
312+ lambda: self.assertThat(event_view, Eventually(Equals("ArticleListPage.qml")))
313+ self.click_back_Toolbar_Button()
314+
315+ #-----> view individual feed:
316+ event_view = self.ubuntusdk.get_qml_view()
317+ #click Canonical feed item
318+ self.select_and_click_canonical_feed(event_view)
319+ self.click_back_Toolbar_Button()
320+
321+ self.remove_canonical_feed(event_view)
322+
323+ def select_and_click_canonical_feed(self,event_view):
324+ canonical_feed = lambda: self.main_window.get_canonical_feed()
325+ #does it exist?
326+ self.assertThat(canonical_feed, Eventually(NotEquals(None)))
327+ #click on Canonical feed
328+ self.mouse.move_to_object(canonical_feed())
329+ self.mouse.click()
330+ #verify list all news page is open
331+ lambda: self.assertThat(event_view, Eventually(Equals("ArticleListPage.qml")))
332+
333+
334+ def insert_canonical_feed(self):
335+ #toggle toolbar
336+ self.ubuntusdk.toggle_toolbar()
337+ #click on add feed button
338+ self.ubuntusdk.click_toolbar_button('Add feed')
339+ #type feed in input field
340+ new_Feed_Url = lambda: self.main_window.get_new_event_name_input_box()
341+ self.assertThat(new_Feed_Url, Eventually(NotEquals(None)))
342+ self.pointing_device.click_object(new_Feed_Url())
343+ self.keyboard.type("http://www.canonical.com/rss.xml")
344+ #click confirm button to save RSS
345+ confirm_btn = self.main_window.get_confirm_button()
346+ #does it exist?
347+ self.assertThat(confirm_btn, NotEquals(None))
348+ #let's click it
349+ self.mouse.move_to_object(confirm_btn)
350+ self.mouse.click()
351+ #verify Feed list page is open
352+ lambda: self.assertThat(event_view, Eventually(Equals("FeedListPage.qml")))
353+ #check that feed is updated, not empty
354+ canonical_feed_before = "http://www.canonical.com/rss.xml"
355+ self.assertThat(self._canonical_feed, Eventually(Equals(canonical_feed_before)))
356+ #verify feed has been added
357+ self.assertThat(self._canonical_feed, Eventually(Equals("Canonical")))
358+
359+ def _canonical_feed(self):
360+ try:
361+ return self.main_window.get_individual_feed().text
362+ except StateNotFoundError:
363+ return None
364+
365+ def remove_canonical_feed(self,event_view):
366+ canonical_feed = self.main_window.get_canonical_feed()
367+ #does it exist?
368+ self.assertThat(canonical_feed, NotEquals(None))
369+ #verify list all news page is open
370+ lambda: self.assertThat(event_view, Eventually(Equals("ArticleListPage.qml")))
371+ #let's click it
372+ self.mouse.move_to_object(canonical_feed)
373+ self.mouse.click_object(canonical_feed, button=1, press_duration=4)
374+ #select remove feed from popover context menu
375+ remove_in_context_menu = self.main_window.get_remove_form_popOver()
376+ #let's click it
377+ self.mouse.move_to_object(remove_in_context_menu)
378+ self.mouse.click()
379+ self.assertThat(self.main_window.get_canonical_feed, Eventually(Equals(None), timeout=30))
380+
381+ def click_back_Toolbar_Button(self):
382+ #toggle toolbar
383+ self.ubuntusdk.toggle_toolbar()
384+ #click on back button
385+ backTBButton = self.app.select_single('Button', text='Back')
386+ #let's click it
387+ self.mouse.move_to_object(backTBButton)
388+ self.mouse.click()

Subscribers

People subscribed via source and target branches