Merge lp:~nskaggs/ubuntu-rssreader-app/expand-setup into lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 62
Merged at revision: 59
Proposed branch: lp:~nskaggs/ubuntu-rssreader-app/expand-setup
Merge into: lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk
Diff against target: 161 lines (+66/-5)
4 files modified
tests/autopilot/ubuntu_rssreader_app/emulators.py (+9/-0)
tests/autopilot/ubuntu_rssreader_app/tests/__init__.py (+33/-1)
tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py (+22/-4)
ubuntu-rssreader-app.qml (+2/-0)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-rssreader-app/expand-setup
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Approve
Review via email: mp+183912@code.launchpad.net

Commit message

expand test setup so a clean db is used, and the refresh dialog is expired before beginning a test

Description of the change

This enhances the autopilot tests to make them run more robustly by using a fresh database before each test, as well as adding an assert to wait for the the refresh dialog to disappear before starting a test.

To post a comment you must log in.
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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (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) :
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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntu_rssreader_app/emulators.py'
2--- tests/autopilot/ubuntu_rssreader_app/emulators.py 2013-08-13 20:21:58 +0000
3+++ tests/autopilot/ubuntu_rssreader_app/emulators.py 2013-09-05 05:27:18 +0000
4@@ -127,3 +127,12 @@
5
6 def get_add_a_topic(self):
7 return self.select_single("QQuickItem", objectName = "addTopic")
8+
9+ def get_refresh_feed_dialog(self):
10+ return self.select_single("Dialog", objectName = "refreshWaitDialog")
11+
12+ def get_refresh_dialog_cancel_button(self):
13+ return self.select_single("Button", objectName = "refreshCancel")
14+
15+ def get_network_activity(self):
16+ return self.select_single("ActivityIndicator", running = "True")
17
18=== modified file 'tests/autopilot/ubuntu_rssreader_app/tests/__init__.py'
19--- tests/autopilot/ubuntu_rssreader_app/tests/__init__.py 2013-08-13 02:52:16 +0000
20+++ tests/autopilot/ubuntu_rssreader_app/tests/__init__.py 2013-09-05 05:27:18 +0000
21@@ -21,12 +21,13 @@
22
23 import os.path
24 import os
25+import shutil
26
27 from autopilot.input import Mouse, Touch, Pointer
28 from autopilot.platform import model
29 from autopilot.testcase import AutopilotTestCase
30 from autopilot.matchers import Eventually
31-from testtools.matchers import GreaterThan
32+from testtools.matchers import GreaterThan, Equals
33
34 from ubuntuuitoolkit import emulators as toolkit_emulators
35 from ubuntu_rssreader_app import emulators
36@@ -43,10 +44,16 @@
37 scenarios = [('with touch', dict(input_device_class=Touch))]
38
39 local_location = "../../ubuntu-rssreader-app.qml"
40+ sqlite_dir = os.path.expanduser(
41+ "~/.local/share/Qt Project/QtQmlViewer/QML/OfflineStorage/Databases")
42+ backup_dir = sqlite_dir + ".backup"
43
44 def setUp(self):
45 self.pointing_device = Pointer(self.input_device_class.create())
46 super(RssReaderAppTestCase, self).setUp()
47+ self.temp_move_sqlite_db()
48+ self.addCleanup(self.restore_sqlite_db)
49+
50 if os.path.exists(self.local_location):
51 self.launch_test_local()
52 else:
53@@ -68,6 +75,31 @@
54 app_type='qt',
55 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
56
57+ def temp_move_sqlite_db(self):
58+ if os.path.exists(self.sqlite_dir):
59+ shutil.move(self.sqlite_dir, self.backup_dir)
60+ self.assertThat(
61+ lambda: os.path.exists(self.backup_dir),
62+ Eventually(Equals(True)))
63+
64+ def restore_sqlite_db(self):
65+ if os.path.exists(self.backup_dir) and os.path.exists(self.sqlite_dir):
66+ shutil.rmtree(self.sqlite_dir)
67+ self.assertThat(
68+ lambda: os.path.exists(self.sqlite_dir),
69+ Eventually(Equals(False)))
70+ shutil.move(self.backup_dir, self.sqlite_dir)
71+ self.assertTrue(
72+ lambda: os.path.exists(self.sqlite_dir),
73+ Eventually(Equals(True)))
74+ elif os.path.exists(self.backup_dir):
75+ shutil.move(self.backup_dir, self.sqlite_dir)
76+ self.assertTrue(
77+ lambda: os.path.exists(self.sqlite_dir),
78+ Eventually(Equals(True)))
79+ else:
80+ pass
81+
82 @property
83 def main_view(self):
84 return self.app.select_single(emulators.MainView)
85
86=== modified file 'tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py'
87--- tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py 2013-08-30 14:58:01 +0000
88+++ tests/autopilot/ubuntu_rssreader_app/tests/test_rssreader.py 2013-09-05 05:27:18 +0000
89@@ -26,6 +26,11 @@
90 super(TestMainWindow, self).setUp()
91 self.assertThat(self.main_view.visible, Eventually(Equals(True)))
92
93+ #wait for any updates to finish before beginning tests
94+ self.assertThat(self.main_view.get_network_activity, Eventually(Not(Is(None))))
95+ self.assertThat(self.main_view.get_network_activity, Eventually(Is(None)))
96+
97+
98 def _add_feed_and_topic(self):
99 """test add feed and topic"""
100 #open toolbar
101@@ -65,15 +70,28 @@
102 self.assertThat(chossetopicpage, Eventually(Equals(True)))
103
104 #add a new topic
105- self._input_new_topic("CanonicalTopic")
106+ topicName = "CanonicalTopic"
107+ self._input_new_topic(topicName)
108
109 #select canonical topic
110 self.assertThat(self.main_view.get_canonical_topic_labelvisual, Eventually(Not(Is(None))))
111+
112+ #make sure topic is selected
113+ timeout = 0
114 canonicalTopic = self.main_view.get_canonical_topic_labelvisual()
115 self.pointing_device.click_object(canonicalTopic)
116
117- #just for timing purposes
118- self.assertThat(canonicalTopic.text, Eventually(Equals("CanonicalTopic")))
119+ #loop to ensure we clicked the topic
120+ #while canonicalTopic.Text != topicName and timeout < 10:
121+ while not self.main_view.get_network_activity and timeout < 10:
122+ canonicalTopic = self.main_view.get_canonical_topic_labelvisual()
123+ self.pointing_device.click_object(canonicalTopic)
124+ sleep(1)
125+ timeout += 1
126+
127+ #wait for any updates to finish
128+ #self.assertThat(self.main_view.get_network_activity, Eventually(Not(Is(None))))
129+ self.assertThat(self.main_view.get_network_activity, Eventually(Is(None)))
130
131 def _remove_feed(self):
132 #open toolbar
133@@ -197,7 +215,7 @@
134 #remove added Canonical topic
135 #12 Aug 2013, removing topic broken for now
136 #test commented until fixed, see https://bugs.launchpad.net/ubuntu-rssreader-app/+bug/1211631
137- ## self._remove_topic()
138+ #self._remove_topic()
139
140 #remove added Canonical feed
141 self._remove_feed()
142
143=== modified file 'ubuntu-rssreader-app.qml'
144--- ubuntu-rssreader-app.qml 2013-09-01 21:45:40 +0000
145+++ ubuntu-rssreader-app.qml 2013-09-05 05:27:18 +0000
146@@ -273,6 +273,7 @@
147
148 Dialog {
149 id: refreshWaitDialog
150+ objectName: refreshWaitDialog
151
152 title: i18n.tr("Checking for new articles")
153
154@@ -282,6 +283,7 @@
155
156 Button {
157 text: i18n.tr("Cancel")
158+ objectName: refreshCancel
159 color: UbuntuColors.orange
160 onClicked: {
161 xmlnetwork.cancelDownload()

Subscribers

People subscribed via source and target branches