Merge lp:~nskaggs/sudoku-app/add-emulator-autopilot into lp:sudoku-app

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Dinko Osmankovic
Approved revision: 75
Merged at revision: 74
Proposed branch: lp:~nskaggs/sudoku-app/add-emulator-autopilot
Merge into: lp:sudoku-app
Diff against target: 247 lines (+120/-30)
5 files modified
components/SudokuBlocksGrid.qml (+1/-0)
sudoku-app.qml (+4/-0)
tests/autopilot/sudoku_app/emulators/main_window.py (+17/-0)
tests/autopilot/sudoku_app/emulators/ubuntusdk.py (+35/-29)
tests/autopilot/sudoku_app/tests/test_sudoku.py (+63/-1)
To merge this branch: bzr merge lp:~nskaggs/sudoku-app/add-emulator-autopilot
Reviewer Review Type Date Requested Status
Dinko Osmankovic Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+174282@code.launchpad.net

Commit message

This change adds tests for number inputs and the high score tab

Description of the change

This change adds tests for number inputs and the high score tab

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: Approve (continuous-integration)
75. By Nicholas Skaggs

fix testcase for input numbers

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
Dinko Osmankovic (dinko-metalac) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'components/SudokuBlocksGrid.qml'
--- components/SudokuBlocksGrid.qml 2013-07-10 09:02:21 +0000
+++ components/SudokuBlocksGrid.qml 2013-07-11 22:05:30 +0000
@@ -292,6 +292,7 @@
292292
293 Dialog {293 Dialog {
294 id: dialogue294 id: dialogue
295 objectName: "picknumberscreen"
295 //title: "Number Picker"296 //title: "Number Picker"
296 text: i18n.tr("Please pick a number")297 text: i18n.tr("Please pick a number")
297298
298299
=== modified file 'sudoku-app.qml'
--- sudoku-app.qml 2013-07-10 11:38:57 +0000
+++ sudoku-app.qml 2013-07-11 22:05:30 +0000
@@ -304,6 +304,7 @@
304304
305 SudokuBlocksGrid {305 SudokuBlocksGrid {
306 id: sudokuBlocksGrid;306 id: sudokuBlocksGrid;
307 objectName: "blockgrid"
307 }308 }
308309
309 }310 }
@@ -320,6 +321,7 @@
320 page: Page {321 page: Page {
321 tools: ToolbarItems {322 tools: ToolbarItems {
322 ToolbarButton {323 ToolbarButton {
324 objectName: "allusersbutton"
323 action: Action {325 action: Action {
324 text: "All\nusers"326 text: "All\nusers"
325 iconSource: Qt.resolvedUrl("icons/all-users.svg")327 iconSource: Qt.resolvedUrl("icons/all-users.svg")
@@ -341,6 +343,7 @@
341 }343 }
342 }344 }
343 ToolbarButton {345 ToolbarButton {
346 objectName: "currentuserbutton"
344 action: Action {347 action: Action {
345 text: "Current\nuser"348 text: "Current\nuser"
346 iconSource: Qt.resolvedUrl("icons/single-user.svg")349 iconSource: Qt.resolvedUrl("icons/single-user.svg")
@@ -387,6 +390,7 @@
387 anchors.fill: parent390 anchors.fill: parent
388 header: ListItem.Header {391 header: ListItem.Header {
389 id: highscoresHeader392 id: highscoresHeader
393 objectName: "highscoreslabel"
390 text: highscoresHeaderText394 text: highscoresHeaderText
391 }395 }
392 delegate: ListItem.SingleValue {396 delegate: ListItem.SingleValue {
393397
=== modified file 'tests/autopilot/sudoku_app/emulators/main_window.py'
--- tests/autopilot/sudoku_app/emulators/main_window.py 2013-07-11 16:46:16 +0000
+++ tests/autopilot/sudoku_app/emulators/main_window.py 2013-07-11 22:05:30 +0000
@@ -15,3 +15,20 @@
15 """15 """
16 def __init__(self, app):16 def __init__(self, app):
17 self.app = app17 self.app = app
18
19 def get_blank_inputs(self):
20 #generate a list of blank input fields from the game board
21 #SudokuBlocksGrid->..->SudokuButton->QQuickTest->enabled == true
22 inputs = self.app.select_single("SudokuBlocksGrid")
23 blankInputsList = inputs.select_many("QQuickText", enabled=True)
24 return blankInputsList
25
26 def get_dialog_button(self, name):
27 numberdialog = self.get_number_dialog()
28
29 #SudokuDialogButton->QQuickText text =
30 button = numberdialog.select_single("QQuickText",text=name)
31 return button
32
33 def get_number_dialog(self):
34 return self.app.select_single("Dialog", objectName="picknumberscreen")
1835
=== modified file 'tests/autopilot/sudoku_app/emulators/ubuntusdk.py'
--- tests/autopilot/sudoku_app/emulators/ubuntusdk.py 2013-07-11 16:46:16 +0000
+++ tests/autopilot/sudoku_app/emulators/ubuntusdk.py 2013-07-11 22:05:30 +0000
@@ -38,6 +38,10 @@
38 """Get more than one object"""38 """Get more than one object"""
39 return self.app.select_many(typeName, objectName=name)39 return self.app.select_many(typeName, objectName=name)
4040
41 def get_tabs(self):
42 """Return all tabs"""
43 return self.app.select_single("Tabs")
44
41 def switch_to_tab(self, tab):45 def switch_to_tab(self, tab):
42 """Switch to the specified tab number"""46 """Switch to the specified tab number"""
43 tabs = self.get_tabs()47 tabs = self.get_tabs()
@@ -46,11 +50,37 @@
46 #perform operations until tab == currentTab50 #perform operations until tab == currentTab
47 while tab != currentTab:51 while tab != currentTab:
48 if tab > currentTab:52 if tab > currentTab:
53 self._next_tab()
54 if tab < currentTab:
49 self._previous_tab()55 self._previous_tab()
50 if tab < currentTab:
51 self._next_tab()
52 currentTab = tabs.selectedTabIndex56 currentTab = tabs.selectedTabIndex
5357
58 def _previous_tab(self):
59 """Switch to the previous tab"""
60 qmlView = self.get_qml_view()
61
62 startX = int(qmlView.x + qmlView.width * 0.10)
63 stopX = int(qmlView.x + qmlView.width * 0.35)
64 lineY = int(qmlView.y + qmlView.height * 0.05)
65
66 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
67 self.autopilot.pointing_device.move(startX, lineY)
68 self.autopilot.pointing_device.click()
69 self.autopilot.pointing_device.click()
70
71 def _next_tab(self):
72 """Switch to the next tab"""
73 qmlView = self.get_qml_view()
74
75 startX = int(qmlView.x + qmlView.width * 0.35)
76 stopX = int(qmlView.x + qmlView.width * 0.10)
77 lineY = int(qmlView.y + qmlView.height * 0.05)
78
79 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
80 self.autopilot.pointing_device.move(startX, lineY)
81 self.autopilot.pointing_device.click()
82 self.autopilot.pointing_device.click()
83
54 def toggle_toolbar(self):84 def toggle_toolbar(self):
55 """Toggle the toolbar between revealed and hidden"""85 """Toggle the toolbar between revealed and hidden"""
56 #check and see if the toolbar is open or not86 #check and see if the toolbar is open or not
@@ -69,6 +99,9 @@
69 if not toolbar.opened:99 if not toolbar.opened:
70 self.open_toolbar()100 self.open_toolbar()
71 buttonList = toolbar.select_many("ActionItem")101 buttonList = toolbar.select_many("ActionItem")
102 #old version is ToolbarButton
103 if not buttonList:
104 buttonList = toolbar.select_many("ToolbarButton")
72 for button in buttonList:105 for button in buttonList:
73 if button.objectName == buttonObject:106 if button.objectName == buttonObject:
74 return button107 return button
@@ -122,30 +155,3 @@
122 if item.text == value:155 if item.text == value:
123 self.autopilot.pointing_device.click_object(item)156 self.autopilot.pointing_device.click_object(item)
124 return item157 return item
125
126 def get_tabs(self):
127 """Return all tabs"""
128 return self.get_object("Tabs", "rootTabs")
129
130 def _previous_tab(self):
131 """Switch to the previous tab"""
132 qmlView = self.get_qml_view()
133
134 startX = int(qmlView.x + qmlView.width * 0.35)
135 stopX = int(qmlView.x + qmlView.width * 0.50)
136 lineY = int(qmlView.y + qmlView.height * 0.05)
137
138 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
139 self.autopilot.pointing_device.click()
140 self.autopilot.pointing_device.click()
141
142 def _next_tab(self):
143 """Switch to the next tab"""
144 qmlView = self.get_qml_view()
145
146 startX = int(qmlView.x + qmlView.width * 0.50)
147 stopX = int(qmlView.x + qmlView.width * 0.35)
148 lineY = int(qmlView.y + qmlView.height * 0.05)
149
150 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
151 self.autopilot.pointing_device.click()
152158
=== modified file 'tests/autopilot/sudoku_app/tests/test_sudoku.py'
--- tests/autopilot/sudoku_app/tests/test_sudoku.py 2013-07-11 16:58:38 +0000
+++ tests/autopilot/sudoku_app/tests/test_sudoku.py 2013-07-11 22:05:30 +0000
@@ -10,7 +10,7 @@
10from __future__ import absolute_import10from __future__ import absolute_import
1111
12from autopilot.matchers import Eventually12from autopilot.matchers import Eventually
13from testtools.matchers import Equals13from testtools.matchers import Equals, Contains, NotEquals
1414
15from sudoku_app.tests import SudokuTestCase15from sudoku_app.tests import SudokuTestCase
1616
@@ -24,3 +24,65 @@
2424
25 def tearDown(self):25 def tearDown(self):
26 super(TestMainWindow, self).tearDown()26 super(TestMainWindow, self).tearDown()
27
28 def test_enter_and_clear_number(self):
29 #find the first button that has a blank value
30 gridButtons = self.main_window.get_blank_inputs()
31 gridButton = gridButtons[0]
32
33 #create a value function to check later using id
34 buttonValue = lambda: self.app.select_single("QQuickText",id=gridButton.id).text
35
36 #double check that it's blank
37 self.assertThat(buttonValue, Eventually(Equals("")))
38
39 #click the button
40 self.pointing_device.click_object(gridButton)
41
42 #assert that we can see the input screen
43 inputScreen = lambda: self.main_window.get_number_dialog()
44 self.assertThat(inputScreen, Eventually(NotEquals(None)))
45
46 #set a value, choose 4
47 dialogButton = self.main_window.get_dialog_button("4")
48 self.assertThat(dialogButton, NotEquals(None))
49 self.pointing_device.click_object(dialogButton)
50
51 #check the value to ensure it worked
52 self.assertThat(buttonValue, Eventually(Equals("4")))
53
54 #click the button
55 self.pointing_device.click_object(gridButton)
56
57 #assert that we can see the input screen
58 inputScreen = lambda: self.main_window.get_number_dialog()
59 self.assertThat(inputScreen, Eventually(NotEquals(None)))
60
61 #set a value, choose clear
62 dialogButton = self.main_window.get_dialog_button("Clear")
63 self.assertThat(dialogButton, NotEquals(None))
64 self.pointing_device.click_object(dialogButton)
65
66 #check the value to ensure it worked
67 self.assertThat(buttonValue, Eventually(Equals("")))
68
69 def test_best_scores_tab(self):
70 #switch to best scores tab
71 self.ubuntusdk.switch_to_tab(1)
72
73 #make sure we are in the right place
74 tabName = lambda: self.ubuntusdk.get_object("Tab","highscoresTab")
75 self.assertThat(tabName, Eventually(NotEquals(None)))
76
77 #click current user button
78 self.ubuntusdk.click_toolbar_button("currentuserbutton")
79
80 #check label
81 label = lambda: self.ubuntusdk.get_object("Header","highscoreslabel").text
82 self.assertThat(label, Eventually(NotEquals("<b>Best scores for all players</b>")))
83
84 #click all users button
85 self.ubuntusdk.click_toolbar_button("allusersbutton")
86
87 #check label again
88 self.assertThat(label, Eventually(Equals("<b>Best scores for all players</b>")))

Subscribers

People subscribed via source and target branches