Merge lp:~carla-sella/ubuntu-rssreader-app/open_feed_test into lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk

Proposed by Carla Sella
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 210
Merged at revision: 219
Proposed branch: lp:~carla-sella/ubuntu-rssreader-app/open_feed_test
Merge into: lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk
Diff against target: 119 lines (+48/-6)
4 files modified
ArticleViewItem.qml (+2/-0)
ListModePage.qml (+1/-0)
tests/autopilot/shorts_app/emulators.py (+28/-6)
tests/autopilot/shorts_app/tests/test_rssreader.py (+17/-0)
To merge this branch: bzr merge lp:~carla-sella/ubuntu-rssreader-app/open_feed_test
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Needs Fixing
Leo Arias Pending
Review via email: mp+214598@code.launchpad.net

Commit message

Test for opening a feed in feed list.

Description of the change

Hello Leo,
I am trying to test opening a feed in a feed list.
I am unable to get the count and currentIndex properties of the Article view item's Quick list view (https://lh3.googleusercontent.com/-wumo9Dj3-Qg/U0L7f_s6e1I/AAAAAAAAF2o/J1rJVKmJW6g/w1309-h737-no/QquickListView.png).
If count is greater than 0 and currentIndex is greater than -1 then it means that a feed has been opened (clicked on).
I just need to put an assert to verify the feed I clicked on has been opened.

To post a comment you must log in.
Revision history for this message
Carla Sella (carla-sella) wrote :

I forgot, I get a StateNotFoundError: Object not found with name 'QQuickListView' and properties {'ObjectName': 'articleviewitem_listview'}.

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

Fixed asserts at the end of the test.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

Hello Carla,

This is a good test, but it could be better if we hide the implementation details behind methods that are called after actions that a user can do.

Have you read https://code.google.com/p/selenium/wiki/PageObjects ?
We are trying to follow that patter everywhere, because it makes the tests more readable and easier to maintain.

Some important details:

38 + def get_topictab_articleviewitem(self, test_feed_title):
42 + def get_articleviewitem_listview(self, test_feed_title):

Any method that returns an autopilot object should be private and not be called directly from the test cases. So they should be:
_get_topictab_articleviewitem
_get_articleviewitem_listview

77 + feed_in_feeedlist = self.main_view.get_feed_in_feedlist(
78 + test_topic, test_feed_title)
79 + self.pointing_device.click_object(feed_in_feeedlist)

We can wrap this in a method called: open_feed_item.

81 + article_count = self.main_view.\
82 + get_articleviewitem_listview(test_feed_title).count

We can wrap this in a method called: get_article_count.

I'm going to take half a holiday today, so I'm about to leave to enjoy the sun rays. But tomorrow I'll be all day, ping me and I'll go into more details if you have doubts with the page object pattern.

Thanks again, a hug for your code.

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

> Hello Carla,

Hello Leo,

>
> This is a good test, but it could be better if we hide the implementation
> details behind methods that are called after actions that a user can do.
>
> Have you read https://code.google.com/p/selenium/wiki/PageObjects ?

No I haven't read it but I will now :).

> We are trying to follow that patter everywhere, because it makes the tests
> more readable and easier to maintain.
>
> Some important details:
>
> 38 + def get_topictab_articleviewitem(self, test_feed_title):
> 42 + def get_articleviewitem_listview(self, test_feed_title):
>
> Any method that returns an autopilot object should be private and not be
> called directly from the test cases. So they should be:
> _get_topictab_articleviewitem
> _get_articleviewitem_listview

I put
 38 + def get_topictab_articleviewitem(self, test_feed_title):
 42 + def get_articleviewitem_listview(self, test_feed_title):

in emulators.py not in test_rssreader.py, if I make them private in emulators.py I will not be able to use them in test_rssreader.py, so do I have to make them private and move them to test_rssreader.py ?
I made them private and moved them to test_rssreader.py if this is not ok, tell me and I will put them back to emulators.py, but the cannot be private.

[...]
>
> I'm going to take half a holiday today, so I'm about to leave to enjoy the sun
> rays.

Lucky you :D.

>But tomorrow I'll be all day, ping me and I'll go into more details if
> you have doubts with the page object pattern.
>
> Thanks again, a hug for your code.

Thank you.

Carla

207. By Carla Sella

Fixed test_open_feed_item as Leo suggested.

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

Hello Leo,
I put back the:
 38 + def get_topictab_articleviewitem(self, test_feed_title):
 42 + def get_articleviewitem_listview(self, test_feed_title):
to emulators.py.
I will ping you for this tomorrow :).

Carla

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
208. By Carla Sella

Fixed assert in test_open_listmode_feed_item test (renamed form test_open_feed_item).

209. By Carla Sella

Bzr merged.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
David Planella (dpm) wrote :

Leo, Nick, would you mind having a look at the latest changes from Carla on this branch? Does it now look good to you for approval?

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

Hmm, when I run this I'm getting this bug:

https://bugs.launchpad.net/ubuntu-rssreader-app/+bug/1314531

Wild, and not related to this change I'm sure.

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
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 :

Needs to use the new variables from trunk. Rebase to trunk and you will see them. This fixes the build.

