Merge lp:~hiroshidi/ubuntu-terminal-app/autopilot-tests-panels into lp:ubuntu-terminal-app

Proposed by Dmitry Zagnoyko
Status: Merged
Approved by: Dmitry Zagnoyko
Approved revision: 17
Merged at revision: 15
Proposed branch: lp:~hiroshidi/ubuntu-terminal-app/autopilot-tests-panels
Merge into: lp:ubuntu-terminal-app
Diff against target: 352 lines (+233/-25)
5 files modified
Terminal.qml (+6/-0)
tests/autopilot/ubuntu_terminal_app/emulators/main_window.py (+15/-12)
tests/autopilot/ubuntu_terminal_app/emulators/ubuntusdk.py (+154/-0)
tests/autopilot/ubuntu_terminal_app/tests/__init__.py (+7/-1)
tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py (+51/-12)
To merge this branch: bzr merge lp:~hiroshidi/ubuntu-terminal-app/autopilot-tests-panels
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+170388@code.launchpad.net

Commit message

add autopilot test for panels and the circle menu
add ubuntusdk emu from lp:~nskaggs/+junk/ubuntusdk_autopilot_emulator

Description of the change

Added Autopilot Testcase for:
- Control keys panel - LP: #1188835
- Function keys panel - LP: #1188836
- Text control panel - LP: #1188837
- Circle-menu - LP: #1188838

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

Looks good Dmitry! Can you incorporate the emulator WIP for this? lp:~nskaggs/+junk/ubuntusdk_autopilot_emulator. We're going to continue to iterate on this to have many of the common functions (like tab switching, toolbar access, etc) and we want to be able to keep tests up to date on best practices as they continue to evolve :-)

That said, this is otherwise a nice basic testcase -- good base to build on.

review: Needs Fixing
17. By Dmitry Zagnoyko

Merged ubuntusdk autopilot testcase emulator. Merged branch: lp:~nskaggs/+junk/ubuntusdk_autopilot_emulator

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 :

