Merge lp:~nik90/ubuntu-clock-app/more-stopwatch-tests into lp:ubuntu-clock-app/saucy

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 268
Merged at revision: 282
Proposed branch: lp:~nik90/ubuntu-clock-app/more-stopwatch-tests
Merge into: lp:ubuntu-clock-app/saucy
Prerequisite: lp:~nik90/ubuntu-clock-app/use-default-swipe-delete
Diff against target: 196 lines (+78/-12)
7 files modified
clock/WorldClock.qml (+1/-0)
stopwatch/LapList.qml (+1/-0)
stopwatch/StopwatchPage.qml (+0/-1)
tests/autopilot/ubuntu_clock_app/emulators.py (+13/-4)
tests/autopilot/ubuntu_clock_app/tests/test_clock.py (+3/-2)
tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py (+59/-5)
tests/autopilot/ubuntu_clock_app/tests/test_timer.py (+1/-0)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/more-stopwatch-tests
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Approve
Ubuntu Clock Developers Pending
Review via email: mp+193922@code.launchpad.net

Commit message

Added autopilot tests for creating and deleting stopwatch laps.

Description of the change

This MP adds three autopilot test cases,
-> Test creating laps (stopwatch)
-> Test deleting laps (stopwatch)

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

I was JUST going to ping on the status of this :-) Think we can land this now?

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Yup it is ready from my pov. So its up to you and jenkins to decide if the code is good and then approve it :-)

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
Nicholas Skaggs (nskaggs) wrote :

Trying this on my device now.. Did you run it? I got the error below once during a run. Going to keep running to see if it's the only occasional error:

Traceback (most recent call last):
File "/home/phablet/autopilot/ubuntu_clock_app/tests/test_timer.py", line 119, in test_delete_preset
self.test_add_preset()
File "/home/phablet/autopilot/ubuntu_clock_app/tests/test_timer.py", line 91, in test_add_preset
Eventually(Equals(num_of_presets_old + 1)))
File "/usr/lib/python2.7/dist-packages/testtools/testcase.py", line 412, in assertThat
raise MismatchError(matchee, matcher, mismatch, verbose)
MismatchError: After 10.0 seconds test failed: 4 != 3

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

The aforementioned error is no longer an issue, however RE: IRC, the test_add_online_world_city isn't testing online cities like you think :- )

I would also add an assert to ensure the stopwatch time moves in test_create_lap, even if you sleep. This will prevent timing issues where you try and hit a lap with no time elapsed :-)

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

Finally, I'm ok with adding the online test, but we are trying to transition away. We might end up disabling it as extraneous. (since we're testing it anyway since it's the same as local)

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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
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) wrote :

Looks much better :-)

