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
=== modified file 'src/app/qml/Terminal.qml'
--- src/app/qml/Terminal.qml 2014-08-26 13:31:30 +0000
+++ src/app/qml/Terminal.qml 2014-09-02 16:53:27 +0000
@@ -1,7 +1,6 @@
1import QtQuick 2.01import QtQuick 2.0
2import Ubuntu.Components 0.12import Ubuntu.Components 0.1
3import org.kde.konsole 0.13import org.kde.konsole 0.1
4import Ubuntu.Unity.Action 1.0 as UnityActions
5import "config"4import "config"
6import "extraPanel"5import "extraPanel"
76
@@ -368,65 +367,4 @@
368 }367 }
369368
370 }369 }
371
372 UnityActions.ActionContext {
373 id: actionContext
374 active: mparent.visible
375 actions: [
376 UnityActions.Action {
377 text: i18n.tr("Upload Crash Reports")
378 keywords: i18n.tr("Whoopsie;Apport;Debugging;Bugs")
379 onTriggered: ksession.sendText("\x03\n/usr/share/apport/whoopsie-upload-all\n")
380 },
381 UnityActions.Action {
382 text: i18n.tr("Make Image Writable")
383 keywords: i18n.tr("System Image;Install Deb")
384 onTriggered: ksession.sendText("\x03\nsudo touch /userdata/.writable_image\n")
385 },
386 UnityActions.Action {
387 text: i18n.tr("List Running Applications")
388 keywords: i18n.tr("Apps")
389 onTriggered: ksession.sendText("\x03\nupstart-app-list\n")
390 },
391 UnityActions.Action {
392 text: i18n.tr("Installed Click Packages")
393 keywords: i18n.tr("Packages;Applications;Utilities")
394 onTriggered: ksession.sendText("\x03\nclick list\n")
395 },
396 UnityActions.Action {
397 text: i18n.tr("System Image Information")
398 keywords: i18n.tr("Image;Version;Channel")
399 onTriggered: ksession.sendText("\x03\nsudo system-image-cli -i\n")
400 },
401 UnityActions.Action {
402 text: i18n.tr("System Kernel Version")
403 onTriggered: ksession.sendText("\x03\nuname -a\n")
404 },
405 UnityActions.Action {
406 text: i18n.tr("Upstart Job Status")
407 keywords: i18n.tr("Init;Session;User Job")
408 onTriggered: ksession.sendText("\x03\ninitctl list | sort\n")
409 },
410 UnityActions.Action {
411 text: i18n.tr("Hack into the NSA")
412 keywords: i18n.tr("Government;Secret;Cracking")
413 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")
414 },
415 UnityActions.Action {
416 text: i18n.tr("Watch Running Processes")
417 keywords: i18n.tr("Top;Memory;Usage")
418 onTriggered: ksession.sendText("\x03\ntop\n")
419 },
420 UnityActions.Action {
421 text: i18n.tr("Networking Status")
422 keywords: i18n.tr("Wireless;Ethernet;Access Points")
423 onTriggered: ksession.sendText("\x03\nnm-tool\n")
424 },
425 UnityActions.Action {
426 text: i18n.tr("Watch Star Wars Episode IV")
427 keywords: i18n.tr("Death Star;Skywalker;Leia;Darth Vader")
428 onTriggered: ksession.sendText("\x03\nnetcat -v towel.blinkenlights.nl 23\n")
429 }
430 ]
431 }
432}370}
433371
=== modified file 'tests/autopilot/ubuntu_terminal_app/__init__.py'
--- tests/autopilot/ubuntu_terminal_app/__init__.py 2013-05-31 13:10:55 +0000
+++ tests/autopilot/ubuntu_terminal_app/__init__.py 2014-09-02 16:53:27 +0000
@@ -1,8 +1,174 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013 Canonical2#
3#3# Copyright (C) 2013 Canonical Ltd.
4# This program is free software: you can redistribute it and/or modify it4#
5# under the terms of the GNU General Public License version 3, as published5# This program is free software; you can redistribute it and/or modify
6# by the Free Software Foundation.6# it under the terms of the GNU Lesser General Public License as published by
77# the Free Software Foundation; version 3.
8"""terminal-app tests and emulators - top level package."""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 Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""Terminal app autopilot helpers."""
18
19from time import sleep
20import sqlite3
21import os.path
22import ubuntuuitoolkit
23
24
25class TerminalApp(object):
26
27 """Autopilot helper object for the terminal application."""
28
29 def __init__(self, app_proxy):
30 self.app = app_proxy
31 self.main_view = self.app.select_single(MainView)
32
33 @property
34 def pointing_device(self):
35 return self.app.pointing_device
36
37
38class MainView(ubuntuuitoolkit.MainView):
39
40 """Autopilot custom proxy object for the MainView."""
41
42 def __init__(self, *args):
43 super(MainView, self).__init__(*args)
44 self.visible.wait_for(True)
45
46 def get_slider_item(self, slider):
47 return self.wait_select_single("Slider", objectName=slider)
48
49 def get_control_panel(self):
50 return self.wait_select_single("CtrlKeys", objectName="kbCtrl")
51
52 def get_function_panel(self):
53 return self.wait_select_single("FnKeys", objectName="kbFn")
54
55 def get_text_panel(self):
56 return self.wait_select_single("ScrlKeys", objectName="kbScrl")
57
58 def get_terminal_page(self):
59 return self.wait_select_single("Terminal", objectName="pgTerm")
60
61 def get_circle_menu(self):
62 return self.wait_select_single("CircleMenu", objectName="cmenu")
63
64 def long_tap_terminal_center(self):
65 x, y, w, h = self.globalRect
66 tap_x = (x + w) / 2
67 tap_y = (y + h) / 3
68
69 # tap in the top third of the screen, to avoid OSK
70 self.pointing_device.move(tap_x, tap_y)
71 self.pointing_device.press()
72 # we can hold the press for a long time without issue
73 # so we'll ensure the app recieves our signal when under load
74 sleep(4)
75 self.pointing_device.release()
76
77 def drag_horizontal_slider(self, slider, pos):
78 """Drag slider until value is set"""
79 slItem = self.get_slider_item(slider)
80
81 slRect = slItem.select_single("SliderStyle")
82
83 slideMin = int(slItem.minimumValue)
84 slideMax = int(slItem.maximumValue)
85
86 if pos > slideMax:
87 raise ValueError("Pos cannot be greater than" + str(slideMax))
88
89 if pos < slideMin:
90 raise ValueError("Pos cannot be less than" + str(slideMin))
91
92 x, y, w, h = slRect.globalRect
93 # calculate the approximate slide step width
94 # we take half of the theoretical step value just to make
95 # sure we don't miss any values
96 step = w / ((slideMax - slideMin) * 2)
97 sx = x + step
98 sy = y + h / 2
99 loop = 1
100
101 # set the slider to minimum value and loop
102 self.pointing_device.move(sx, sy)
103 self.pointing_device.click()
104
105 # drag through the slider until the pos matches our desired value
106 # in case of bad sliding, loop will also timeout
107 while round(slItem.value) != pos and slItem.value < slideMax \
108 and loop <= (slideMax * 2):
109 valuePos = int(sx + step)
110 self.pointing_device.drag(sx, sy, valuePos, sy)
111 sx = valuePos
112 sleep(1)
113 loop = loop + 1
114
115
116class DbMan(object):
117
118 """
119 Helper functions for dealing with sqlite databases
120 """
121
122 def get_db(self):
123 dbs_path = os.path.expanduser(
124 "~/.local/share/com.ubuntu.terminal/Databases")
125 if not os.path.exists(dbs_path):
126 return None
127
128 files = [f for f in os.listdir(dbs_path)
129 if os.path.splitext(f)[1] == ".ini"]
130 for f in files:
131 ini_path = os.path.join(dbs_path, f)
132 with open(ini_path) as ini:
133 for line in ini:
134 if "=" in line:
135 key, val = line.strip().split("=")
136 if key == "Name" and val == "UbuntuTerminalDB":
137 try:
138 return ini_path.replace(".ini", ".sqlite")
139 except OSError:
140 pass
141 return None
142
143 def clean_db(self):
144 path = self.get_db()
145 if path is None:
146 self.assertNotEquals(path, None)
147 try:
148 os.remove(path)
149 except OSError:
150 pass
151
152 def get_font_size_from_storage(self):
153 db = self.get_db()
154 conn = sqlite3.connect(db)
155
156 with conn:
157 cur = conn.cursor()
158 cur.execute("SELECT value FROM config WHERE item='fontSize'")
159 row = cur.fetchone()
160 if row is None:
161 self.assertNotEquals(row, None)
162 return int(row[0])
163
164 def get_color_scheme_from_storage(self):
165 db = self.get_db()
166 conn = sqlite3.connect(db)
167
168 with conn:
169 cur = conn.cursor()
170 cur.execute("SELECT value FROM config WHERE item='colorScheme'")
171 row = cur.fetchone()
172 if row is None:
173 self.assertNotEquals(row, None)
174 return row[0]
9175
=== removed file 'tests/autopilot/ubuntu_terminal_app/emulators.py'
--- tests/autopilot/ubuntu_terminal_app/emulators.py 2014-08-28 16:47:48 +0000
+++ tests/autopilot/ubuntu_terminal_app/emulators.py 1970-01-01 00:00:00 +0000
@@ -1,81 +0,0 @@
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 Lesser General Public License as published by
7# the Free Software Foundation; version 3.
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 Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""Terminal app autopilot emulators."""
18
19from time import sleep
20from ubuntuuitoolkit import emulators as toolkit_emulators
21
22
23class MainView(toolkit_emulators.MainView):
24
25 """Terminal MainView Autopilot emulator."""
26
27 def get_slider_item(self, slider):
28 return self.wait_select_single("Slider", objectName=slider)
29
30 def get_control_panel(self):
31 return self.wait_select_single("CtrlKeys", objectName="kbCtrl")
32
33 def get_function_panel(self):
34 return self.wait_select_single("FnKeys", objectName="kbFn")
35
36 def get_scroll_panel(self):
37 return self.wait_select_single("ScrlKeys", objectName="kbScrl")
38
39 def get_terminal_page(self):
40 return self.wait_select_single("Terminal", objectName="pgTerm")
41
42 def get_circle_menu(self):
43 return self.wait_select_single("CircleMenu", objectName="cmenu")
44
45 def drag_horizontal_slider(self, slider, pos):
46 """Drag slider until value is set"""
47 slItem = self.get_slider_item(slider)
48
49 slRect = slItem.select_single("SliderStyle")
50
51 slideMin = int(slItem.minimumValue)
52 slideMax = int(slItem.maximumValue)
53
54 if pos > slideMax:
55 raise ValueError("Pos cannot be greater than" + str(slideMax))
56
57 if pos < slideMin:
58 raise ValueError("Pos cannot be less than" + str(slideMin))
59
60 x, y, w, h = slRect.globalRect
61 # calculate the approximate slide step width
62 # we take half of the theoretical step value just to make
63 # sure we don't miss any values
64 step = w / ((slideMax - slideMin) * 2)
65 sx = x + step
66 sy = y + h / 2
67 loop = 1
68
69 # set the slider to minimum value and loop
70 self.pointing_device.move(sx, sy)
71 self.pointing_device.click()
72
73 # drag through the slider until the pos matches our desired value
74 # in case of bad sliding, loop will also timeout
75 while round(slItem.value) != pos and slItem.value < slideMax \
76 and loop <= (slideMax * 2):
77 valuePos = int(sx + step)
78 self.pointing_device.drag(sx, sy, valuePos, sy)
79 sx = valuePos
80 sleep(0.3)
81 loop = loop + 1
820
=== modified file 'tests/autopilot/ubuntu_terminal_app/tests/__init__.py'
--- tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2014-06-27 15:14:32 +0000
+++ tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2014-09-02 16:53:27 +0000
@@ -7,16 +7,16 @@
77
8"""Terminal app autopilot tests."""8"""Terminal app autopilot tests."""
99
10import sqlite3
11import os.path10import os.path
12
13import fixtures11import fixtures
14from autopilot.input import Mouse, Touch, Pointer12import logging
15from autopilot.platform import model13from autopilot import logging as autopilot_logging
16from autopilot.testcase import AutopilotTestCase14from autopilot.testcase import AutopilotTestCase
17from ubuntuuitoolkit import emulators as toolkit_emulators15import ubuntuuitoolkit
1816
19from ubuntu_terminal_app import emulators17import ubuntu_terminal_app
18
19logger = logging.getLogger(__name__)
2020
2121
22class TerminalTestCase(AutopilotTestCase):22class TerminalTestCase(AutopilotTestCase):
@@ -25,120 +25,51 @@
25 app.25 app.
2626
27 """27 """
28 if model() == 'Desktop':28
29 scenarios = [('with mouse', dict(input_device_class=Mouse))]29 binary = 'terminal'
30 else:30 source_dir = os.path.dirname(os.path.dirname(os.path.abspath('.')))
31 scenarios = [('with touch', dict(input_device_class=Touch))]31 local_location_binary = os.path.join(source_dir, 'src', 'app', binary)
32 installed_location_binary = os.path.join('/usr/bin/', binary)
33 installed_location_qml = '/usr/share/terminal/qml/ubuntu-terminal-app.qml'
3234
33 def setUp(self):35 def setUp(self):
34 self.pointing_device = Pointer(self.input_device_class.create())
35 super(TerminalTestCase, self).setUp()36 super(TerminalTestCase, self).setUp()
3637 launcher_method, _ = self.get_launcher_method_and_type()
37 self.EXEC = 'terminal'38 self.app = ubuntu_terminal_app.TerminalApp(launcher_method())
38 self.source_dir = os.path.dirname(39
39 os.path.dirname(os.path.abspath('.')))40 def get_launcher_method_and_type(self):
40 self.build_dir = self._get_build_dir()
41 self.local_location_binary = os.path.join(self.build_dir,
42 'src', 'app', self.EXEC)
43 self.installed_location_binary = os.path.join('/usr/bin/', self.EXEC)
44 self.installed_location_qml = \
45 '/usr/share/terminal/qml/ubuntu-terminal-app.qml'
46
47 if os.path.exists(self.local_location_binary):41 if os.path.exists(self.local_location_binary):
48 self.launch_test_local()42 launcher = self.launch_test_local
43 test_type = 'local'
49 elif os.path.exists(self.installed_location_binary):44 elif os.path.exists(self.installed_location_binary):
50 self.launch_test_installed()45 launcher = self.launch_test_installed
46 test_type = 'deb'
51 else:47 else:
52 self.launch_test_click()48 launcher = self.launch_test_click
5349 test_type = 'click'
54 def _get_build_dir(self):50 return launcher, test_type
55 build_dir = self.source_dir51
5652 @autopilot_logging.log_action(logger.info)
57 return build_dir
58
59 def launch_test_local(self):53 def launch_test_local(self):
60 self.useFixture(fixtures.EnvironmentVariable(54 self.useFixture(fixtures.EnvironmentVariable(
61 'QML2_IMPORT_PATH', newvalue=os.path.join(self.build_dir,55 'QML2_IMPORT_PATH', newvalue=os.path.join(self.source_dir,
62 'src', 'plugin')))56 'src', 'plugin')))
6357
64 self.app = self.launch_test_application(58 return self.launch_test_application(
65 self.local_location_binary,59 self.local_location_binary,
66 app_type='qt',60 app_type='qt',
67 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)61 emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
6862
63 @autopilot_logging.log_action(logger.info)
69 def launch_test_installed(self):64 def launch_test_installed(self):
70 self.app = self.launch_test_application(65 return self.launch_test_application(
71 self.installed_location_binary,66 self.installed_location_binary,
72 '-q', self.installed_location_qml,67 '-q', self.installed_location_qml,
73 app_type='qt',68 app_type='qt',
74 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)69 emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
7570
71 @autopilot_logging.log_action(logger.info)
76 def launch_test_click(self):72 def launch_test_click(self):
77 self.app = self.launch_click_package(73 return self.launch_click_package(
78 "com.ubuntu.terminal",74 "com.ubuntu.terminal",
79 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)75 emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
80
81 @property
82 def main_view(self):
83 return self.app.select_single(emulators.MainView)
84
85
86class DbMan(object):
87
88 """
89 Helper functions for dealing with sqlite databases
90 """
91
92 def get_db(self):
93 dbs_path = os.path.expanduser(
94 "~/.local/share/com.ubuntu.terminal/Databases")
95 if not os.path.exists(dbs_path):
96 return None
97
98 files = [f for f in os.listdir(dbs_path)
99 if os.path.splitext(f)[1] == ".ini"]
100 for f in files:
101 ini_path = os.path.join(dbs_path, f)
102 with open(ini_path) as ini:
103 for line in ini:
104 if "=" in line:
105 key, val = line.strip().split("=")
106 if key == "Name" and val == "UbuntuTerminalDB":
107 try:
108 return ini_path.replace(".ini", ".sqlite")
109 except OSError:
110 pass
111 return None
112
113 def clean_db(self):
114 path = self.get_db()
115 if path is None:
116 self.assertNotEquals(path, None)
117 try:
118 os.remove(path)
119 except OSError:
120 pass
121
122 def get_font_size_from_storage(self):
123 db = self.get_db()
124 conn = sqlite3.connect(db)
125
126 with conn:
127 cur = conn.cursor()
128 cur.execute("SELECT value FROM config WHERE item='fontSize'")
129 row = cur.fetchone()
130 if row is None:
131 self.assertNotEquals(row, None)
132 return int(row[0])
133
134 def get_color_scheme_from_storage(self):
135 db = self.get_db()
136 conn = sqlite3.connect(db)
137
138 with conn:
139 cur = conn.cursor()
140 cur.execute("SELECT value FROM config WHERE item='colorScheme'")
141 row = cur.fetchone()
142 if row is None:
143 self.assertNotEquals(row, None)
144 return row[0]
14576
=== modified file 'tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py'
--- tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2014-08-28 16:18:16 +0000
+++ tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2014-09-02 16:53:27 +0000
@@ -11,112 +11,108 @@
1111
12from autopilot.matchers import Eventually12from autopilot.matchers import Eventually
13from testtools.matchers import Equals13from testtools.matchers import Equals
14from autopilot.platform import model
1514
16from ubuntu_terminal_app.tests import TerminalTestCase, DbMan15from ubuntu_terminal_app.tests import TerminalTestCase
17from ubuntuuitoolkit import ToolkitException as ToolkitException16from ubuntu_terminal_app import DbMan
17from ubuntuuitoolkit import ToolkitException
18from testscenarios import TestWithScenarios
1819
19from time import sleep20from time import sleep
20import random21import random
2122
2223
23class TestMainWindow(TerminalTestCase, DbMan):24class TestMainWindow(TerminalTestCase):
2425
25 def setUp(self):26 def test_circle_menu_shows(self):
26 super(TestMainWindow, self).setUp()27 """Make sure that Circle Menu is visible
27 self.assertThat(28 on long tap"""
28 self.main_view.visible, Eventually(Equals(True)))29 self.app.main_view.long_tap_terminal_center()
2930 menu = self.app.main_view.get_circle_menu()
30 def hide_panels(self):31 self.assertThat(menu.visible, Eventually(Equals(True)))
31 """Click hide panels button"""32
32 header = self.main_view.get_header()33 def test_header(self):
33 header.click_action_button('hidepanelaction')34 """Make sure that Header is visible
34 # Click on the button a second time in case that the35 in Portrait Mode and not visible in landscape mode"""
35 # actions list was open and the first click just closed it36 kterm = self.app.main_view.get_terminal_page()
36 # without further effect. If that was not the case, then37 header = self.app.main_view.get_header()
37 # be prepared to catch the exception, as once clicked on,38 if kterm.width > kterm.height:
38 # the action to hide panels makes the button no longer visible39 self.assertThat(header.visible, Equals(False))
40 else:
41 self.assertThat(header.visible, Equals(True))
42
43
44class TestPanel(TerminalTestCase, TestWithScenarios):
45
46 scenarios = [
47 ('controlpanel',
48 {'button': 'controlkeysaction',
49 'helper_method': 'get_control_panel'
50 }),
51
52 ('functionpanel',
53 {'button': 'functionkeysaction',
54 'helper_method': 'get_function_panel'
55 }),
56
57 ('textpanel',
58 {'button': 'textkeysaction',
59 'helper_method': 'get_text_panel'
60 })
61 ]
62
63 def open_panel(self, button, helper_method):
64 """Open named panel"""
65 header = self.app.main_view.get_header()
66 header.click_action_button(button)
67 get_panel = getattr(self.app.main_view, helper_method)
68 return get_panel()
69
70 def hide_panel(self):
71 """Close any open panel"""
72 header = self.app.main_view.get_header()
73
74 # the overflow panel can be left open, so we need to try again
75 # https://bugs.launchpad.net/ubuntu-terminal-app/+bug/1363233
39 try:76 try:
40 header.click_action_button('hidepanelaction')77 header.click_action_button('hidepanelaction')
78 try:
79 sleep(2)
80 header.click_action_button('hidepanelaction')
81 except ToolkitException:
82 pass
41 except ToolkitException:83 except ToolkitException:
42 pass84 pass
4385
86 def test_panels(self):
87 """Make sure that Panel is visible
88 when clicking the toolbar popup items and hides properly."""
89 panel = self.open_panel(self.button, self.helper_method)
90 self.assertThat(panel.visible, Eventually(Equals(True)))
91 self.hide_panel()
92 self.assertThat(panel.visible, Eventually(Equals(False)))
93
94
95class TestSettings(TerminalTestCase, DbMan):
96
44 def click_item_selector_item(self, selector, value):97 def click_item_selector_item(self, selector, value):
45 """Clicks item from item selector"""98 """Clicks item from item selector"""
46 # This needs a toolkit helper99 # This needs a toolkit helper
47 # https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1272345100 # https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1272345
48 item_selector = self.main_view.wait_select_single('ItemSelector',101 select = self.app.main_view.wait_select_single('ItemSelector',
49 objectName=selector)102 objectName=selector)
50 selector = item_selector.wait_select_single('Standard',103 container = select.wait_select_single('Standard',
51 objectName='listContainer')104 objectName='listContainer')
52 self.pointing_device.click_object(selector)105 self.app.pointing_device.click_object(container)
53 item_selector.currentlyExpanded.wait_for(True)106 select.currentlyExpanded.wait_for(True)
54 # waiting for currentlyExpanded is not enough107 # waiting for currentlyExpanded is not enough
55 # some animation is not accounted for and thus we sleep108 # some animation is not accounted for and thus we sleep
56 sleep(2)109 sleep(2)
57 item = selector.wait_select_single('Label', text=value)110 item = container.wait_select_single('Label', text=value)
58 self.pointing_device.click_object(item)111 self.app.pointing_device.click_object(item)
59112 select.currentlyExpanded.wait_for(False)
60 def test_control_panel(self):113 # waiting for currentlyExpanded is not enough
61 """Make sure that Control Keys Panel is visible114 # some animation is not accounted for and thus we sleep
62 when clicking the toolbar popup items and hides properly."""115 sleep(1)
63 header = self.main_view.get_header()
64 header.click_action_button('controlkeysaction')
65
66 panelCtrl = lambda: self.main_view.get_control_panel().visible
67 self.assertThat(panelCtrl, Eventually(Equals(True)))
68 self.hide_panels()
69 self.assertThat(panelCtrl, Eventually(Equals(False)))
70
71 def test_function_panel(self):
72 """Make sure that function Keys Panel is visible
73 when clicking the toolbar popup items and hides properly."""
74 header = self.main_view.get_header()
75 header.click_action_button('functionkeysaction')
76
77 panelFunc = lambda: self.main_view.get_function_panel().visible
78 self.assertThat(panelFunc, Eventually(Equals(True)))
79 self.hide_panels()
80 self.assertThat(panelFunc, Eventually(Equals(False)))
81
82 def test_textctrl_panel(self):
83 """Make sure that Text Control Keys Panel is visible
84 when clicking the toolbar popup items and hides properly."""
85 header = self.main_view.get_header()
86 header.click_action_button('textkeysaction')
87
88 panelScrl = lambda: self.main_view.get_scroll_panel().visible
89 self.assertThat(panelScrl, Eventually(Equals(True)))
90 self.hide_panels()
91 self.assertThat(panelScrl, Eventually(Equals(False)))
92
93 def test_circle_menu_shows(self):
94 """Make sure that Circle Menu is visible
95 on long tap"""
96 kterm = self.main_view.get_terminal_page()
97 x, y, w, h = kterm.globalRect
98 tap_x = (x + w) / 2
99 tap_y = (y + h) / 3
100
101 # tap in the top third of the screen, to avoid OSK
102 self.pointing_device.move(tap_x, tap_y)
103 self.pointing_device.press()
104 # we can hold the press for a long time without issue
105 # so we'll ensure the app recieves our signal when under load
106 sleep(4)
107 self.pointing_device.release()
108
109 menu = self.main_view.get_circle_menu()
110 self.assertThat(menu.visible, Eventually(Equals(True)))
111
112 def test_header(self):
113 """Make sure that Header is visible
114 in Portrait Mode and not visible in landscape mode"""
115 header = lambda: self.main_view.get_header().visible
116 if model() == "Nexus 10" or model() == "Nexus 7":
117 self.assertThat(header, Eventually(Equals(False)))
118 else:
119 self.assertThat(header, Eventually(Equals(True)))
120116
121 def test_color_scheme_changes(self):117 def test_color_scheme_changes(self):
122 """Make sure that color scheme is set correctly"""118 """Make sure that color scheme is set correctly"""
@@ -133,28 +129,29 @@
133129
134 colorScheme = self.get_color_scheme_from_storage130 colorScheme = self.get_color_scheme_from_storage
135 for scheme in schemeList:131 for scheme in schemeList:
136 self.main_view.get_header().click_action_button('SettingsButton')132 header = self.app.main_view.get_header()
133 header.click_action_button('SettingsButton')
137 self.click_item_selector_item("liSchemes", scheme)134 self.click_item_selector_item("liSchemes", scheme)
138 self.main_view.go_back()135 self.app.main_view.go_back()
139 self.assertThat(colorScheme, Eventually(Equals(scheme)))136 self.assertThat(colorScheme, Eventually(Equals(scheme)))
140137
141 def test_font_size_changes(self):138 def test_font_size_changes(self):
142 """Make sure that font size is set correctly"""139 """Make sure that font size is set correctly"""
143 header = self.main_view.get_header()140 header = self.app.main_view.get_header()
144 header.click_action_button('SettingsButton')141 header.click_action_button('SettingsButton')
145142
146 font_size = self.get_font_size_from_storage143 font_size = self.get_font_size_from_storage
147144
148 # change font size to min145 # change font size to min
149 self.main_view.drag_horizontal_slider("slFont", 8)146 self.app.main_view.drag_horizontal_slider("slFont", 8)
150 self.assertThat(font_size, Eventually(Equals(8)))147 self.assertThat(font_size, Eventually(Equals(8)))
151148
152 # change font size to max149 # change font size to max
153 self.main_view.drag_horizontal_slider("slFont", 32)150 self.app.main_view.drag_horizontal_slider("slFont", 32)
154 self.assertThat(font_size, Eventually(Equals(32)))151 self.assertThat(font_size, Eventually(Equals(32)))
155152
156 # change font size to random sizes153 # change font size to random sizes
157 for loop in range(1, 3):154 for loop in range(1, 3):
158 randSize = random.randrange(9, 31, 1)155 randSize = random.randrange(9, 31, 1)
159 self.main_view.drag_horizontal_slider("slFont", randSize)156 self.app.main_view.drag_horizontal_slider("slFont", randSize)
160 self.assertThat(font_size, Eventually(Equals(randSize)))157 self.assertThat(font_size, Eventually(Equals(randSize)))

Subscribers

People subscribed via source and target branches