Merge lp:~nskaggs/ubuntu-terminal-app/convert-ap-to-sdk-emulator into lp:ubuntu-terminal-app

Proposed by Nicholas Skaggs
Status: Superseded
Proposed branch: lp:~nskaggs/ubuntu-terminal-app/convert-ap-to-sdk-emulator
Merge into: lp:ubuntu-terminal-app
Diff against target: 899 lines (+317/-409)
7 files modified
tests/autopilot/ubuntu_terminal_app/emulators.py (+138/-0)
tests/autopilot/ubuntu_terminal_app/emulators/__init__.py (+0/-6)
tests/autopilot/ubuntu_terminal_app/emulators/main_window.py (+0/-114)
tests/autopilot/ubuntu_terminal_app/emulators/ubuntusdk.py (+0/-157)
tests/autopilot/ubuntu_terminal_app/tests/__init__.py (+19/-20)
tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py (+149/-107)
ubuntu-terminal-app.qml (+11/-5)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-terminal-app/convert-ap-to-sdk-emulator
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Ubuntu Terminal Developers Pending
Review via email: mp+179530@code.launchpad.net

This proposal has been superseded by a proposal from 2013-08-09.

Commit message

This converts the terminal ap tests to the ubuntusdk emulator as well as cleans up and fixes all the tests; including the color scheme check

Description of the change

This converts the terminal ap tests to the ubuntusdk emulator as well as cleans up and fixes all the tests; including the color scheme check

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 :

Top approving to force new build for ease of testing on device.

25. By Nicholas Skaggs

add ubuntu-ui-toolkit-autopilot dependency, sigh /me facepalms

26. By Nicholas Skaggs

change to polling to support gated review vm

27. By Nicholas Skaggs

remove polling, remove kterm scheme

28. By Nicholas Skaggs

comment out font size change test for now

29. By Nicholas Skaggs

migrated to object polling instead of asserts

30. By Nicholas Skaggs

fix valueselector function

Unmerged revisions

30. By Nicholas Skaggs

fix valueselector function

29. By Nicholas Skaggs

migrated to object polling instead of asserts

28. By Nicholas Skaggs

comment out font size change test for now

27. By Nicholas Skaggs

remove polling, remove kterm scheme

26. By Nicholas Skaggs

change to polling to support gated review vm

25. By Nicholas Skaggs

add ubuntu-ui-toolkit-autopilot dependency, sigh /me facepalms

24. By Nicholas Skaggs

add timeout for bad sliding and sleep for db calls

23. By Nicholas Skaggs

all tests now working

22. By Nicholas Skaggs

slider test for font works

21. By Nicholas Skaggs