Let's push this in. I need to add the popover function to the sdk somehow.. work for me to gt right :-) Thanks Dmitry!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Terminal.qml'
--- Terminal.qml 2013-05-24 16:18:10 +0000
+++ Terminal.qml 2013-06-19 18:58:26 +0000
@@ -82,6 +82,7 @@
8282
83 CtrlKeys {83 CtrlKeys {
84 id: kbCtrl84 id: kbCtrl
85 objectName: "kbCtrl"
85 visible: false86 visible: false
86 width: parent.width87 width: parent.width
87 anchors{88 anchors{
@@ -97,6 +98,7 @@
9798
98 FnKeys {99 FnKeys {
99 id: kbFn100 id: kbFn
101 objectName: "kbFn"
100 visible: false102 visible: false
101 width: parent.width103 width: parent.width
102 anchors{104 anchors{
@@ -113,6 +115,7 @@
113115
114 ScrlKeys {116 ScrlKeys {
115 id: kbScrl117 id: kbScrl
118 objectName: "kbScrl"
116 visible: false119 visible: false
117 width: parent.width120 width: parent.width
118 anchors{121 anchors{
@@ -141,6 +144,7 @@
141144
142 CircleMenu {145 CircleMenu {
143 id: cmenu146 id: cmenu
147 objectName: "cmenu"
144 z: 99148 z: 99
145 visible: false149 visible: false
146 anchors.centerIn: parent150 anchors.centerIn: parent
@@ -181,6 +185,7 @@
181185
182 KTerminal {186 KTerminal {
183 id: kterm187 id: kterm
188 objectName: "kterm"
184189
185 //////////////////////////////////////190 //////////////////////////////////////
186 /// FONT SIZE = 24 (FINE FOR GNEXUS)191 /// FONT SIZE = 24 (FINE FOR GNEXUS)
@@ -195,6 +200,7 @@
195200
196 session: KSession {201 session: KSession {
197 id: ksession202 id: ksession
203 objectName: "ksession"
198 kbScheme: "linux"204 kbScheme: "linux"
199 }205 }
200 }206 }
201207
=== modified file 'tests/autopilot/ubuntu_terminal_app/emulators/main_window.py'
--- tests/autopilot/ubuntu_terminal_app/emulators/main_window.py 2013-05-31 13:10:55 +0000
+++ tests/autopilot/ubuntu_terminal_app/emulators/main_window.py 2013-06-19 18:58:26 +0000
@@ -7,18 +7,21 @@
77
8"""Terminal app autopilot emulators."""8"""Terminal app autopilot emulators."""
99
10
11class MainWindow(object):10class MainWindow(object):
12 """An emulator class that makes it easy to interact with the11 """An emulator class that makes it easy to interact with the
13 terminal-app.12 terminal-app."""
1413 def __init__(self, autopilot, app):
15 """
16 def __init__(self, app):
17 self.app = app14 self.app = app
1815 self.autopilot = autopilot
19 def get_qml_view(self):16
20 """Get the main QML view"""17 def click_popup_item(self, popupLable):
21 return self.app.select_single("QQuickView")18 """Clicks the toolbar popup item with popupLable"""
2219 li = self.app.select_single("ActionSelectionPopover")
23 def get_toolbar(self):20 row = li.select_single("QQuickColumn")
24 return self.app.select_single("Toolbar")21 loaderList = row.select_many("QQuickLoader")
22 for loader in loaderList:
23 labelList = loader.select_many("Label")
24 for label in labelList:
25 if label.text == popupLable:
26 self.autopilot.pointing_device.click_object(label)
27
2528
=== added file 'tests/autopilot/ubuntu_terminal_app/emulators/ubuntusdk.py'
--- tests/autopilot/ubuntu_terminal_app/emulators/ubuntusdk.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntu_terminal_app/emulators/ubuntusdk.py 2013-06-19 18:58:26 +0000
@@ -0,0 +1,154 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2013 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17# Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com>
18
19from testtools.matchers import Equals, NotEquals, Not, Is
20from autopilot.matchers import Eventually
21
22class ubuntusdk(object):
23 """An emulator class that makes it easy to interact with the ubuntu sdk applications."""
24
25 def __init__(self, autopilot, app):
26 self.app = app
27 self.autopilot = autopilot
28
29 def get_qml_view(self):
30 """Get the main QML view"""
31 return self.app.select_single("QQuickView")
32
33 def get_object(self, typeName, name):
34 """Get a specific object"""
35 return self.app.select_single(typeName, objectName=name)
36
37 def get_objects(self, typeName, name):
38 """Get more than one object"""
39 return self.app.select_many(typeName, objectName=name)
40
41 def switch_to_tab(self, tab):
42 """Switch to the specified tab number"""
43 tabs = self.get_tabs()
44 currentTab = tabs.selectedTabIndex
45
46 #perform operations until tab == currentTab
47 while tab != currentTab:
48 if tab > currentTab:
49 self._previous_tab()
50 if tab < currentTab:
51 self._next_tab()
52 currentTab = tabs.selectedTabIndex
53
54 def toggle_toolbar(self):
55 """Toggle the toolbar between revealed and hidden"""
56 #check and see if the toolbar is open or not
57 if self.get_toolbar().opened:
58 self.hide_toolbar()
59 else:
60 self.open_toolbar()
61
62 def get_toolbar(self):
63 """Returns the toolbar in the main events view."""
64 return self.app.select_single("Toolbar")
65
66 def get_toolbar_button(self, buttonLabel):
67 """Returns the toolbar button at position index"""
68 toolbar = self.get_toolbar()
69 if not toolbar.opened:
70 self.open_toolbar()
71 row = toolbar.select_single("QQuickRow")
72 loaderList = row.select_many("QQuickLoader")
73 for loader in loaderList:
74 buttonList = loader.select_many("Button")
75 for button in buttonList:
76 if button.text == buttonLabel:
77 return button
78
79 def click_toolbar_button(self, buttonLabel):
80 """Clicks the toolbar button with buttonLabel"""
81 #The toolbar button is assumed to be the following format
82 #ToolbarActions {
83 # Action {
84 # objectName: "name"
85 # text: value
86 button = self.get_toolbar_button(buttonLabel)
87 self.autopilot.pointing_device.click_object(button)
88
89 def open_toolbar(self):
90 """Open the toolbar"""
91 qmlView = self.get_qml_view()
92
93 lineX = qmlView.x + qmlView.width * 0.50
94 startY = qmlView.y + qmlView.height - 1
95 stopY = qmlView.y + qmlView.height * 0.95
96
97 self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
98
99 def hide_toolbar(self):
100 """Hide the toolbar"""
101 qmlView = self.get_qml_view()
102
103 lineX = qmlView.x + qmlView.width * 0.50
104 startY = qmlView.y + qmlView.height * 0.95
105 stopY = qmlView.y + qmlView.height - 1
106
107 self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
108
109 def set_popup_value(self, popover, button, value):
110 """Changes the given popover selector to the request value
111 At the moment this only works for values that are currently visible. To
112 access the remaining items, a help method to drag and recheck is needed."""
113 #The popover is assumed to be the following format
114 # Popover {
115 # Column {
116 # ListView {
117 # delegate: Standard {
118 # objectName: "name"
119 # text: value
120
121 self.autopilot.pointing_device.click_object(button)
122 #we'll get all matching objects, incase the popover is reused between buttons
123 itemList = lambda: self.get_objects("Standard", popover)
124
125 for item in itemList():
126 if item.get_properties()['text'] == value:
127 self.autopilot.pointing_device.click_object(item)
128
129 def get_tabs(self):
130 """Return all tabs"""
131 return self.get_object("Tabs", "rootTabs")
132
133 def _previous_tab(self):
134 """Switch to the previous tab"""
135 qmlView = self.get_qml_view()
136
137 startX = qmlView.x + qmlView.width * 0.35
138 stopX = qmlView.x + qmlView.width * 0.50
139 lineY = qmlView.y + qmlView.height * 0.05
140
141 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
142 self.autopilot.pointing_device.click()
143 self.autopilot.pointing_device.click()
144
145 def _next_tab(self):
146 """Switch to the next tab"""
147 qmlView = self.get_qml_view()
148
149 startX = qmlView.x + qmlView.width * 0.50
150 stopX = qmlView.x + qmlView.width * 0.35
151 lineY = qmlView.y + qmlView.height * 0.05
152
153 self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
154 self.autopilot.pointing_device.click()
0155
=== modified file 'tests/autopilot/ubuntu_terminal_app/tests/__init__.py'
--- tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2013-05-31 13:10:55 +0000
+++ tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2013-06-19 18:58:26 +0000
@@ -14,6 +14,7 @@
14from autopilot.testcase import AutopilotTestCase14from autopilot.testcase import AutopilotTestCase
1515
16from ubuntu_terminal_app.emulators.main_window import MainWindow16from ubuntu_terminal_app.emulators.main_window import MainWindow
17from ubuntu_terminal_app.emulators.ubuntusdk import ubuntusdk
1718
1819
19class TerminalTestCase(AutopilotTestCase):20class TerminalTestCase(AutopilotTestCase):
@@ -52,4 +53,9 @@
5253
53 @property54 @property
54 def main_window(self):55 def main_window(self):
55 return MainWindow(self.app)56 return MainWindow(self, self.app)
57
58 @property
59 def ubuntu_sdk(self):
60 return ubuntusdk(self, self.app)
61
5662
=== modified file 'tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py'
--- tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2013-05-31 13:10:55 +0000
+++ tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2013-06-19 18:58:26 +0000
@@ -14,25 +14,64 @@
1414
15from ubuntu_terminal_app.tests import TerminalTestCase15from ubuntu_terminal_app.tests import TerminalTestCase
1616
17import time
1718
18class TestMainWindow(TerminalTestCase):19class TestMainWindow(TerminalTestCase):
1920
20 def setUp(self):21 def setUp(self):
21 super(TestMainWindow, self).setUp()22 super(TestMainWindow, self).setUp()
22 self.assertThat(23 self.assertThat(
23 self.main_window.get_qml_view().visible, Eventually(Equals(True)))24 self.ubuntu_sdk.get_qml_view().visible, Eventually(Equals(True)))
2425
25 def tearDown(self):26 def tearDown(self):
26 super(TestMainWindow, self).tearDown()27 super(TestMainWindow, self).tearDown()
2728
28 def test_toolbar_shows(self):29 def test_Control_Panel_shows(self):
29 """Make sure that dragging from the bottom reveals the hidden30 """Make sure that Control Keys Panel is visible
30 toolbar."""31 when clicking the toolbar popup items."""
31 toolbar = self.main_window.get_toolbar()32 self.ubuntu_sdk.click_toolbar_button("Panels")
3233 self.main_window.click_popup_item("Control keys")
33 x, y, w, h = toolbar.globalRect34 panelCtrl = self.ubuntu_sdk.get_object("CtrlKeys", "kbCtrl")
34 tx = x + (w / 2)35 self.assertThat(panelCtrl.visible, Eventually(Equals(True)))
35 ty = y + (h - 2)36
3637 def test_Function_Panel_shows(self):
37 self.pointing_device.drag(tx, ty, tx, ty - h)38 """Make sure that Function Keys Panel is visible
38 self.assertThat(toolbar.state, Eventually(Equals("spread")))39 when clicking the toolbar popup items."""
40 self.ubuntu_sdk.click_toolbar_button("Panels")
41 self.main_window.click_popup_item("Function keys")
42 panelFunc = self.ubuntu_sdk.get_object("FnKeys", "kbFn")
43 self.assertThat(panelFunc.visible, Eventually(Equals(True)))
44
45 def test_TextCtrl_Panel_shows(self):
46 """Make sure that Text Control Keys Panel is visible
47 when clicking the toolbar popup items."""
48 self.ubuntu_sdk.click_toolbar_button("Panels")
49 self.main_window.click_popup_item("Text ctrl keys")
50 panelScrl = self.ubuntu_sdk.get_object("ScrlKeys", "kbScrl")
51 self.assertThat(panelScrl.visible, Eventually(Equals(True)))
52
53 def test_Panels_hide(self):
54 """Make sure that all panels are hide
55 when clicking the toolbar popup items."""
56 self.ubuntu_sdk.click_toolbar_button("Panels")
57 self.main_window.click_popup_item("Hide extra panel")
58 panelCtrl = self.ubuntu_sdk.get_object("CtrlKeys", "kbCtrl")
59 panelFunc = self.ubuntu_sdk.get_object("FnKeys", "kbFn")
60 panelScrl = self.ubuntu_sdk.get_object("ScrlKeys", "kbScrl")
61 self.assertThat(panelCtrl.visible, Eventually(Equals(False)))
62 self.assertThat(panelFunc.visible, Eventually(Equals(False)))
63 self.assertThat(panelScrl.visible, Eventually(Equals(False)))
64
65 def test_CircleMenu_shows(self):
66 """Make sure that Circle Menu is visible
67 on long tap"""
68 kterm = self.ubuntu_sdk.get_object("KTerminalDisplay", "kterm")
69 menu = self.ubuntu_sdk.get_object("CircleMenu", "cmenu")
70 self.pointing_device.click_object(kterm)
71 self.pointing_device.press()
72 time.sleep(1)
73 self.pointing_device.release()
74 self.assertThat(menu.visible, Eventually(Equals(True)))
75
76
77

Subscribers

People subscribed via source and target branches