_EXTERNAL_FEED_URL = 'http://www.canonical.com/rss.xml'
_EXTERNAL_FEED_TITLE = 'Ubuntu Insights'

Then +1 from me.

review: Needs Fixing
210. By Carla Sella

Fixed test_open_listmode_feed_item with new variables from trunk.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ArticleViewItem.qml'
2--- ArticleViewItem.qml 2014-04-16 15:54:38 +0000
3+++ ArticleViewItem.qml 2014-04-30 18:58:28 +0000
4@@ -126,6 +126,7 @@
5
6 Flickable {
7 id: scrollArea
8+ objectName: "articleview_flickable"
9
10 clip: true
11
12@@ -173,6 +174,7 @@
13 }
14
15 Label {
16+ objectName: "articleviewitem_title"
17 fontSize: "large"
18 text: model.title
19 anchors.horizontalCenter: parent.horizontalCenter
20
21=== modified file 'ListModePage.qml'
22--- ListModePage.qml 2014-03-08 15:27:10 +0000
23+++ ListModePage.qml 2014-04-30 18:58:28 +0000
24@@ -141,6 +141,7 @@
25
26 Label {
27 id: labelTitle
28+ objectName: "label_title"
29
30 text: model.title
31 width: parent.width
32
33=== modified file 'tests/autopilot/shorts_app/emulators.py'
34--- tests/autopilot/shorts_app/emulators.py 2014-04-23 17:48:20 +0000
35+++ tests/autopilot/shorts_app/emulators.py 2014-04-30 18:58:28 +0000
36@@ -170,8 +170,7 @@
37 return self.select_single("ManageTopicsPage")
38
39 def get_rss_feed_page(self):
40- return self.wait_select_single(
41- "RssFeedPage", objectName="rssfeedpage")
42+ return self.wait_select_single("RssFeedPage", objectName="rssfeedpage")
43
44 def get_shorts_tab(self):
45 return self.wait_select_single("ShortsTab", objectName="Tab0")
46@@ -217,18 +216,41 @@
47 def get_topic_tab(self, topic):
48 return self.wait_select_single("TopicTab", title=topic)
49
50- def get_feed_in_feedlist(self, topic, feed):
51- itemList = self.get_feedlist(topic)
52+ @autopilot_logging.log_action(logger.info)
53+ def open_feed_item(self, test_topic, test_feed_title):
54+ feed_in_feeedlist = self._get_feed_in_feedlist(
55+ test_topic, test_feed_title)
56+ self.pointing_device.click_object(feed_in_feeedlist)
57+
58+ def _get_feed_in_feedlist(self, topic, feed):
59+ itemList = self._get_feedlist(topic)
60 for item in itemList:
61 label = item.select_single("Label", objectName="labelFeedname")
62 if label.text == feed:
63 return item
64
65- def get_feedlist(self, topic):
66- #tab = self.get_topic_tab(topic)
67+ def _get_feedlist(self, topic):
68 items = self.select_many("UbuntuShape", objectName="feedlistitems")
69 return items
70
71+ def get_feed_in_feedlist_title(self, test_topic, test_feed_title):
72+ feed_in_feeedlist = self._get_feed_in_feedlist(
73+ test_topic, test_feed_title)
74+ return feed_in_feeedlist.select_single(
75+ "Label", objectName="label_title").text
76+
77+ def get_articleviewitem_title(self):
78+ flickable = self._get_articleview_flickables()
79+ return flickable.select_single(
80+ "Label", objectName="articleviewitem_title").text
81+
82+ def _get_articleview_flickables(self):
83+ flickables_list = self.select_many(
84+ "QQuickFlickable", objectName="articleview_flickable")
85+ for flickable in flickables_list:
86+ if flickable.focus:
87+ return flickable
88+
89 def get_editfeed_topic_valueselector(self):
90 return self.wait_select_single(
91 "ValueSelector", objectName="valueselector")
92
93=== modified file 'tests/autopilot/shorts_app/tests/test_rssreader.py'
94--- tests/autopilot/shorts_app/tests/test_rssreader.py 2014-04-30 17:10:41 +0000
95+++ tests/autopilot/shorts_app/tests/test_rssreader.py 2014-04-30 18:58:28 +0000
96@@ -205,6 +205,23 @@
97 if not current_tab.isListMode:
98 self.main_view.change_view_mode()
99
100+ def test_open_listmode_feed_item(self):
101+ """"test to ensure list mode feed items can be opened"""
102+
103+ test_feed_url = _EXTERNAL_FEED_URL
104+ test_feed_title = _EXTERNAL_FEED_TITLE
105+ test_topic = 'Test topic'
106+
107+ self.add_feed_to_new_topic(test_feed_url, test_feed_title, test_topic)
108+ new_topic_tab = self.main_view.get_topic_tab(test_topic)
109+ self.ensure_list_view_mode(new_topic_tab)
110+
111+ self.main_view.open_feed_item(test_topic, test_feed_title)
112+ self.assertEqual(
113+ self.main_view.get_feed_in_feedlist_title(
114+ test_topic, test_feed_title),
115+ self.main_view.get_articleviewitem_title())
116+
117 @unittest.skip("Can't see or get dynamic tabs")
118 def test_edit_topic(self):
119 """test edit topic"""

Subscribers

People subscribed via source and target branches