Merge lp:~nskaggs/ubuntu-calculator-app/fix-testability into lp:ubuntu-calculator-app

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Bartosz Kosiorek
Approved revision: 187
Merged at revision: 190
Proposed branch: lp:~nskaggs/ubuntu-calculator-app/fix-testability
Merge into: lp:ubuntu-calculator-app
Diff against target: 121 lines (+38/-19)
3 files modified
app/ui/Screen.qml (+4/-3)
tests/autopilot/ubuntu_calculator_app/__init__.py (+33/-15)
tests/autopilot/ubuntu_calculator_app/tests/__init__.py (+1/-1)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-calculator-app/fix-testability
Reviewer Review Type Date Requested Status
Bartosz Kosiorek Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Riccardo Padovani Approve
Review via email: mp+262019@code.launchpad.net

Commit message

Fix testability for screen components

Description of the change

Fix testability for screen components

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)
186. By Nicholas Skaggs

add helpers to calculation history for retrieving history entries

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

Sorry, I wanted to sneak one more thing in so it's all set :-)

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
Bartosz Kosiorek (gang65) wrote :

Nice improvement.
I think you forget to uncomment one "objectName:".
Please take a look at inline comment.

review: Needs Fixing
187. By Nicholas Skaggs

remove objectname

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

> Nice improvement.
> I think you forget to uncomment one "objectName:".
> Please take a look at inline comment.

Yea, it's unneeded. Removed.

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
Bartosz Kosiorek (gang65) wrote :

Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/ui/Screen.qml'
2--- app/ui/Screen.qml 2015-03-12 21:21:47 +0000
3+++ app/ui/Screen.qml 2015-06-16 12:39:32 +0000
4@@ -23,6 +23,7 @@
5
6 ListItemWithActions {
7 id: root
8+ objectName: "screenroot" + model.index
9
10 function formatDate(date) {
11 var now = new Date();
12@@ -89,6 +90,7 @@
13 }
14 Row {
15 id: calculationRow
16+ objectName: "historyrow"
17 width: parent.width
18 anchors.right: parent.right
19
20@@ -97,7 +99,7 @@
21
22 Text {
23 id: result
24- objectName: "result"
25+ objectName: "result" + model.index
26
27 anchors.bottom: formula.bottom
28
29@@ -110,7 +112,6 @@
30
31 Text {
32 id: equal
33-
34 anchors.bottom: formula.bottom
35
36 color: UbuntuColors.darkGrey
37@@ -122,7 +123,7 @@
38
39 Text {
40 id: formula
41- objectName: "formula"
42+ objectName: "formula" + model.index
43
44 width: parent.width - equal.width - result.width
45 anchors.bottom: parent.bottom
46
47=== modified file 'tests/autopilot/ubuntu_calculator_app/__init__.py'
48--- tests/autopilot/ubuntu_calculator_app/__init__.py 2015-06-12 10:07:20 +0000
49+++ tests/autopilot/ubuntu_calculator_app/__init__.py 2015-06-16 12:39:32 +0000
50@@ -42,25 +42,43 @@
51 def contains(self, entry):
52 found = False
53
54- calculations = self.app.select_many('QQuickRectangle',
55- objectName='mainItem')
56-
57- for calculation in calculations:
58- if entry.strip() == self._get_entry(calculation):
59+ history = self.get_all_history_entries()
60+ for line in history:
61+ calculation = self._get_entry(line)
62+ if calculation == entry.strip():
63 found = True
64+ break
65
66 return found
67
68- def _get_entry(self, calc):
69- return self._get_formula(calc) + '=' + self._get_result(calc)
70-
71- def _get_formula(self, calc):
72- return calc.wait_select_single('QQuickText',
73- objectName='formula').text.strip()
74-
75- def _get_result(self, calc):
76- return calc.wait_select_single('QQuickText',
77- objectName='result').text.strip()
78+ def get_all_history_entries(self):
79+ return self.app.select_many('QQuickRow', objectName='historyrow')
80+
81+ def get_history_entry(self, entry):
82+ return self.app.select_single('QQuickText',
83+ objectName='result' + str(entry))
84+
85+ def get_formula_entry(self, entry=0):
86+ return self.app.select_single('QQuickText',
87+ objectName='formula' + str(entry))
88+
89+ def get_formula_value(self, entry=0):
90+ return self.get_formula_entry(entry).text.strip()
91+
92+ def get_result_value(self, entry=0):
93+ return self.get_history_entry(entry).text.strip()
94+
95+ def _get_entry(self, line):
96+ values = line.select_many('QQuickText')
97+ result = ''
98+ formula = ''
99+ for value in values:
100+ if 'result' in value.objectName:
101+ result = value.text.strip()
102+ elif 'formula' in value.objectName:
103+ formula = value.text.strip()
104+
105+ return formula + '=' + result
106
107
108 class MainView(ubuntuuitoolkit.MainView):
109
110=== modified file 'tests/autopilot/ubuntu_calculator_app/tests/__init__.py'
111--- tests/autopilot/ubuntu_calculator_app/tests/__init__.py 2015-04-30 08:33:46 +0000
112+++ tests/autopilot/ubuntu_calculator_app/tests/__init__.py 2015-06-16 12:39:32 +0000
113@@ -97,7 +97,7 @@
114 os.path.expanduser('~'),
115 '.local',
116 'share',
117- 'com.ubuntu.calculator_reboot'
118+ 'com.ubuntu.calculator'
119 )
120
121 if os.path.exists(calculator_database_path):

Subscribers

People subscribed via source and target branches