review: Approve
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
=== modified file 'clock/WorldClock.qml'
--- clock/WorldClock.qml 2013-11-07 16:34:43 +0000
+++ clock/WorldClock.qml 2014-01-06 20:53:15 +0000
@@ -74,6 +74,7 @@
74 // TODO: Add capability to also search cities provided locally with clock-app74 // TODO: Add capability to also search cities provided locally with clock-app
75 SearchBox {75 SearchBox {
76 id: searchBox76 id: searchBox
77 objectName: "worldSearchBox"
7778
78 height: units.gu(4)79 height: units.gu(4)
79 anchors { left: parent.left; right: parent.right }80 anchors { left: parent.left; right: parent.right }
8081
=== modified file 'stopwatch/LapList.qml'
--- stopwatch/LapList.qml 2013-10-26 19:26:49 +0000
+++ stopwatch/LapList.qml 2014-01-06 20:53:15 +0000
@@ -83,6 +83,7 @@
83 model: lapModel83 model: lapModel
84 84
85 delegate: ListItem.Standard {85 delegate: ListItem.Standard {
86 objectName: "laps" + index
86 Label {87 Label {
87 text: Utils.numberToLocaleString(lapModel.count - index);88 text: Utils.numberToLocaleString(lapModel.count - index);
88 anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: units.gu(3) }89 anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: units.gu(3) }
8990
=== modified file 'stopwatch/StopwatchPage.qml'
--- stopwatch/StopwatchPage.qml 2013-10-26 19:26:49 +0000
+++ stopwatch/StopwatchPage.qml 2014-01-06 20:53:15 +0000
@@ -43,7 +43,6 @@
4343
44 ListModel {44 ListModel {
45 id: laps45 id: laps
46 objectName: "laps"
4746
48 property int lapStart: 0;47 property int lapStart: 0;
4948
5049
=== modified file 'tests/autopilot/ubuntu_clock_app/emulators.py'
--- tests/autopilot/ubuntu_clock_app/emulators.py 2013-11-07 16:34:43 +0000
+++ tests/autopilot/ubuntu_clock_app/emulators.py 2014-01-06 20:53:15 +0000
@@ -73,6 +73,10 @@
73 """Return the page containing the world cities."""73 """Return the page containing the world cities."""
74 return self.wait_select_single("WorldClock") 74 return self.wait_select_single("WorldClock")
7575
76 def get_search_box(self):
77 """Returns the search box used to search for world cities online."""
78 return self.wait_select_single('SearchBox', objectName="worldSearchBox")
79
76 def get_world_cities_list(self):80 def get_world_cities_list(self):
77 """Return the component containing the list of available world cities."""81 """Return the component containing the list of available world cities."""
78 return self.wait_select_single(objectName="worldList")82 return self.wait_select_single(objectName="worldList")
@@ -141,15 +145,20 @@
141145
142 def get_lap_button(self):146 def get_lap_button(self):
143 """Returns the select for the lap button"""147 """Returns the select for the lap button"""
144 return self.wait_select_single("Button", objectName="lapButton")148 return self.wait_select_single("ImageButton", objectName="lapButton")
145149
146 def get_reset_button(self):150 def get_reset_button(self):
147 """Returns the select for the reset button"""151 """Returns the select for the reset button"""
148 return self.wait_select_single("ImageButton", objectName="resetButton")152 return self.wait_select_single("ImageButton", objectName="resetButton")
149153
150 def get_laps(self):154 def get_num_of_laps(self):
151 """Returns the select for the lap count"""155 """Returns the number of laps in the stopwatch page."""
152 return self.wait_select_single("ListModel", objectName="laps")156 stopwatch_page = self.select_single("StopwatchPage")
157 return int(stopwatch_page.wait_select_single("QQuickListView").count)
158
159 def get_first_laps_list_item(self):
160 """Returns the first lap list item in the stopwatch page."""
161 return self.wait_select_single("Standard", objectName="laps0")
153 162
154 # ALARM Page Emulator Functions163 # ALARM Page Emulator Functions
155 def get_addalarm_page(self):164 def get_addalarm_page(self):
156165
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_clock.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2013-11-07 16:34:43 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2014-01-06 20:53:15 +0000
@@ -25,6 +25,7 @@
2525
26from testtools.matchers import Equals, NotEquals26from testtools.matchers import Equals, NotEquals
27from autopilot.matchers import Eventually27from autopilot.matchers import Eventually
28from time import sleep
2829
29from ubuntu_clock_app.tests import ClockAppTestCase30from ubuntu_clock_app.tests import ClockAppTestCase
3031
@@ -69,8 +70,8 @@
69 city_name = self.main_view.get_city_name(city)70 city_name = self.main_view.get_city_name(city)
70 self.main_view.select_city(city)71 self.main_view.select_city(city)
71 saved_city_name = self.main_view.get_city_name(self.main_view.grab_first_saved_city())72 saved_city_name = self.main_view.get_city_name(self.main_view.grab_first_saved_city())
72 self.assertThat(saved_city_name, Eventually(Equals(city_name)))73 self.assertThat(saved_city_name, Eventually(Equals(city_name)))
7374
74 def test_delete_local_world_city(self):75 def test_delete_local_world_city(self):
75 """Test to check if deleting a saved local world city works"""76 """Test to check if deleting a saved local world city works"""
7677
7778
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2013-11-01 21:46:43 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2014-01-06 20:53:15 +0000
@@ -41,20 +41,29 @@
41 def tearDown(self):41 def tearDown(self):
42 super(TestStopwatch, self).tearDown()42 super(TestStopwatch, self).tearDown()
4343
44 def create_lap(self):
45 """Function to create a stopwatch lap"""
46 lap_button = self.main_view.get_lap_button()
47 self.pointing_device.click_object(lap_button)
48
49 def start_stop_stopwatch(self):
50 """Function to start/stop the stopwatch"""
51 start_stop_button = self.main_view.get_stopwatch_button()
52 self.pointing_device.click_object(start_stop_button)
53
44 def test_start_stop_reset_stopwatch(self):54 def test_start_stop_reset_stopwatch(self):
45 """Test to check the proper functioning of the start/stop/reset of stopwatch"""55 """Test to check the proper functioning of the start/stop/reset of stopwatch"""
4656
47 start_stop_button = self.main_view.get_stopwatch_button()
48 stopwatch_label = self.main_view.get_stopwatch_label()57 stopwatch_label = self.main_view.get_stopwatch_label()
49 reset_button = self.main_view.get_reset_button()58 reset_button = self.main_view.get_reset_button()
5059
51 # Press the start button to start the stopwatch and check if the stopwatch starts ticking60 # Start the stopwatch and check if the stopwatch starts ticking
52 stopwatch_label_before = self.main_view.get_stopwatch_label().text61 stopwatch_label_before = self.main_view.get_stopwatch_label().text
53 self.pointing_device.click_object(start_stop_button)62 self.start_stop_stopwatch()
54 self.assertThat(stopwatch_label.text, Eventually(NotEquals("00:00.0")))63 self.assertThat(stopwatch_label.text, Eventually(NotEquals("00:00.0")))
5564
56 # Press stop and check if the stopwatch has indeed stopped65 # Stop the stopwatch and check it has indeed stopped
57 self.pointing_device.click_object(start_stop_button)66 self.start_stop_stopwatch()
58 self.assertThat(stopwatch_label_before, NotEquals(self.main_view.get_stopwatch_label().text))67 self.assertThat(stopwatch_label_before, NotEquals(self.main_view.get_stopwatch_label().text))
59 stopwatch_label_after = lambda: self.main_view.get_stopwatch_label().text68 stopwatch_label_after = lambda: self.main_view.get_stopwatch_label().text
60 self.assertThat(stopwatch_label_after, Eventually(Equals(self.main_view.get_stopwatch_label().text)))69 self.assertThat(stopwatch_label_after, Eventually(Equals(self.main_view.get_stopwatch_label().text)))
@@ -62,3 +71,48 @@
62 # Press reset and check if the stopwatch has been resetted71 # Press reset and check if the stopwatch has been resetted
63 self.pointing_device.click_object(reset_button)72 self.pointing_device.click_object(reset_button)
64 self.assertThat(stopwatch_label.text, Eventually(Equals("00:00.0")))73 self.assertThat(stopwatch_label.text, Eventually(Equals("00:00.0")))
74
75 def test_create_lap(self):
76 """Test to check creating a new stopwatch lap"""
77
78 # Start the stopwatch
79 stopwatch_label = self.main_view.get_stopwatch_label().text
80 self.start_stop_stopwatch()
81
82 # Ensure that the stopwatch actually ticks
83 self.assertThat(stopwatch_label, Eventually(NotEquals("00:00.0")))
84
85 # Create a stopwatch lap by pressing the lap button
86 num_of_laps_old = self.main_view.get_num_of_laps()
87 self.create_lap()
88
89 # Confirm that the lap is created
90 self.assertThat(
91 self.main_view.get_num_of_laps,
92 Eventually(Equals(num_of_laps_old + 1)))
93
94 def test_delete_lap(self):
95 """Test to check deleting a stopwatch lap"""
96
97 # Start the stopwatch
98 stopwatch_label = self.main_view.get_stopwatch_label().text
99 self.start_stop_stopwatch()
100
101 # Ensure that the stopwatch actually ticks
102 self.assertThat(stopwatch_label, Eventually(NotEquals("00:00.0")))
103
104 # Create a stopwatch lap
105 self.create_lap()
106
107 num_of_laps_old = self.main_view.get_num_of_laps()
108 self.main_view.drag_page_up("StopwatchPage", self)
109
110 # Delete stopwatch lap
111 first_lap = self.main_view.get_first_laps_list_item()
112 first_lap.swipe_to_delete()
113 first_lap.confirm_removal()
114
115 # Check that the stopwatch lap has been deleted
116 self.assertThat(
117 self.main_view.get_num_of_laps,
118 Eventually(Equals(num_of_laps_old - 1)))
65119
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_timer.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-11-01 21:46:43 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2014-01-06 20:53:15 +0000
@@ -24,6 +24,7 @@
24from testtools.matchers import Equals, NotEquals, Is, Not24from testtools.matchers import Equals, NotEquals, Is, Not
25from autopilot.matchers import Eventually25from autopilot.matchers import Eventually
26from time import sleep26from time import sleep
27
27from ubuntu_clock_app.tests import ClockAppTestCase28from ubuntu_clock_app.tests import ClockAppTestCase
2829
2930

Subscribers

People subscribed via source and target branches