Merge lp:~nskaggs/ubuntu-calculator-app/fix-ap-asserts into lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 348
Merged at revision: 334
Proposed branch: lp:~nskaggs/ubuntu-calculator-app/fix-ap-asserts
Merge into: lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk
Diff against target: 147 lines (+35/-26)
3 files modified
Simple/SimplePage.qml (+1/-0)
tests/autopilot/ubuntu_calculator_app/__init__.py (+25/-18)
tests/autopilot/ubuntu_calculator_app/tests/test_simple_page.py (+9/-8)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-calculator-app/fix-ap-asserts
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Riccardo Padovani Approve
Review via email: mp+237874@code.launchpad.net

Commit message

Assert properly about results; remove select_many's and use objectnames

Description of the change

Assert properly about results; remove select_many's and use objectnames

To post a comment you must log in.
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

lgtm, thanks!

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) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Need to fix isLast: False for multiple screens when saving swipes

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Simple/SimplePage.qml'
2--- Simple/SimplePage.qml 2014-09-20 10:48:09 +0000
3+++ Simple/SimplePage.qml 2014-10-10 03:06:11 +0000
4@@ -359,6 +359,7 @@
5
6 delegate: Screen {
7 id: screen
8+ objectName: "screen" + index
9 width: formulaView.width
10 ops: operators
11
12
13=== modified file 'tests/autopilot/ubuntu_calculator_app/__init__.py'
14--- tests/autopilot/ubuntu_calculator_app/__init__.py 2014-09-08 19:34:46 +0000
15+++ tests/autopilot/ubuntu_calculator_app/__init__.py 2014-10-10 03:06:11 +0000
16@@ -19,7 +19,6 @@
17 import logging
18
19 import autopilot.logging
20-from autopilot.introspection import dbus
21
22 import ubuntuuitoolkit
23
24@@ -95,8 +94,7 @@
25
26 def get_current_screen(self):
27 """Return the screen for the current calculation."""
28- count = self.get_number_of_screens()
29- return self.select_many(Screen)[count - 1]
30+ return self.get_screen_by_index(0)
31
32 def get_operand_by_index(self, index):
33 """Return an operand of a calculation entered."""
34@@ -117,7 +115,8 @@
35
36 def get_screen_by_index(self, index):
37 """Return a screen."""
38- return self._get_screens()[index]
39+ return self.wait_select_single(Screen,
40+ objectName="screen" + str(index))
41
42 def _get_screens(self):
43 return self.select_many(Screen)
44@@ -131,8 +130,8 @@
45 _, prev_screen_y, _, prev_screen_h = previous_screen.globalRect
46 x, y, w, h = self.globalRect
47 start_x = stop_x = x + w / 2
48- start_y = y + h / 2
49- stop_y = start_y + y - prev_screen_y
50+ stop_y = y + h / 2
51+ start_y = stop_y + y - prev_screen_y
52 self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
53 self._wait_for_screen_to_finish_animation()
54
55@@ -253,13 +252,15 @@
56 try:
57 return self.select_single(
58 'CalcLabel', objectName='result', isLast=True)
59- except dbus.StateNotFoundError:
60- results = self.select_many('CalcLabel', objectName='result')
61- count = len(results)
62- if count > 0:
63- return results[count - 1]
64- else:
65- return None
66+ except:
67+ try:
68+ return self.select_many('CalcLabel', objectName='result')[0]
69+ except:
70+ try:
71+ return self.select_single(
72+ 'CalcLabel', objectName='result')
73+ except:
74+ return None
75
76 @autopilot.logging.log_action(logger.info)
77 def click_result_label(self):
78@@ -310,7 +311,15 @@
79 self.get_operand_by_index(0) == "")
80
81 def _get_number_of_labels(self):
82- return len(self.select_many('CalcLabel'))
83+ try:
84+ labels = self.select_many('CalcLabel')
85+ except:
86+ try:
87+ labels = self.select_single('CalcLabel')
88+ except:
89+ raise CalculatorException("No calculations found")
90+
91+ return len(labels)
92
93 @autopilot.logging.log_action(logger.info)
94 def swipe_to_delete(self):
95@@ -324,10 +333,8 @@
96
97 def _drag_pointing_device_to_delete(self):
98 x, y, width, height = self.globalRect
99- left_x = x + (width * 0.33)
100- right_x = x + (width * 0.9)
101+ start_x = x + (width * 0.33)
102+ stop_x = x + (width * 0.9)
103 start_y = stop_y = y + (height // 2)
104
105- start_x = left_x
106- stop_x = right_x
107 self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
108
109=== modified file 'tests/autopilot/ubuntu_calculator_app/tests/test_simple_page.py'
110--- tests/autopilot/ubuntu_calculator_app/tests/test_simple_page.py 2014-09-10 09:54:12 +0000
111+++ tests/autopilot/ubuntu_calculator_app/tests/test_simple_page.py 2014-10-10 03:06:11 +0000
112@@ -208,26 +208,27 @@
113
114 def test_swipe_up_with_result(self):
115 """Test swipe up adds calculation to history"""
116+
117 self.app.main_view.calculate_operation("9+8")
118 self.app.main_view.clear_with_swipe()
119
120- self.assertThat(
121- self.app.main_view.get_number_of_screens, Eventually(Equals(2)))
122+ self.assertEquals(
123+ self.app.main_view.get_screen_by_index(1).get_result(), "17")
124 self.assertTrue(
125- self.app.main_view.get_screen_by_index(1).is_cleared())
126- self.assertEquals(
127- self.app.main_view.get_screen_by_index(0).get_result(), "17")
128+ self.app.main_view.get_screen_by_index(0).is_cleared())
129
130 def test_swipe_to_delete_calculation(self):
131 """Delete a calculation swiping on it to the side."""
132+ screens = self.app.main_view.get_number_of_screens()
133+
134 self.app.main_view.calculate_operation("9+5")
135 self.app.main_view.clear_with_swipe()
136
137- self.app.main_view.swipe_previous_calculation_into_view(0)
138- self.app.main_view.delete_previous_calculation(0, confirm=True)
139+ self.app.main_view.delete_previous_calculation(1, confirm=True)
140
141 self.assertThat(
142- self.app.main_view.get_number_of_screens, Eventually(Equals(1)))
143+ self.app.main_view.get_number_of_screens,
144+ Eventually(Equals(screens)))
145
146 def test_continue_calculation(self):
147 self.app.main_view.calculate_operation("59+1")

Subscribers

People subscribed via source and target branches