Merge lp:~nskaggs/ubuntu-terminal-app/ap-restruct into lp:ubuntu-terminal-app

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 137
Merged at revision: 133
Proposed branch: lp:~nskaggs/ubuntu-terminal-app/ap-restruct
Merge into: lp:ubuntu-terminal-app
Diff against target: 763 lines (+299/-348)
5 files modified
src/app/qml/Terminal.qml (+0/-62)
tests/autopilot/ubuntu_terminal_app/__init__.py (+173/-7)
tests/autopilot/ubuntu_terminal_app/emulators.py (+0/-81)
tests/autopilot/ubuntu_terminal_app/tests/__init__.py (+35/-104)
tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py (+91/-94)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-terminal-app/ap-restruct
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Ubuntu Terminal Developers Pending
Review via email: mp+232748@code.launchpad.net

Commit message

Restructure test launching, fix 1341681

Description of the change

Restructure test launching, fix 1341681

remove hud actions

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

animation fixes, split tests

133. By Nicholas Skaggs

flake8 happiness

134. By Nicholas Skaggs

tweak test_header

135. By Nicholas Skaggs

flake8

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

move circle menu helper

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
Alan Pope 🍺🐧🐱 🦄 (popey) wrote :

Looks like pyflakes issues:-

+ pyflakes .
./tests/autopilot/ubuntu_terminal_app/__init__.py:65: local variable 'kterm' is assigned to but never used
./debian/tmp/usr/lib/python3/dist-packages/ubuntu_terminal_app/__init__.py:65: local variable 'kterm' is assigned to but never used
./debian/ubuntu-terminal-app-autopilot/usr/lib/python3/dist-packages/ubuntu_terminal_app/__init__.py:65: local variable 'kterm' is assigned to but never used

137. By Nicholas Skaggs