add polling for header check

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed directory 'tests/autopilot/ubuntu_terminal_app/emulators'
2=== added file 'tests/autopilot/ubuntu_terminal_app/emulators.py'
3--- tests/autopilot/ubuntu_terminal_app/emulators.py 1970-01-01 00:00:00 +0000
4+++ tests/autopilot/ubuntu_terminal_app/emulators.py 2013-08-09 19:48:09 +0000
5@@ -0,0 +1,138 @@
6+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
7+#
8+# Copyright (C) 2013 Canonical Ltd.
9+#
10+# This program is free software; you can redistribute it and/or modify
11+# it under the terms of the GNU Lesser General Public License as published by
12+# the Free Software Foundation; version 3.
13+#
14+# This program is distributed in the hope that it will be useful,
15+# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+# GNU Lesser General Public License for more details.
18+#
19+# You should have received a copy of the GNU Lesser General Public License
20+# along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
22+"""Terminal app autopilot emulators."""
23+
24+from time import sleep
25+from ubuntuuitoolkit import emulators as toolkit_emulators
26+
27+
28+class MainView(toolkit_emulators.MainView):
29+ """Terminal MainView Autopilot emulator."""
30+
31+ def get_header_item(self):
32+ """Get the header"""
33+ return self.select_single("Header")
34+
35+ def get_slider_item(self, slider):
36+ """Get the header"""
37+ return self.select_single("Slider", objectName=slider)
38+
39+ def get_kterm(self):
40+ return self.select_single("KTerminalDisplay", objectName="kterm")
41+ def get_control_panel(self):
42+ return self.select_single("CtrlKeys", objectName="kbCtrl")
43+
44+ def get_function_panel(self):
45+ return self.select_single("FnKeys", objectName="kbFn")
46+
47+ def get_scroll_panel(self):
48+ return self.select_single("ScrlKeys", objectName="kbScrl")
49+
50+ def get_terminal_page(self):
51+ return self.select_single("Terminal", objectName="pgTerm")
52+
53+ def get_circle_menu(self):
54+ return self.select_single("CircleMenu", objectName="cmenu")
55+
56+ def expand_width(self, val):
57+ """Expand width of the main QML view"""
58+ qmlView = self.get_qml_view()
59+ startX = int(qmlView.x + qmlView.width)
60+ stopX = int(qmlView.x + qmlView.width + val)
61+ lineY = int(qmlView.height/2)
62+ self.pointing_device.drag(startX, lineY, stopX, lineY)
63+
64+ def expand_height(self, val):
65+ """Expand height of the main QML view"""
66+ qmlView = self.get_qml_view()
67+ startY = int(qmlView.y + qmlView.height)
68+ stopY = int(qmlView.y + qmlView.height + val)
69+ lineX = int(qmlView.width/2)
70+ self.pointing_device.drag(lineX, startY, lineX, stopY)
71+
72+ def get_panel_actions_popover(self):
73+ """Return the ActionSelectionPopover emulator of the popup action."""
74+ return self.select_single(ActionSelectionPopover, objectName='panelpopover')
75+
76+ def drag_horizontal_slider(self, slider, pos):
77+ """Drag slider until value is set"""
78+ slItem = self.get_slider_item(slider)
79+
80+ # calculate required shift per position
81+ slRect = slItem.select_single("SliderStyle")
82+ thumbSpacing = slRect.thumbSpacing
83+
84+ slideMin = int(slItem.minimumValue)
85+ slideMax = int(slItem.maximumValue)
86+
87+ if pos > slideMax:
88+ raise ValueError("Pos cannot be greater than" + str(slideMax))
89+
90+ if pos < slideMin:
91+ raise ValueError("Pos cannot be less than" + str(slideMin))
92+
93+ x, y, w, h = slRect.globalRect
94+ sx = x + thumbSpacing
95+ sy = y+h/2
96+ loop = 1
97+
98+ #set the slider to minimum value and loop
99+ self.pointing_device.move(sx, sy)
100+ self.pointing_device.click()
101+
102+ #drag through the slider until the pos matches our desired value
103+ #in case of bad sliding, loop will also timeout
104+ while round(slItem.value) != pos and slItem.value<slideMax and loop<=(slideMax*2):
105+ #we can speed it along at twice the thumbSpacing and still hit everything
106+ valuePos = int(sx + (thumbSpacing * 2 * loop))
107+ self.pointing_device.drag(sx, sy, valuePos, sy)
108+ sleep(0.3)
109+ loop = loop + 1
110+
111+
112+class ActionSelectionPopover(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
113+ """ActionSelectionPopover Autopilot emulator."""
114+ # TODO Move this to the ubuntu-ui-toolkit. Reported on
115+ # https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205205
116+ # --elopio - 2013-07-25
117+
118+ def __init__(self, *args):
119+ super(ActionSelectionPopover, self).__init__(*args)
120+ self.pointing_device = toolkit_emulators.get_pointing_device()
121+
122+ def click_button(self, text):
123+ """Click a button on the popover.
124+
125+ XXX We are receiving the text because there's no way to set the
126+ objectName on the action. This is reported at
127+ https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205144
128+ --elopio - 2013-07-25
129+
130+ :parameter text: The text of the button.
131+
132+ """
133+ button = self._get_button(text)
134+ if button is None:
135+ raise ValueError(
136+ 'Button with text "{0}" not found.'.format(text))
137+ self.pointing_device.click_object(button)
138+
139+ def _get_button(self, text):
140+ buttons = self.select_many('Empty')
141+ for button in buttons:
142+ if button.text == text:
143+ return button
144
145=== removed file 'tests/autopilot/ubuntu_terminal_app/emulators/__init__.py'
146--- tests/autopilot/ubuntu_terminal_app/emulators/__init__.py 2013-05-31 13:10:55 +0000
147+++ tests/autopilot/ubuntu_terminal_app/emulators/__init__.py 1970-01-01 00:00:00 +0000
148@@ -1,6 +0,0 @@
149-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
150-# Copyright 2013 Canonical
151-#
152-# This program is free software: you can redistribute it and/or modify it
153-# under the terms of the GNU General Public License version 3, as published
154-# by the Free Software Foundation.
155
156=== removed file 'tests/autopilot/ubuntu_terminal_app/emulators/main_window.py'
157--- tests/autopilot/ubuntu_terminal_app/emulators/main_window.py 2013-07-19 18:16:29 +0000
158+++ tests/autopilot/ubuntu_terminal_app/emulators/main_window.py 1970-01-01 00:00:00 +0000
159@@ -1,114 +0,0 @@
160-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
161-# Copyright 2013 Canonical
162-#
163-# This program is free software: you can redistribute it and/or modify it
164-# under the terms of the GNU General Public License version 3, as published
165-# by the Free Software Foundation.
166-
167-"""Terminal app autopilot emulators."""
168-
169-class MainWindow(object):
170- """An emulator class that makes it easy to interact with the
171- terminal-app."""
172- def __init__(self, autopilot, app):
173- self.app = app
174- self.autopilot = autopilot
175-
176- def get_qml_view(self):
177- """Get the main QML view"""
178- return self.app.select_single("QQuickView")
179-
180- def get_header_item(self):
181- """Get the header"""
182- return self.app.select_single("Header")
183-
184- def get_slider_item(self, slider):
185- """Get the header"""
186- return self.app.select_single("Slider", objectName=slider)
187-
188- def expand_width(self, val):
189- """Expand width of the main QML view"""
190- qmlView = self.get_qml_view()
191- startX = int(qmlView.x + qmlView.width)
192- stopX = int(qmlView.x + qmlView.width + val)
193- lineY = int(qmlView.height/2)
194- self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
195-
196- def expand_height(self, val):
197- """Expand height of the main QML view"""
198- qmlView = self.get_qml_view()
199- startY = int(qmlView.y + qmlView.height)
200- stopY = int(qmlView.y + qmlView.height + val)
201- lineX = int(qmlView.width/2)
202- self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
203-
204- def click_action_selection_popup_item(self, popupLable):
205- """Clicks the toolbar popup item with popupLable"""
206- # The action selection is assumed to be the following format
207- # ActionSelectionPopover {
208- # actions: ActionList {
209- # Action {
210- # text:
211- li = self.app.select_single("ActionSelectionPopover")
212- row = li.select_single("QQuickColumn")
213- loaderList = row.select_many("QQuickLoader")
214- for loader in loaderList:
215- labelList = loader.select_many("Label")
216- for label in labelList:
217- if label.text == popupLable:
218- self.autopilot.pointing_device.click_object(label)
219-
220- def click_value_selector_item(self, selector, value):
221- """Clicks value from value selector"""
222- # The value selector is assumed to be the following format
223- # ListItem.ValueSelector {
224- # objectName:
225- # values:
226- val_selector = self.app.select_single("ValueSelector", objectName=selector)
227- self.autopilot.pointing_device.click_object(val_selector)
228- rows = val_selector.select_single("QQuickColumn")
229- rects = rows.select_many("QQuickRectangle")
230- for ritem in rects:
231- labelList = ritem.select_many("LabelVisual")
232- for label in labelList:
233- if label.text == value:
234- self.autopilot.pointing_device.click_object(label)
235-
236- def tap_horizontal_slider(self, slider, pos):
237- """Tap slider at position"""
238- slItem = self.get_slider_item(slider)
239- x, y, w, h = slItem.globalRect
240-
241- # pos to click inside the slider, px
242- self.autopilot.pointing_device.move(x+pos, y+(h/2))
243- self.autopilot.pointing_device.click()
244-
245- def drag_horizontal_slider(self, slider, pos):
246- """Drag slider by delta value"""
247- # The slider is assumed to be the following format
248- # Slider {
249- # objectName:
250- # minimumValue:
251- # maximumValue:
252- slItem = self.get_slider_item(slider)
253- slRect = slItem.select_single("SliderStyle")
254-
255- # calculate required shift per position
256- thumbSpace = slRect.thumbSpace
257- minVal = slItem.minimumValue
258- maxVal = slItem.maximumValue
259- shift = thumbSpace/(maxVal-minVal)
260-
261- # get thumb to drag
262- ushapes = slItem.select_many("UbuntuShape")
263- slThumb = ushapes[0]
264- for ushape in ushapes:
265- if ushape.width == slRect.thumbWidth:
266- slThumb = ushape
267-
268- x, y, w, h = slThumb.globalRect
269- sx = x+w/2
270- sy = y+h/2
271- self.autopilot.pointing_device.drag(sx, sy, sx+(shift*pos), sy)
272-
273-
274
275=== removed file 'tests/autopilot/ubuntu_terminal_app/emulators/ubuntusdk.py'
276--- tests/autopilot/ubuntu_terminal_app/emulators/ubuntusdk.py 2013-07-19 18:16:29 +0000
277+++ tests/autopilot/ubuntu_terminal_app/emulators/ubuntusdk.py 1970-01-01 00:00:00 +0000
278@@ -1,157 +0,0 @@
279-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
280-#
281-# Copyright (C) 2013 Canonical Ltd
282-#
283-# This program is free software: you can redistribute it and/or modify
284-# it under the terms of the GNU General Public License version 3 as
285-# published by the Free Software Foundation.
286-#
287-# This program is distributed in the hope that it will be useful,
288-# but WITHOUT ANY WARRANTY; without even the implied warranty of
289-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
290-# GNU General Public License for more details.
291-#
292-# You should have received a copy of the GNU General Public License
293-# along with this program. If not, see <http://www.gnu.org/licenses/>.
294-#
295-# Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com>
296-
297-from testtools.matchers import Equals, NotEquals, Not, Is
298-from autopilot.matchers import Eventually
299-
300-class ubuntusdk(object):
301- """An emulator class that makes it easy to interact with the ubuntu sdk applications."""
302-
303- def __init__(self, autopilot, app):
304- self.app = app
305- self.autopilot = autopilot
306-
307- def get_qml_view(self):
308- """Get the main QML view"""
309- return self.app.select_single("QQuickView")
310-
311- def get_object(self, typeName, name):
312- """Get a specific object"""
313- return self.app.select_single(typeName, objectName=name)
314-
315- def get_objects(self, typeName, name):
316- """Get more than one object"""
317- return self.app.select_many(typeName, objectName=name)
318-
319- def get_tabs(self):
320- """Return all tabs"""
321- return self.app.select_single("Tabs")
322-
323- def switch_to_tab(self, tab):
324- """Switch to the specified tab number"""
325- tabs = self.get_tabs()
326- currentTab = tabs.selectedTabIndex
327-
328- #perform operations until tab == currentTab
329- while tab != currentTab:
330- if tab > currentTab:
331- self._next_tab()
332- if tab < currentTab:
333- self._previous_tab()
334- currentTab = tabs.selectedTabIndex
335-
336- def _previous_tab(self):
337- """Switch to the previous tab"""
338- qmlView = self.get_qml_view()
339-
340- startX = int(qmlView.x + qmlView.width * 0.10)
341- stopX = int(qmlView.x + qmlView.width * 0.45)
342- lineY = int(qmlView.y + qmlView.height * 0.05)
343-
344- self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
345- self.autopilot.pointing_device.move(startX, lineY)
346- self.autopilot.pointing_device.click()
347- self.autopilot.pointing_device.click()
348-
349- def _next_tab(self):
350- """Switch to the next tab"""
351- qmlView = self.get_qml_view()
352-
353- startX = int(qmlView.x + qmlView.width * 0.45)
354- stopX = int(qmlView.x + qmlView.width * 0.10)
355- lineY = int(qmlView.y + qmlView.height * 0.05)
356-
357- self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
358- self.autopilot.pointing_device.move(startX, lineY)
359- self.autopilot.pointing_device.click()
360- self.autopilot.pointing_device.click()
361-
362- def toggle_toolbar(self):
363- """Toggle the toolbar between revealed and hidden"""
364- #check and see if the toolbar is open or not
365- if self.get_toolbar().opened:
366- self.hide_toolbar()
367- else:
368- self.open_toolbar()
369-
370- def get_toolbar(self):
371- """Returns the toolbar in the main events view."""
372- return self.app.select_single("Toolbar")
373-
374- def get_toolbar_button(self, buttonLabel):
375- """Returns the toolbar button at position index"""
376- toolbar = self.get_toolbar()
377- if not toolbar.opened:
378- self.open_toolbar()
379- row = toolbar.select_single("ToolbarItems")
380- loaderList = row.select_many("QQuickLoader")
381- for loader in loaderList:
382- buttonList = loader.select_many("Label")
383- for button in buttonList:
384- if button.text == buttonLabel:
385- return button
386-
387- def click_toolbar_button(self, buttonLabel):
388- """Clicks the toolbar button with buttonLabel"""
389- #The toolbar button is assumed to be the following format
390- # ToolbarItems {
391- # ToolbarButton {
392- # id:
393- # action: Action {
394- # text:
395- button = self.get_toolbar_button(buttonLabel)
396- self.autopilot.pointing_device.click_object(button)
397-
398- def open_toolbar(self):
399- """Open the toolbar"""
400- qmlView = self.get_qml_view()
401-
402- lineX = int(qmlView.x + qmlView.width * 0.50)
403- startY = int(qmlView.y + qmlView.height - 1)
404- stopY = int(qmlView.y + qmlView.height * 0.95)
405-
406- self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
407-
408- def hide_toolbar(self):
409- """Hide the toolbar"""
410- qmlView = self.get_qml_view()
411-
412- lineX = int(qmlView.x + qmlView.width * 0.50)
413- startY = int(qmlView.y + qmlView.height * 0.95)
414- stopY = int(qmlView.y + qmlView.height - 1)
415-
416- self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
417-
418- def set_popup_value(self, popover, button, value):
419- """Changes the given popover selector to the request value
420- At the moment this only works for values that are currently visible. To
421- access the remaining items, a help method to drag and recheck is needed."""
422- #The popover is assumed to be the following format
423- #Component {
424- # id: actionSelectionPopover
425- #
426- #ActionSelectionPopover {
427- # actions: ActionList {
428- # Action {
429-
430- popList = self.get_object("ActionSelectionPopover", popover)
431- itemList = popList.select_many("Label")
432- for item in itemList:
433- if item.text == value:
434- self.autopilot.pointing_device.click_object(item)
435- return item
436
437=== modified file 'tests/autopilot/ubuntu_terminal_app/tests/__init__.py'
438--- tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2013-07-19 18:16:29 +0000
439+++ tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2013-08-09 19:48:09 +0000
440@@ -7,21 +7,21 @@
441
442 """Terminal app autopilot tests."""
443
444+import sqlite3
445 import os.path
446-import sqlite3
447
448 from autopilot.input import Mouse, Touch, Pointer
449 from autopilot.platform import model
450 from autopilot.testcase import AutopilotTestCase
451+from ubuntuuitoolkit import emulators as toolkit_emulators
452
453-from ubuntu_terminal_app.emulators.main_window import MainWindow
454-from ubuntu_terminal_app.emulators.ubuntusdk import ubuntusdk
455+from ubuntu_terminal_app import emulators
456
457
458 class TerminalTestCase(AutopilotTestCase):
459
460- """A common test case class that provides several useful methods for
461- terminal-app tests.
462+ """A common testcase class that provides useful methods for the terminal
463+ app.
464
465 """
466 if model() == 'Desktop':
467@@ -34,6 +34,7 @@
468 def setUp(self):
469 self.pointing_device = Pointer(self.input_device_class.create())
470 super(TerminalTestCase, self).setUp()
471+
472 if os.path.exists(self.local_location):
473 self.launch_test_local()
474 else:
475@@ -43,23 +44,21 @@
476 self.app = self.launch_test_application(
477 "qmlscene",
478 self.local_location,
479- app_type='qt')
480+ app_type='qt',
481+ emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
482
483 def launch_test_installed(self):
484 self.app = self.launch_test_application(
485 "qmlscene",
486 "/usr/share/ubuntu-terminal-app/ubuntu-terminal-app.qml",
487- "--desktop_file_hint=/usr/share/applications/ubuntu-terminal-app.desktop",
488- app_type='qt')
489-
490- @property
491- def main_window(self):
492- return MainWindow(self, self.app)
493-
494- @property
495- def ubuntu_sdk(self):
496- return ubuntusdk(self, self.app)
497-
498+ "--desktop_file_hint="
499+ "/usr/share/applications/ubuntu-terminal-app.desktop",
500+ app_type='qt',
501+ emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
502+
503+ @property
504+ def main_view(self):
505+ return self.app.select_single(emulators.MainView)
506
507 class DbMan(object):
508 """
509@@ -99,19 +98,19 @@
510 conn = sqlite3.connect(db)
511
512 with conn:
513- cur = conn.cursor()
514+ cur = conn.cursor()
515 cur.execute("SELECT value FROM config WHERE item='fontSize'")
516 row = cur.fetchone()
517 if row is None:
518 self.assertNotEquals(row, None)
519 return int(row[0])
520-
521+
522 def get_color_scheme_from_storage(self):
523 db = self.get_db()
524 conn = sqlite3.connect(db)
525
526 with conn:
527- cur = conn.cursor()
528+ cur = conn.cursor()
529 cur.execute("SELECT value FROM config WHERE item='colorScheme'")
530 row = cur.fetchone()
531 if row is None:
532
533=== modified file 'tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py'
534--- tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2013-07-19 21:29:59 +0000
535+++ tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2013-08-09 19:48:09 +0000
536@@ -10,145 +10,187 @@
537 from __future__ import absolute_import
538
539 from autopilot.matchers import Eventually
540-from testtools.matchers import Equals, GreaterThan
541+from testtools.matchers import Equals, NotEquals,GreaterThan
542+from autopilot.platform import model
543
544 from ubuntu_terminal_app.tests import TerminalTestCase, DbMan
545
546-import time
547+from time import sleep
548+import random
549
550 class TestMainWindow(TerminalTestCase, DbMan):
551
552 def setUp(self):
553 super(TestMainWindow, self).setUp()
554 self.assertThat(
555- self.ubuntu_sdk.get_qml_view().visible, Eventually(Equals(True)))
556+ self.main_view.visible, Eventually(Equals(True)))
557
558 def tearDown(self):
559 super(TestMainWindow, self).tearDown()
560
561- def test_control_panel_shows(self):
562+ def hide_panels(self):
563+ """Click hide panels button"""
564+ toolbar = self.main_view.open_toolbar()
565+ timeout = 0
566+ toolbar.click_button("PanelsButton")
567+ panel_popover = self.main_view.get_panel_actions_popover()
568+
569+ #we have to poll the complex action because we can't check the animation for the header
570+ while panel_popover == None and timeout < 10:
571+ toolbar.click_button("PanelsButton")
572+ panel_popover = self.main_view.get_panel_actions_popover()
573+ sleep(1)
574+ timeout+=1
575+ panel_popover.click_button("Hide extra panel")
576+
577+ def click_value_selector_item(self, selector, value):
578+ """Clicks value from value selector"""
579+ # The value selector is assumed to be the following format
580+ # ListItem.ValueSelector {
581+ # objectName:
582+ # values:
583+ val_selector = self.main_view.select_single("ValueSelector", objectName=selector)
584+ self.assertThat(lambda: val_selector, Eventually(NotEquals(None)))
585+ self.pointing_device.click_object(val_selector)
586+ rows = val_selector.select_single("QQuickColumn")
587+ rects = rows.select_many("QQuickRectangle")
588+ for ritem in rects:
589+ labelList = ritem.select_many("LabelVisual")
590+ for label in labelList:
591+ if label.text == value:
592+ self.pointing_device.click_object(label)
593+ #check to make sure update is complete
594+ self.assertThat(lambda: val_selector.select_single("QQuickRepeater").state, Eventually(Equals("closed")))
595+ #check label match
596+ valBase = val_selector.select_single("Base")
597+ #the first label is always the "color scheme"
598+ valLabel = valBase.select_many("LabelVisual")[1]
599+ self.assertThat(lambda: valLabel.text, Eventually(Equals(value)))
600+
601+ def test_control_panel(self):
602 """Make sure that Control Keys Panel is visible
603- when clicking the toolbar popup items."""
604- self.ubuntu_sdk.click_toolbar_button("Panels")
605- self.main_window.click_action_selection_popup_item("Control keys")
606- panelCtrl = self.ubuntu_sdk.get_object("CtrlKeys", "kbCtrl")
607- self.assertThat(panelCtrl.visible, Eventually(Equals(True)))
608-
609- def test_function_panel_shows(self):
610- """Make sure that Function Keys Panel is visible
611- when clicking the toolbar popup items."""
612- self.ubuntu_sdk.click_toolbar_button("Panels")
613- self.main_window.click_action_selection_popup_item("Function keys")
614- panelFunc = self.ubuntu_sdk.get_object("FnKeys", "kbFn")
615- self.assertThat(panelFunc.visible, Eventually(Equals(True)))
616-
617- def test_TextCtrl_Panel_shows(self):
618+ when clicking the toolbar popup items and hides properly."""
619+ toolbar = self.main_view.open_toolbar()
620+ toolbar.click_button("PanelsButton")
621+
622+ panel_popover = self.main_view.get_panel_actions_popover()
623+ self.assertThat(lambda: panel_popover, Eventually(NotEquals(None)))
624+ panel_popover.click_button("Control keys")
625+
626+ panelCtrl = self.main_view.get_control_panel()
627+ self.assertThat(lambda: panelCtrl.visible, Eventually(Equals(True)))
628+
629+ self.hide_panels()
630+
631+ panelCtrl = self.main_view.get_control_panel()
632+ self.assertThat(lambda: panelCtrl.visible, Eventually(Equals(False)))
633+
634+ def test_function_panel(self):
635+ """Make sure that function Keys Panel is visible
636+ when clicking the toolbar popup items and hides properly."""
637+ toolbar = self.main_view.open_toolbar()
638+ toolbar.click_button("PanelsButton")
639+
640+ panel_popover = self.main_view.get_panel_actions_popover()
641+ self.assertThat(lambda: panel_popover, Eventually(NotEquals(None)))
642+ panel_popover.click_button("Function keys")
643+
644+ panelFunc = self.main_view.get_function_panel()
645+ self.assertThat(lambda: panelFunc.visible, Eventually(Equals(True)))
646+
647+ self.hide_panels()
648+
649+ panelFunc = self.main_view.get_function_panel()
650+ self.assertThat(lambda: panelFunc.visible, Eventually(Equals(False)))
651+
652+ def test_textctrl_panel(self):
653 """Make sure that Text Control Keys Panel is visible
654- when clicking the toolbar popup items."""
655- self.ubuntu_sdk.click_toolbar_button("Panels")
656- self.main_window.click_action_selection_popup_item("Text ctrl keys")
657- panelScrl = self.ubuntu_sdk.get_object("ScrlKeys", "kbScrl")
658- self.assertThat(panelScrl.visible, Eventually(Equals(True)))
659-
660- def test_panels_hide(self):
661- """Make sure that all panels are hide
662- when clicking the toolbar popup items."""
663- self.ubuntu_sdk.click_toolbar_button("Panels")
664- self.main_window.click_action_selection_popup_item("Hide extra panel")
665- panelCtrl = self.ubuntu_sdk.get_object("CtrlKeys", "kbCtrl")
666- panelFunc = self.ubuntu_sdk.get_object("FnKeys", "kbFn")
667- panelScrl = self.ubuntu_sdk.get_object("ScrlKeys", "kbScrl")
668- self.assertThat(panelCtrl.visible, Eventually(Equals(False)))
669- self.assertThat(panelFunc.visible, Eventually(Equals(False)))
670- self.assertThat(panelScrl.visible, Eventually(Equals(False)))
671+ when clicking the toolbar popup items and hides properly."""
672+ toolbar = self.main_view.open_toolbar()
673+ toolbar.click_button("PanelsButton")
674+
675+ panel_popover = self.main_view.get_panel_actions_popover()
676+ self.assertThat(lambda: panel_popover, Eventually(NotEquals(None)))
677+ panel_popover.click_button("Text ctrl keys")
678+
679+ panelScrl = self.main_view.get_scroll_panel()
680+ self.assertThat(lambda: panelScrl.visible, Eventually(Equals(True)))
681+
682+ self.hide_panels()
683+
684+ panelScrl = self.main_view.get_scroll_panel()
685+ self.assertThat(lambda: panelScrl.visible, Eventually(Equals(False)))
686
687 def test_circle_menu_shows(self):
688 """Make sure that Circle Menu is visible
689 on long tap"""
690- kterm = self.ubuntu_sdk.get_object("Terminal", "pgTerm")
691- menu = self.ubuntu_sdk.get_object("CircleMenu", "cmenu")
692+ kterm = self.main_view.get_terminal_page()
693+ menu = self.main_view.get_circle_menu()
694 self.pointing_device.click_object(kterm)
695 self.pointing_device.press()
696- time.sleep(1)
697+ sleep(2)
698 self.pointing_device.release()
699 self.assertThat(menu.visible, Eventually(Equals(True)))
700
701- def test_header_shows(self):
702+ def test_header(self):
703 """Make sure that Header is visible
704- in Portrait Mode"""
705- qmlView = self.ubuntu_sdk.get_qml_view()
706- header = self.main_window.get_header_item()
707- self.main_window.expand_width(10)
708- self.assertThat(qmlView.height, Eventually(GreaterThan(qmlView.width)))
709- self.assertThat(header.visible, Eventually(Equals(True)))
710+ in Portrait Mode and not visible in landscape mode"""
711+ header = self.main_view.get_header_item().visible
712+ if model() == "Nexus 10" or model() == "Nexus 7":
713+ self.assertThat(lambda: header, Eventually(Equals(False)))
714+ else:
715+ self.assertThat(lambda: header, Eventually(Equals(True)))
716
717- def test_header_hides(self):
718- """Make sure that Header is not visible
719- in Landscape Mode"""
720- qmlView = self.ubuntu_sdk.get_qml_view()
721- header = self.main_window.get_header_item()
722- self.main_window.expand_width(400)
723- self.assertThat(qmlView.width, Eventually(GreaterThan(qmlView.height)))
724- self.assertThat(header.visible, Eventually(Equals(False)))
725-
726-
727- # broken testcase. should be uncommented
728+ # broken testcase. should be uncommented
729 # and tested with latest update of ubuntu sdk
730-
731- #def test_color_scheme_changes(self):
732- # """Make sure that color scheme is set correctly"""
733- # qmlView = self.ubuntu_sdk.get_qml_view()
734- # # kterm = self.ubuntu_sdk.get_object("KTerminalDisplay", "kterm")
735- # self.ubuntu_sdk.switch_to_tab(1)
736-
737- # schemeList = ("DarkPastels",
738- # "Linux",
739- # "BlackOnRandomLight",
740- # "BlackOnWhite",
741- # "BlackOnLightYellow",
742- # "GreenOnBlack",
743- # "WhiteOnBlack",
744- # )
745-
746- # for scheme in schemeList:
747- # self.main_window.click_value_selector_item("liSchemes",scheme)
748- # # This assert uses KTerminalDisplay property (old rev)
749- # # self.assertThat(kterm.colorScheme, Eventually(Equals(scheme)))
750- # time.sleep(0.3)
751- # # This assert uses localstorage (new rev)
752- # colorScheme = self.get_color_scheme_from_storage()
753- # self.assertThat(colorScheme, Equals(scheme))
754+
755+ def test_color_scheme_changes(self):
756+ """Make sure that color scheme is set correctly"""
757+ kterm = self.main_view.get_kterm()
758+ self.main_view.switch_to_tab("SettingsTab")
759+
760+ #are these string translatable?
761+ #if so, we need to do this another way
762+ schemeList = ("DarkPastels",
763+ "Linux",
764+ "BlackOnRandomLight",
765+ "BlackOnWhite",
766+ "BlackOnLightYellow",
767+ "GreenOnBlack",
768+ "WhiteOnBlack",
769+ )
770+
771+ for scheme in schemeList:
772+ self.click_value_selector_item("liSchemes",scheme)
773+ sleep(1)
774+ # This assert uses KTerminalDisplay property (old rev)
775+ self.assertThat(kterm.colorScheme, Eventually(Equals(scheme)))
776+ # This assert uses localstorage (new rev)
777+ colorScheme = self.get_color_scheme_from_storage()
778+ self.assertThat(colorScheme, Equals(scheme))
779
780
781 def test_font_size_changes(self):
782 """Make sure that font size is set correctly"""
783- self.ubuntu_sdk.switch_to_tab(1)
784- slider = self.main_window.get_slider_item("slFont")
785-
786- # start and end positions
787- i = int(slider.minimumValue) + 1
788- iMax = int(slider.maximumValue)
789-
790- # return to start position of the slider
791- self.main_window.tap_horizontal_slider("slFont",5)
792- time.sleep(0.3)
793+ self.main_view.switch_to_tab("SettingsTab")
794+ slider = self.main_view.get_slider_item("slFont")
795+
796+ # change font size to max
797+ self.main_view.drag_horizontal_slider("slFont",32)
798+ sleep(1)
799+ font_size = self.get_font_size_from_storage()
800+ self.assertThat(font_size, Equals(32))
801+
802+ ## change font size to min
803+ self.main_view.drag_horizontal_slider("slFont",8)
804+ sleep(1)
805 font_size = self.get_font_size_from_storage()
806 self.assertThat(font_size, Equals(8))
807
808- p = 1
809- while ( i < (iMax+1) ):
810- # WARNING - MAGIC nums: should be removed with better case
811- if (i == 18):
812- p = 1.4
813- if (i == 20):
814- p = 1
815-
816- self.main_window.drag_horizontal_slider("slFont",p)
817- time.sleep(0.3)
818+ ## change font size to random sizes
819+ for loop in range(1,3):
820+ randSize = random.randrange(8,32,1)
821+ self.main_view.drag_horizontal_slider("slFont",randSize)
822+ sleep(1)
823 font_size = self.get_font_size_from_storage()
824- self.assertThat(font_size, Equals(i))
825- i+=1
826-
827-
828-
829-
830+ self.assertThat(font_size, Equals(randSize))
831
832=== modified file 'ubuntu-terminal-app.qml'
833--- ubuntu-terminal-app.qml 2013-07-19 18:16:29 +0000
834+++ ubuntu-terminal-app.qml 2013-08-09 19:48:09 +0000
835@@ -17,20 +17,25 @@
836 id: actionSelectionPopover
837
838 ActionSelectionPopover {
839+ objectName: "panelpopover"
840 actions: ActionList {
841 Action {
842+ objectName: "controlkeysaction"
843 text: i18n.tr("Control keys")
844 onTriggered: pgTerm.showExtraPanel(1)
845 }
846 Action {
847+ objectName: "functionkeysaction"
848 text: i18n.tr("Function keys")
849 onTriggered: pgTerm.showExtraPanel(2)
850 }
851 Action {
852+ objectName: "textkeysaction"
853 text: i18n.tr("Text ctrl keys")
854 onTriggered: pgTerm.showExtraPanel(3)
855 }
856 Action {
857+ objectName: "hidepanelaction"
858 text: i18n.tr("Hide extra panel")
859 onTriggered: pgTerm.showExtraPanel(0)
860 }
861@@ -42,9 +47,9 @@
862 id: tabs
863 objectName: "rootTabs"
864 anchors.fill: parent
865-
866+
867 Tab {
868- objectName: "Tab1"
869+ objectName: "TerminalTab"
870 title: i18n.tr("Terminal")
871 page: Page {
872
873@@ -56,14 +61,15 @@
874 header.visible = width < height;
875 }
876
877- Terminal {
878+ Terminal {
879 id: pgTerm
880- objectName: "pgTerm"
881+ objectName: "pgTerm"
882 }
883
884 tools: ToolbarItems {
885 ToolbarButton {
886 id: toolbarAction
887+ objectName: "PanelsButton"
888 action: Action {
889 text: "Panels"
890 iconSource: Qt.resolvedUrl("avatar.png")
891@@ -77,7 +83,7 @@
892 }
893
894 Tab {
895- objectName: "Tab2"
896+ objectName: "SettingsTab"
897 title: i18n.tr("Settings")
898 page: Page {
899 Configs { id: pgConf }

Subscribers

People subscribed via source and target branches