flake8 happiness

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 'src/app/qml/Terminal.qml'
2--- src/app/qml/Terminal.qml 2014-08-26 13:31:30 +0000
3+++ src/app/qml/Terminal.qml 2014-09-02 16:53:27 +0000
4@@ -1,7 +1,6 @@
5 import QtQuick 2.0
6 import Ubuntu.Components 0.1
7 import org.kde.konsole 0.1
8-import Ubuntu.Unity.Action 1.0 as UnityActions
9 import "config"
10 import "extraPanel"
11
12@@ -368,65 +367,4 @@
13 }
14
15 }
16-
17- UnityActions.ActionContext {
18- id: actionContext
19- active: mparent.visible
20- actions: [
21- UnityActions.Action {
22- text: i18n.tr("Upload Crash Reports")
23- keywords: i18n.tr("Whoopsie;Apport;Debugging;Bugs")
24- onTriggered: ksession.sendText("\x03\n/usr/share/apport/whoopsie-upload-all\n")
25- },
26- UnityActions.Action {
27- text: i18n.tr("Make Image Writable")
28- keywords: i18n.tr("System Image;Install Deb")
29- onTriggered: ksession.sendText("\x03\nsudo touch /userdata/.writable_image\n")
30- },
31- UnityActions.Action {
32- text: i18n.tr("List Running Applications")
33- keywords: i18n.tr("Apps")
34- onTriggered: ksession.sendText("\x03\nupstart-app-list\n")
35- },
36- UnityActions.Action {
37- text: i18n.tr("Installed Click Packages")
38- keywords: i18n.tr("Packages;Applications;Utilities")
39- onTriggered: ksession.sendText("\x03\nclick list\n")
40- },
41- UnityActions.Action {
42- text: i18n.tr("System Image Information")
43- keywords: i18n.tr("Image;Version;Channel")
44- onTriggered: ksession.sendText("\x03\nsudo system-image-cli -i\n")
45- },
46- UnityActions.Action {
47- text: i18n.tr("System Kernel Version")
48- onTriggered: ksession.sendText("\x03\nuname -a\n")
49- },
50- UnityActions.Action {
51- text: i18n.tr("Upstart Job Status")
52- keywords: i18n.tr("Init;Session;User Job")
53- onTriggered: ksession.sendText("\x03\ninitctl list | sort\n")
54- },
55- UnityActions.Action {
56- text: i18n.tr("Hack into the NSA")
57- keywords: i18n.tr("Government;Secret;Cracking")
58- onTriggered: ksession.sendText("\x03\nclear;echo -n \"That's not very nice, now tracing your location .\";sleep 1;echo -n \" .\";sleep 1;echo -n \" .\";sleep 1;echo -n \" .\";sleep 1;echo -n \" .\";sleep 1;echo -n \" .\";sleep 1;echo -n \" .\";sleep 1;echo -n \" .\";sleep 1;echo -n \" .\";sleep 1;echo -n \" .\";sleep 1;echo -n \" .\";sleep 1;echo -n \" .\";echo \"Trace failed\";echo \"You get away this time, but don't try again.\"\n")
59- },
60- UnityActions.Action {
61- text: i18n.tr("Watch Running Processes")
62- keywords: i18n.tr("Top;Memory;Usage")
63- onTriggered: ksession.sendText("\x03\ntop\n")
64- },
65- UnityActions.Action {
66- text: i18n.tr("Networking Status")
67- keywords: i18n.tr("Wireless;Ethernet;Access Points")
68- onTriggered: ksession.sendText("\x03\nnm-tool\n")
69- },
70- UnityActions.Action {
71- text: i18n.tr("Watch Star Wars Episode IV")
72- keywords: i18n.tr("Death Star;Skywalker;Leia;Darth Vader")
73- onTriggered: ksession.sendText("\x03\nnetcat -v towel.blinkenlights.nl 23\n")
74- }
75- ]
76- }
77 }
78
79=== modified file 'tests/autopilot/ubuntu_terminal_app/__init__.py'
80--- tests/autopilot/ubuntu_terminal_app/__init__.py 2013-05-31 13:10:55 +0000
81+++ tests/autopilot/ubuntu_terminal_app/__init__.py 2014-09-02 16:53:27 +0000
82@@ -1,8 +1,174 @@
83 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
84-# Copyright 2013 Canonical
85-#
86-# This program is free software: you can redistribute it and/or modify it
87-# under the terms of the GNU General Public License version 3, as published
88-# by the Free Software Foundation.
89-
90-"""terminal-app tests and emulators - top level package."""
91+#
92+# Copyright (C) 2013 Canonical Ltd.
93+#
94+# This program is free software; you can redistribute it and/or modify
95+# it under the terms of the GNU Lesser General Public License as published by
96+# the Free Software Foundation; version 3.
97+#
98+# This program is distributed in the hope that it will be useful,
99+# but WITHOUT ANY WARRANTY; without even the implied warranty of
100+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
101+# GNU Lesser General Public License for more details.
102+#
103+# You should have received a copy of the GNU Lesser General Public License
104+# along with this program. If not, see <http://www.gnu.org/licenses/>.
105+
106+"""Terminal app autopilot helpers."""
107+
108+from time import sleep
109+import sqlite3
110+import os.path
111+import ubuntuuitoolkit
112+
113+
114+class TerminalApp(object):
115+
116+ """Autopilot helper object for the terminal application."""
117+
118+ def __init__(self, app_proxy):
119+ self.app = app_proxy
120+ self.main_view = self.app.select_single(MainView)
121+
122+ @property
123+ def pointing_device(self):
124+ return self.app.pointing_device
125+
126+
127+class MainView(ubuntuuitoolkit.MainView):
128+
129+ """Autopilot custom proxy object for the MainView."""
130+
131+ def __init__(self, *args):
132+ super(MainView, self).__init__(*args)
133+ self.visible.wait_for(True)
134+
135+ def get_slider_item(self, slider):
136+ return self.wait_select_single("Slider", objectName=slider)
137+
138+ def get_control_panel(self):
139+ return self.wait_select_single("CtrlKeys", objectName="kbCtrl")
140+
141+ def get_function_panel(self):
142+ return self.wait_select_single("FnKeys", objectName="kbFn")
143+
144+ def get_text_panel(self):
145+ return self.wait_select_single("ScrlKeys", objectName="kbScrl")
146+
147+ def get_terminal_page(self):
148+ return self.wait_select_single("Terminal", objectName="pgTerm")
149+
150+ def get_circle_menu(self):
151+ return self.wait_select_single("CircleMenu", objectName="cmenu")
152+
153+ def long_tap_terminal_center(self):
154+ x, y, w, h = self.globalRect
155+ tap_x = (x + w) / 2
156+ tap_y = (y + h) / 3
157+
158+ # tap in the top third of the screen, to avoid OSK
159+ self.pointing_device.move(tap_x, tap_y)
160+ self.pointing_device.press()
161+ # we can hold the press for a long time without issue
162+ # so we'll ensure the app recieves our signal when under load
163+ sleep(4)
164+ self.pointing_device.release()
165+
166+ def drag_horizontal_slider(self, slider, pos):
167+ """Drag slider until value is set"""
168+ slItem = self.get_slider_item(slider)
169+
170+ slRect = slItem.select_single("SliderStyle")
171+
172+ slideMin = int(slItem.minimumValue)
173+ slideMax = int(slItem.maximumValue)
174+
175+ if pos > slideMax:
176+ raise ValueError("Pos cannot be greater than" + str(slideMax))
177+
178+ if pos < slideMin:
179+ raise ValueError("Pos cannot be less than" + str(slideMin))
180+
181+ x, y, w, h = slRect.globalRect
182+ # calculate the approximate slide step width
183+ # we take half of the theoretical step value just to make
184+ # sure we don't miss any values
185+ step = w / ((slideMax - slideMin) * 2)
186+ sx = x + step
187+ sy = y + h / 2
188+ loop = 1
189+
190+ # set the slider to minimum value and loop
191+ self.pointing_device.move(sx, sy)
192+ self.pointing_device.click()
193+
194+ # drag through the slider until the pos matches our desired value
195+ # in case of bad sliding, loop will also timeout
196+ while round(slItem.value) != pos and slItem.value < slideMax \
197+ and loop <= (slideMax * 2):
198+ valuePos = int(sx + step)
199+ self.pointing_device.drag(sx, sy, valuePos, sy)
200+ sx = valuePos
201+ sleep(1)
202+ loop = loop + 1
203+
204+
205+class DbMan(object):
206+
207+ """
208+ Helper functions for dealing with sqlite databases
209+ """
210+
211+ def get_db(self):
212+ dbs_path = os.path.expanduser(
213+ "~/.local/share/com.ubuntu.terminal/Databases")
214+ if not os.path.exists(dbs_path):
215+ return None
216+
217+ files = [f for f in os.listdir(dbs_path)
218+ if os.path.splitext(f)[1] == ".ini"]
219+ for f in files:
220+ ini_path = os.path.join(dbs_path, f)
221+ with open(ini_path) as ini:
222+ for line in ini:
223+ if "=" in line:
224+ key, val = line.strip().split("=")
225+ if key == "Name" and val == "UbuntuTerminalDB":
226+ try:
227+ return ini_path.replace(".ini", ".sqlite")
228+ except OSError:
229+ pass
230+ return None
231+
232+ def clean_db(self):
233+ path = self.get_db()
234+ if path is None:
235+ self.assertNotEquals(path, None)
236+ try:
237+ os.remove(path)
238+ except OSError:
239+ pass
240+
241+ def get_font_size_from_storage(self):
242+ db = self.get_db()
243+ conn = sqlite3.connect(db)
244+
245+ with conn:
246+ cur = conn.cursor()
247+ cur.execute("SELECT value FROM config WHERE item='fontSize'")
248+ row = cur.fetchone()
249+ if row is None:
250+ self.assertNotEquals(row, None)
251+ return int(row[0])
252+
253+ def get_color_scheme_from_storage(self):
254+ db = self.get_db()
255+ conn = sqlite3.connect(db)
256+
257+ with conn:
258+ cur = conn.cursor()
259+ cur.execute("SELECT value FROM config WHERE item='colorScheme'")
260+ row = cur.fetchone()
261+ if row is None:
262+ self.assertNotEquals(row, None)
263+ return row[0]
264
265=== removed file 'tests/autopilot/ubuntu_terminal_app/emulators.py'
266--- tests/autopilot/ubuntu_terminal_app/emulators.py 2014-08-28 16:47:48 +0000
267+++ tests/autopilot/ubuntu_terminal_app/emulators.py 1970-01-01 00:00:00 +0000
268@@ -1,81 +0,0 @@
269-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
270-#
271-# Copyright (C) 2013 Canonical Ltd.
272-#
273-# This program is free software; you can redistribute it and/or modify
274-# it under the terms of the GNU Lesser General Public License as published by
275-# the Free Software Foundation; version 3.
276-#
277-# This program is distributed in the hope that it will be useful,
278-# but WITHOUT ANY WARRANTY; without even the implied warranty of
279-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
280-# GNU Lesser General Public License for more details.
281-#
282-# You should have received a copy of the GNU Lesser General Public License
283-# along with this program. If not, see <http://www.gnu.org/licenses/>.
284-
285-"""Terminal app autopilot emulators."""
286-
287-from time import sleep
288-from ubuntuuitoolkit import emulators as toolkit_emulators
289-
290-
291-class MainView(toolkit_emulators.MainView):
292-
293- """Terminal MainView Autopilot emulator."""
294-
295- def get_slider_item(self, slider):
296- return self.wait_select_single("Slider", objectName=slider)
297-
298- def get_control_panel(self):
299- return self.wait_select_single("CtrlKeys", objectName="kbCtrl")
300-
301- def get_function_panel(self):
302- return self.wait_select_single("FnKeys", objectName="kbFn")
303-
304- def get_scroll_panel(self):
305- return self.wait_select_single("ScrlKeys", objectName="kbScrl")
306-
307- def get_terminal_page(self):
308- return self.wait_select_single("Terminal", objectName="pgTerm")
309-
310- def get_circle_menu(self):
311- return self.wait_select_single("CircleMenu", objectName="cmenu")
312-
313- def drag_horizontal_slider(self, slider, pos):
314- """Drag slider until value is set"""
315- slItem = self.get_slider_item(slider)
316-
317- slRect = slItem.select_single("SliderStyle")
318-
319- slideMin = int(slItem.minimumValue)
320- slideMax = int(slItem.maximumValue)
321-
322- if pos > slideMax:
323- raise ValueError("Pos cannot be greater than" + str(slideMax))
324-
325- if pos < slideMin:
326- raise ValueError("Pos cannot be less than" + str(slideMin))
327-
328- x, y, w, h = slRect.globalRect
329- # calculate the approximate slide step width
330- # we take half of the theoretical step value just to make
331- # sure we don't miss any values
332- step = w / ((slideMax - slideMin) * 2)
333- sx = x + step
334- sy = y + h / 2
335- loop = 1
336-
337- # set the slider to minimum value and loop
338- self.pointing_device.move(sx, sy)
339- self.pointing_device.click()
340-
341- # drag through the slider until the pos matches our desired value
342- # in case of bad sliding, loop will also timeout
343- while round(slItem.value) != pos and slItem.value < slideMax \
344- and loop <= (slideMax * 2):
345- valuePos = int(sx + step)
346- self.pointing_device.drag(sx, sy, valuePos, sy)
347- sx = valuePos
348- sleep(0.3)
349- loop = loop + 1
350
351=== modified file 'tests/autopilot/ubuntu_terminal_app/tests/__init__.py'
352--- tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2014-06-27 15:14:32 +0000
353+++ tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2014-09-02 16:53:27 +0000
354@@ -7,16 +7,16 @@
355
356 """Terminal app autopilot tests."""
357
358-import sqlite3
359 import os.path
360-
361 import fixtures
362-from autopilot.input import Mouse, Touch, Pointer
363-from autopilot.platform import model
364+import logging
365+from autopilot import logging as autopilot_logging
366 from autopilot.testcase import AutopilotTestCase
367-from ubuntuuitoolkit import emulators as toolkit_emulators
368-
369-from ubuntu_terminal_app import emulators
370+import ubuntuuitoolkit
371+
372+import ubuntu_terminal_app
373+
374+logger = logging.getLogger(__name__)
375
376
377 class TerminalTestCase(AutopilotTestCase):
378@@ -25,120 +25,51 @@
379 app.
380
381 """
382- if model() == 'Desktop':
383- scenarios = [('with mouse', dict(input_device_class=Mouse))]
384- else:
385- scenarios = [('with touch', dict(input_device_class=Touch))]
386+
387+ binary = 'terminal'
388+ source_dir = os.path.dirname(os.path.dirname(os.path.abspath('.')))
389+ local_location_binary = os.path.join(source_dir, 'src', 'app', binary)
390+ installed_location_binary = os.path.join('/usr/bin/', binary)
391+ installed_location_qml = '/usr/share/terminal/qml/ubuntu-terminal-app.qml'
392
393 def setUp(self):
394- self.pointing_device = Pointer(self.input_device_class.create())
395 super(TerminalTestCase, self).setUp()
396-
397- self.EXEC = 'terminal'
398- self.source_dir = os.path.dirname(
399- os.path.dirname(os.path.abspath('.')))
400- self.build_dir = self._get_build_dir()
401- self.local_location_binary = os.path.join(self.build_dir,
402- 'src', 'app', self.EXEC)
403- self.installed_location_binary = os.path.join('/usr/bin/', self.EXEC)
404- self.installed_location_qml = \
405- '/usr/share/terminal/qml/ubuntu-terminal-app.qml'
406-
407+ launcher_method, _ = self.get_launcher_method_and_type()
408+ self.app = ubuntu_terminal_app.TerminalApp(launcher_method())
409+
410+ def get_launcher_method_and_type(self):
411 if os.path.exists(self.local_location_binary):
412- self.launch_test_local()
413+ launcher = self.launch_test_local
414+ test_type = 'local'
415 elif os.path.exists(self.installed_location_binary):
416- self.launch_test_installed()
417+ launcher = self.launch_test_installed
418+ test_type = 'deb'
419 else:
420- self.launch_test_click()
421-
422- def _get_build_dir(self):
423- build_dir = self.source_dir
424-
425- return build_dir
426-
427+ launcher = self.launch_test_click
428+ test_type = 'click'
429+ return launcher, test_type
430+
431+ @autopilot_logging.log_action(logger.info)
432 def launch_test_local(self):
433 self.useFixture(fixtures.EnvironmentVariable(
434- 'QML2_IMPORT_PATH', newvalue=os.path.join(self.build_dir,
435+ 'QML2_IMPORT_PATH', newvalue=os.path.join(self.source_dir,
436 'src', 'plugin')))
437
438- self.app = self.launch_test_application(
439+ return self.launch_test_application(
440 self.local_location_binary,
441 app_type='qt',
442- emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
443+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
444
445+ @autopilot_logging.log_action(logger.info)
446 def launch_test_installed(self):
447- self.app = self.launch_test_application(
448+ return self.launch_test_application(
449 self.installed_location_binary,
450 '-q', self.installed_location_qml,
451 app_type='qt',
452- emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
453+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
454
455+ @autopilot_logging.log_action(logger.info)
456 def launch_test_click(self):
457- self.app = self.launch_click_package(
458+ return self.launch_click_package(
459 "com.ubuntu.terminal",
460- emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
461-
462- @property
463- def main_view(self):
464- return self.app.select_single(emulators.MainView)
465-
466-
467-class DbMan(object):
468-
469- """
470- Helper functions for dealing with sqlite databases
471- """
472-
473- def get_db(self):
474- dbs_path = os.path.expanduser(
475- "~/.local/share/com.ubuntu.terminal/Databases")
476- if not os.path.exists(dbs_path):
477- return None
478-
479- files = [f for f in os.listdir(dbs_path)
480- if os.path.splitext(f)[1] == ".ini"]
481- for f in files:
482- ini_path = os.path.join(dbs_path, f)
483- with open(ini_path) as ini:
484- for line in ini:
485- if "=" in line:
486- key, val = line.strip().split("=")
487- if key == "Name" and val == "UbuntuTerminalDB":
488- try:
489- return ini_path.replace(".ini", ".sqlite")
490- except OSError:
491- pass
492- return None
493-
494- def clean_db(self):
495- path = self.get_db()
496- if path is None:
497- self.assertNotEquals(path, None)
498- try:
499- os.remove(path)
500- except OSError:
501- pass
502-
503- def get_font_size_from_storage(self):
504- db = self.get_db()
505- conn = sqlite3.connect(db)
506-
507- with conn:
508- cur = conn.cursor()
509- cur.execute("SELECT value FROM config WHERE item='fontSize'")
510- row = cur.fetchone()
511- if row is None:
512- self.assertNotEquals(row, None)
513- return int(row[0])
514-
515- def get_color_scheme_from_storage(self):
516- db = self.get_db()
517- conn = sqlite3.connect(db)
518-
519- with conn:
520- cur = conn.cursor()
521- cur.execute("SELECT value FROM config WHERE item='colorScheme'")
522- row = cur.fetchone()
523- if row is None:
524- self.assertNotEquals(row, None)
525- return row[0]
526+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
527
528=== modified file 'tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py'
529--- tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2014-08-28 16:18:16 +0000
530+++ tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2014-09-02 16:53:27 +0000
531@@ -11,112 +11,108 @@
532
533 from autopilot.matchers import Eventually
534 from testtools.matchers import Equals
535-from autopilot.platform import model
536
537-from ubuntu_terminal_app.tests import TerminalTestCase, DbMan
538-from ubuntuuitoolkit import ToolkitException as ToolkitException
539+from ubuntu_terminal_app.tests import TerminalTestCase
540+from ubuntu_terminal_app import DbMan
541+from ubuntuuitoolkit import ToolkitException
542+from testscenarios import TestWithScenarios
543
544 from time import sleep
545 import random
546
547
548-class TestMainWindow(TerminalTestCase, DbMan):
549-
550- def setUp(self):
551- super(TestMainWindow, self).setUp()
552- self.assertThat(
553- self.main_view.visible, Eventually(Equals(True)))
554-
555- def hide_panels(self):
556- """Click hide panels button"""
557- header = self.main_view.get_header()
558- header.click_action_button('hidepanelaction')
559- # Click on the button a second time in case that the
560- # actions list was open and the first click just closed it
561- # without further effect. If that was not the case, then
562- # be prepared to catch the exception, as once clicked on,
563- # the action to hide panels makes the button no longer visible
564+class TestMainWindow(TerminalTestCase):
565+
566+ def test_circle_menu_shows(self):
567+ """Make sure that Circle Menu is visible
568+ on long tap"""
569+ self.app.main_view.long_tap_terminal_center()
570+ menu = self.app.main_view.get_circle_menu()
571+ self.assertThat(menu.visible, Eventually(Equals(True)))
572+
573+ def test_header(self):
574+ """Make sure that Header is visible
575+ in Portrait Mode and not visible in landscape mode"""
576+ kterm = self.app.main_view.get_terminal_page()
577+ header = self.app.main_view.get_header()
578+ if kterm.width > kterm.height:
579+ self.assertThat(header.visible, Equals(False))
580+ else:
581+ self.assertThat(header.visible, Equals(True))
582+
583+
584+class TestPanel(TerminalTestCase, TestWithScenarios):
585+
586+ scenarios = [
587+ ('controlpanel',
588+ {'button': 'controlkeysaction',
589+ 'helper_method': 'get_control_panel'
590+ }),
591+
592+ ('functionpanel',
593+ {'button': 'functionkeysaction',
594+ 'helper_method': 'get_function_panel'
595+ }),
596+
597+ ('textpanel',
598+ {'button': 'textkeysaction',
599+ 'helper_method': 'get_text_panel'
600+ })
601+ ]
602+
603+ def open_panel(self, button, helper_method):
604+ """Open named panel"""
605+ header = self.app.main_view.get_header()
606+ header.click_action_button(button)
607+ get_panel = getattr(self.app.main_view, helper_method)
608+ return get_panel()
609+
610+ def hide_panel(self):
611+ """Close any open panel"""
612+ header = self.app.main_view.get_header()
613+
614+ # the overflow panel can be left open, so we need to try again
615+ # https://bugs.launchpad.net/ubuntu-terminal-app/+bug/1363233
616 try:
617 header.click_action_button('hidepanelaction')
618+ try:
619+ sleep(2)
620+ header.click_action_button('hidepanelaction')
621+ except ToolkitException:
622+ pass
623 except ToolkitException:
624 pass
625
626+ def test_panels(self):
627+ """Make sure that Panel is visible
628+ when clicking the toolbar popup items and hides properly."""
629+ panel = self.open_panel(self.button, self.helper_method)
630+ self.assertThat(panel.visible, Eventually(Equals(True)))
631+ self.hide_panel()
632+ self.assertThat(panel.visible, Eventually(Equals(False)))
633+
634+
635+class TestSettings(TerminalTestCase, DbMan):
636+
637 def click_item_selector_item(self, selector, value):
638 """Clicks item from item selector"""
639 # This needs a toolkit helper
640 # https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1272345
641- item_selector = self.main_view.wait_select_single('ItemSelector',
642- objectName=selector)
643- selector = item_selector.wait_select_single('Standard',
644- objectName='listContainer')
645- self.pointing_device.click_object(selector)
646- item_selector.currentlyExpanded.wait_for(True)
647+ select = self.app.main_view.wait_select_single('ItemSelector',
648+ objectName=selector)
649+ container = select.wait_select_single('Standard',
650+ objectName='listContainer')
651+ self.app.pointing_device.click_object(container)
652+ select.currentlyExpanded.wait_for(True)
653 # waiting for currentlyExpanded is not enough
654 # some animation is not accounted for and thus we sleep
655 sleep(2)
656- item = selector.wait_select_single('Label', text=value)
657- self.pointing_device.click_object(item)
658-
659- def test_control_panel(self):
660- """Make sure that Control Keys Panel is visible
661- when clicking the toolbar popup items and hides properly."""
662- header = self.main_view.get_header()
663- header.click_action_button('controlkeysaction')
664-
665- panelCtrl = lambda: self.main_view.get_control_panel().visible
666- self.assertThat(panelCtrl, Eventually(Equals(True)))
667- self.hide_panels()
668- self.assertThat(panelCtrl, Eventually(Equals(False)))
669-
670- def test_function_panel(self):
671- """Make sure that function Keys Panel is visible
672- when clicking the toolbar popup items and hides properly."""
673- header = self.main_view.get_header()
674- header.click_action_button('functionkeysaction')
675-
676- panelFunc = lambda: self.main_view.get_function_panel().visible
677- self.assertThat(panelFunc, Eventually(Equals(True)))
678- self.hide_panels()
679- self.assertThat(panelFunc, Eventually(Equals(False)))
680-
681- def test_textctrl_panel(self):
682- """Make sure that Text Control Keys Panel is visible
683- when clicking the toolbar popup items and hides properly."""
684- header = self.main_view.get_header()
685- header.click_action_button('textkeysaction')
686-
687- panelScrl = lambda: self.main_view.get_scroll_panel().visible
688- self.assertThat(panelScrl, Eventually(Equals(True)))
689- self.hide_panels()
690- self.assertThat(panelScrl, Eventually(Equals(False)))
691-
692- def test_circle_menu_shows(self):
693- """Make sure that Circle Menu is visible
694- on long tap"""
695- kterm = self.main_view.get_terminal_page()
696- x, y, w, h = kterm.globalRect
697- tap_x = (x + w) / 2
698- tap_y = (y + h) / 3
699-
700- # tap in the top third of the screen, to avoid OSK
701- self.pointing_device.move(tap_x, tap_y)
702- self.pointing_device.press()
703- # we can hold the press for a long time without issue
704- # so we'll ensure the app recieves our signal when under load
705- sleep(4)
706- self.pointing_device.release()
707-
708- menu = self.main_view.get_circle_menu()
709- self.assertThat(menu.visible, Eventually(Equals(True)))
710-
711- def test_header(self):
712- """Make sure that Header is visible
713- in Portrait Mode and not visible in landscape mode"""
714- header = lambda: self.main_view.get_header().visible
715- if model() == "Nexus 10" or model() == "Nexus 7":
716- self.assertThat(header, Eventually(Equals(False)))
717- else:
718- self.assertThat(header, Eventually(Equals(True)))
719+ item = container.wait_select_single('Label', text=value)
720+ self.app.pointing_device.click_object(item)
721+ select.currentlyExpanded.wait_for(False)
722+ # waiting for currentlyExpanded is not enough
723+ # some animation is not accounted for and thus we sleep
724+ sleep(1)
725
726 def test_color_scheme_changes(self):
727 """Make sure that color scheme is set correctly"""
728@@ -133,28 +129,29 @@
729
730 colorScheme = self.get_color_scheme_from_storage
731 for scheme in schemeList:
732- self.main_view.get_header().click_action_button('SettingsButton')
733+ header = self.app.main_view.get_header()
734+ header.click_action_button('SettingsButton')
735 self.click_item_selector_item("liSchemes", scheme)
736- self.main_view.go_back()
737+ self.app.main_view.go_back()
738 self.assertThat(colorScheme, Eventually(Equals(scheme)))
739
740 def test_font_size_changes(self):
741 """Make sure that font size is set correctly"""
742- header = self.main_view.get_header()
743+ header = self.app.main_view.get_header()
744 header.click_action_button('SettingsButton')
745
746 font_size = self.get_font_size_from_storage
747
748 # change font size to min
749- self.main_view.drag_horizontal_slider("slFont", 8)
750+ self.app.main_view.drag_horizontal_slider("slFont", 8)
751 self.assertThat(font_size, Eventually(Equals(8)))
752
753 # change font size to max
754- self.main_view.drag_horizontal_slider("slFont", 32)
755+ self.app.main_view.drag_horizontal_slider("slFont", 32)
756 self.assertThat(font_size, Eventually(Equals(32)))
757
758 # change font size to random sizes
759 for loop in range(1, 3):
760 randSize = random.randrange(9, 31, 1)
761- self.main_view.drag_horizontal_slider("slFont", randSize)
762+ self.app.main_view.drag_horizontal_slider("slFont", randSize)
763 self.assertThat(font_size, Eventually(Equals(randSize)))

Subscribers

People subscribed via source and target branches