ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #08651
[Merge] lp:~nskaggs/ubuntu-terminal-app/restore-autopilot into lp:ubuntu-terminal-app
Nicholas Skaggs has proposed merging lp:~nskaggs/ubuntu-terminal-app/restore-autopilot into lp:ubuntu-terminal-app.
Commit message:
Add back templates for autopilot
add autopilot readme
Requested reviews:
Ubuntu Terminal Developers (ubuntu-terminal-dev)
For more details, see:
https://code.launchpad.net/~nskaggs/ubuntu-terminal-app/restore-autopilot/+merge/288347
Add back templates for autopilot
add autopilot readme
--
Your team Ubuntu Terminal Developers is requested to review the proposed merge of lp:~nskaggs/ubuntu-terminal-app/restore-autopilot into lp:ubuntu-terminal-app.
=== added file 'README.autopilot.md'
--- README.autopilot.md 1970-01-01 00:00:00 +0000
+++ README.autopilot.md 2016-03-07 21:17:09 +0000
@@ -0,0 +1,74 @@
+Running Autopilot tests
+=======================
+If you are looking for more info about Autopilot or writing AP tests, here are some useful links to help you:
+
+- [Ubuntu - Quality](http://developer.ubuntu.com/start/quality)
+- [Autopilot - Python](https://developer.ubuntu.com/api/autopilot/python/1.5.0/)
+
+For help and options on running tests, see:
+
+- [Autopilot tests](https://developer.ubuntu.com/en/start/platform/guides/running-autopilot-tests/)
+
+Prerequisites
+=============
+
+Install the following autopilot packages required to run the tests,
+
+ $ sudo apt-get install python3-autopilot libautopilot-qt ubuntu-ui-toolkit-autopilot python3-autopilot-vis
+
+Running tests on the desktop
+============================
+
+Using terminal:
+
+* Branch the Music app code, for example,
+
+ $ bzr branch lp:ubuntu-terminal-app
+
+* Navigate to the tests/autopilot directory.
+
+ $ cd tests/autopilot
+
+* run all tests.
+
+ $ autopilot3 run -vv ubuntu_terminal_app
+
+* to list all tests:
+
+ $ autopilot3 list ubuntu_terminal_app
+
+ To run only one test
+
+ $ autopilot3 run -vv ubuntu_terminal_app.tests.test_name
+
+* Debugging tests using autopilot vis
+
+ $ autopilot3 launch -i Qt qmlscene src/app/terminal
+
+ $ autopilot3 vis
+
+Running tests using Ubuntu SDK
+==============================
+
+Refer this [tutorial](https://developer.ubuntu.com/en/start/platform/guides/running-autopilot-tests/) to run tests on Ubuntu SDK:
+
+Running tests on device or emulator:
+====================================
+
+Using autopkg:
+
+* Branch the Music app code, for example,
+
+ $ bzr branch lp:ubuntu-terminal-app
+
+* Navigate to the source directory.
+
+ $ cd ubuntu-terminal-app
+
+* Build a click package
+
+ $ click-buddy .
+
+* Run the tests on device (assumes only one click package in the directory)
+
+ $ adt-run . *.click --- ssh -s adb -- -p <PASSWORD>
\ No newline at end of file
=== removed directory 'old-tests'
=== removed file 'old-tests/CMakeLists.txt'
--- old-tests/CMakeLists.txt 2014-10-25 04:42:31 +0000
+++ old-tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-add_subdirectory(autopilot)
=== removed directory 'old-tests/autopilot'
=== removed file 'old-tests/autopilot/CMakeLists.txt'
--- old-tests/autopilot/CMakeLists.txt 2014-10-25 04:42:31 +0000
+++ old-tests/autopilot/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
-if(INSTALL_TESTS)
-execute_process(COMMAND python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
- OUTPUT_VARIABLE PYTHON_PACKAGE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-install(DIRECTORY ${AUTOPILOT_DIR}
- DESTINATION ${PYTHON_PACKAGE_DIR}
- )
-endif(INSTALL_TESTS)
=== removed directory 'old-tests/autopilot/ubuntu_terminal_app'
=== removed file 'old-tests/autopilot/ubuntu_terminal_app/__init__.py'
--- old-tests/autopilot/ubuntu_terminal_app/__init__.py 2014-10-25 04:42:31 +0000
+++ old-tests/autopilot/ubuntu_terminal_app/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,174 +0,0 @@
-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
-#
-# Copyright (C) 2013 Canonical Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation; version 3.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-"""Terminal app autopilot helpers."""
-
-from time import sleep
-import sqlite3
-import os.path
-import ubuntuuitoolkit
-
-
-class TerminalApp(object):
-
- """Autopilot helper object for the terminal application."""
-
- def __init__(self, app_proxy):
- self.app = app_proxy
- self.main_view = self.app.select_single(MainView)
-
- @property
- def pointing_device(self):
- return self.app.pointing_device
-
-
-class MainView(ubuntuuitoolkit.MainView):
-
- """Autopilot custom proxy object for the MainView."""
-
- def __init__(self, *args):
- super(MainView, self).__init__(*args)
- self.visible.wait_for(True)
-
- def get_slider_item(self, slider):
- return self.wait_select_single("Slider", objectName=slider)
-
- def get_control_panel(self):
- return self.wait_select_single("CtrlKeys", objectName="kbCtrl")
-
- def get_function_panel(self):
- return self.wait_select_single("FnKeys", objectName="kbFn")
-
- def get_text_panel(self):
- return self.wait_select_single("ScrlKeys", objectName="kbScrl")
-
- def get_terminal_page(self):
- return self.wait_select_single("Terminal", objectName="pgTerm")
-
- def get_circle_menu(self):
- return self.wait_select_single("CircleMenu", objectName="cmenu")
-
- def long_tap_terminal_center(self):
- x, y, w, h = self.globalRect
- tap_x = (x + w) / 2
- tap_y = (y + h) / 3
-
- # tap in the top third of the screen, to avoid OSK
- self.pointing_device.move(tap_x, tap_y)
- self.pointing_device.press()
- # we can hold the press for a long time without issue
- # so we'll ensure the app recieves our signal when under load
- sleep(4)
- self.pointing_device.release()
-
- def drag_horizontal_slider(self, slider, pos):
- """Drag slider until value is set"""
- slItem = self.get_slider_item(slider)
-
- slRect = slItem.select_single("SliderStyle")
-
- slideMin = int(slItem.minimumValue)
- slideMax = int(slItem.maximumValue)
-
- if pos > slideMax:
- raise ValueError("Pos cannot be greater than" + str(slideMax))
-
- if pos < slideMin:
- raise ValueError("Pos cannot be less than" + str(slideMin))
-
- x, y, w, h = slRect.globalRect
- # calculate the approximate slide step width
- # we take half of the theoretical step value just to make
- # sure we don't miss any values
- step = w / ((slideMax - slideMin) * 2)
- sx = x + step
- sy = y + h / 2
- loop = 1
-
- # set the slider to minimum value and loop
- self.pointing_device.move(sx, sy)
- self.pointing_device.click()
-
- # drag through the slider until the pos matches our desired value
- # in case of bad sliding, loop will also timeout
- while round(slItem.value) != pos and slItem.value < slideMax \
- and loop <= (slideMax * 2):
- valuePos = int(sx + step)
- self.pointing_device.drag(sx, sy, valuePos, sy)
- sx = valuePos
- sleep(1)
- loop = loop + 1
-
-
-class DbMan(object):
-
- """
- Helper functions for dealing with sqlite databases
- """
-
- def get_db(self):
- dbs_path = os.path.expanduser(
- "~/.local/share/com.ubuntu.terminal/Databases")
- if not os.path.exists(dbs_path):
- return None
-
- files = [f for f in os.listdir(dbs_path)
- if os.path.splitext(f)[1] == ".ini"]
- for f in files:
- ini_path = os.path.join(dbs_path, f)
- with open(ini_path) as ini:
- for line in ini:
- if "=" in line:
- key, val = line.strip().split("=")
- if key == "Name" and val == "UbuntuTerminalDB":
- try:
- return ini_path.replace(".ini", ".sqlite")
- except OSError:
- pass
- return None
-
- def clean_db(self):
- path = self.get_db()
- if path is None:
- self.assertNotEquals(path, None)
- try:
- os.remove(path)
- except OSError:
- pass
-
- def get_font_size_from_storage(self):
- db = self.get_db()
- conn = sqlite3.connect(db)
-
- with conn:
- cur = conn.cursor()
- cur.execute("SELECT value FROM config WHERE item='fontSize'")
- row = cur.fetchone()
- if row is None:
- self.assertNotEquals(row, None)
- return int(row[0])
-
- def get_color_scheme_from_storage(self):
- db = self.get_db()
- conn = sqlite3.connect(db)
-
- with conn:
- cur = conn.cursor()
- cur.execute("SELECT value FROM config WHERE item='colorScheme'")
- row = cur.fetchone()
- if row is None:
- self.assertNotEquals(row, None)
- return row[0]
=== removed directory 'old-tests/autopilot/ubuntu_terminal_app/tests'
=== removed file 'old-tests/autopilot/ubuntu_terminal_app/tests/__init__.py'
--- old-tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2014-10-25 04:42:31 +0000
+++ old-tests/autopilot/ubuntu_terminal_app/tests/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,131 +0,0 @@
-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
-# Copyright 2013 Canonical
-#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 3, as published
-# by the Free Software Foundation.
-
-"""Terminal app autopilot tests."""
-
-import os.path
-import fixtures
-import logging
-import tempfile
-
-from autopilot import logging as autopilot_logging
-from autopilot.testcase import AutopilotTestCase
-import ubuntuuitoolkit
-
-import ubuntu_terminal_app
-from gi.repository import Click
-
-logger = logging.getLogger(__name__)
-
-
-class TerminalTestCase(AutopilotTestCase):
-
- """A common testcase class that provides useful methods for the terminal
- app.
-
- """
-
- binary = 'terminal'
- source_dir = os.path.dirname(os.path.dirname(os.path.abspath('.')))
- local_location_binary = os.path.join(source_dir, 'src', 'app', binary)
- installed_location_binary = os.path.join('/usr/bin/', binary)
- installed_location_qml = '/usr/share/terminal/qml/ubuntu-terminal-app.qml'
-
- def setUp(self):
- super(TerminalTestCase, self).setUp()
- launcher_method, _ = self.get_launcher_method_and_type()
- self.app = ubuntu_terminal_app.TerminalApp(launcher_method())
-
- def get_launcher_method_and_type(self):
- if os.path.exists(self.local_location_binary):
- launcher = self.launch_test_local
- test_type = 'local'
- elif os.path.exists(self.installed_location_binary):
- launcher = self.launch_test_installed
- test_type = 'deb'
- else:
- launcher = self.launch_test_click
- test_type = 'click'
- return launcher, test_type
-
- @autopilot_logging.log_action(logger.info)
- def launch_test_local(self):
- self.useFixture(fixtures.EnvironmentVariable(
- 'QML2_IMPORT_PATH', newvalue=os.path.join(self.source_dir,
- 'src', 'plugin')))
-
- return self.launch_test_application(
- self.local_location_binary,
- app_type='qt',
- emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
-
- @autopilot_logging.log_action(logger.info)
- def launch_test_installed(self):
- return self.launch_test_application(
- self.installed_location_binary,
- '-q', self.installed_location_qml,
- app_type='qt',
- emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
-
- @autopilot_logging.log_action(logger.info)
- def launch_test_click(self):
- # We need to pass the "--forceAuth false" argument to the terminal app
- # binary, but ubuntu-app-launch doesn't pass arguments to the exec line
- # on the desktop file. So we make a test desktop file that has the
- # "--forceAuth false" on the exec line.
- desktop_file_path = self.write_sandbox_desktop_file()
- desktop_file_name = os.path.basename(desktop_file_path)
- application_name, _ = os.path.splitext(desktop_file_name)
- return self.launch_upstart_application(
- application_name,
- emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
-
- def write_sandbox_desktop_file(self):
- desktop_file_dir = self.get_local_desktop_file_directory()
- desktop_file = self.get_named_temporary_file(
- suffix='.desktop', dir=desktop_file_dir)
- desktop_file.write('[Desktop Entry]\n')
- version, installed_path = self.get_installed_version_and_directory()
- terminal_sandbox_exec = (
- 'aa-exec-click -p com.ubuntu.terminal_terminal_{}'
- ' -- terminal --forceAuth false'.format(version))
- desktop_file_dict = {
- 'Type': 'Application',
- 'Name': 'terminal',
- 'Exec': terminal_sandbox_exec,
- 'Icon': 'Not important',
- 'Path': installed_path
- }
- for key, value in desktop_file_dict.items():
- desktop_file.write('{key}={value}\n'.format(key=key, value=value))
- desktop_file.close()
- logger.debug(terminal_sandbox_exec)
- for key, value in desktop_file_dict.items():
- logger.debug("%s: %s" % (key, value))
- return desktop_file.name
-
- def get_local_desktop_file_directory(self):
- return os.path.join(
- os.path.expanduser('~'), '.local', 'share', 'applications')
-
- def get_named_temporary_file(
- self, dir=None, mode='w+t', delete=False, suffix=''):
- # Discard files with underscores which look like an APP_ID to Unity
- # See https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1329141
- chars = tempfile._RandomNameSequence.characters.strip("_")
- tempfile._RandomNameSequence.characters = chars
- return tempfile.NamedTemporaryFile(
- dir=dir, mode=mode, delete=delete, suffix=suffix)
-
- def get_installed_version_and_directory(self):
- db = Click.DB()
- db.read()
- package_name = 'com.ubuntu.terminal'
- registry = Click.User.for_user(db, name=os.environ.get('USER'))
- version = registry.get_version(package_name)
- directory = registry.get_path(package_name)
- return version, directory
=== removed file 'old-tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py'
--- old-tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2014-10-25 04:42:31 +0000
+++ old-tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 1970-01-01 00:00:00 +0000
@@ -1,157 +0,0 @@
-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
-# Copyright 2013 Canonical
-#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 3, as published
-# by the Free Software Foundation.
-
-"""Terminal app autopilot tests."""
-
-from __future__ import absolute_import
-
-from autopilot.matchers import Eventually
-from testtools.matchers import Equals
-
-from ubuntu_terminal_app.tests import TerminalTestCase
-from ubuntu_terminal_app import DbMan
-from ubuntuuitoolkit import ToolkitException
-from testscenarios import TestWithScenarios
-
-from time import sleep
-import random
-
-
-class TestMainWindow(TerminalTestCase):
-
- def test_circle_menu_shows(self):
- """Make sure that Circle Menu is visible
- on long tap"""
- self.app.main_view.long_tap_terminal_center()
- menu = self.app.main_view.get_circle_menu()
- self.assertThat(menu.visible, Eventually(Equals(True)))
-
- def test_header(self):
- """Make sure that Header is visible
- in Portrait Mode and not visible in landscape mode"""
- kterm = self.app.main_view.get_terminal_page()
- header = self.app.main_view.get_header()
- if kterm.width > kterm.height:
- self.assertThat(header.visible, Equals(False))
- else:
- self.assertThat(header.visible, Equals(True))
-
-
-class TestPanel(TerminalTestCase, TestWithScenarios):
-
- scenarios = [
- ('controlpanel',
- {'button': 'controlkeysaction',
- 'helper_method': 'get_control_panel'
- }),
-
- ('functionpanel',
- {'button': 'functionkeysaction',
- 'helper_method': 'get_function_panel'
- }),
-
- ('textpanel',
- {'button': 'textkeysaction',
- 'helper_method': 'get_text_panel'
- })
- ]
-
- def open_panel(self, button, helper_method):
- """Open named panel"""
- header = self.app.main_view.get_header()
- header.click_action_button(button)
- get_panel = getattr(self.app.main_view, helper_method)
- return get_panel()
-
- def hide_panel(self):
- """Close any open panel"""
- header = self.app.main_view.get_header()
-
- # the overflow panel can be left open, so we need to try again
- # https://bugs.launchpad.net/ubuntu-terminal-app/+bug/1363233
- try:
- header.click_action_button('hidepanelaction')
- try:
- sleep(2)
- header.click_action_button('hidepanelaction')
- except ToolkitException:
- pass
- except ToolkitException:
- pass
-
- def test_panels(self):
- """Make sure that Panel is visible
- when clicking the toolbar popup items and hides properly."""
- panel = self.open_panel(self.button, self.helper_method)
- self.assertThat(panel.visible, Eventually(Equals(True)))
- self.hide_panel()
- self.assertThat(panel.visible, Eventually(Equals(False)))
-
-
-class TestSettings(TerminalTestCase, DbMan):
-
- def click_item_selector_item(self, selector, value):
- """Clicks item from item selector"""
- # This needs a toolkit helper
- # https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1272345
- select = self.app.main_view.wait_select_single('ItemSelector',
- objectName=selector)
- container = select.wait_select_single('Standard',
- objectName='listContainer')
- self.app.pointing_device.click_object(container)
- select.currentlyExpanded.wait_for(True)
- # waiting for currentlyExpanded is not enough
- # some animation is not accounted for and thus we sleep
- sleep(2)
- item = container.wait_select_single('Label', text=value)
- self.app.pointing_device.click_object(item)
- select.currentlyExpanded.wait_for(False)
- # waiting for currentlyExpanded is not enough
- # some animation is not accounted for and thus we sleep
- sleep(1)
-
- def test_color_scheme_changes(self):
- """Make sure that color scheme is set correctly"""
-
- # are these string translatable?
- # if so, we need to do this another way
- schemeList = ("BlackOnRandomLight",
- "BlackOnWhite",
- "BlackOnLightYellow",
- "DarkPastels",
- "GreenOnBlack",
- "Linux",
- "WhiteOnBlack")
-
- colorScheme = self.get_color_scheme_from_storage
- for scheme in schemeList:
- header = self.app.main_view.get_header()
- header.click_action_button('SettingsButton')
- self.click_item_selector_item("liSchemes", scheme)
- self.app.main_view.go_back()
- self.assertThat(colorScheme, Eventually(Equals(scheme)))
-
- def test_font_size_changes(self):
- """Make sure that font size is set correctly"""
- header = self.app.main_view.get_header()
- header.click_action_button('SettingsButton')
-
- font_size = self.get_font_size_from_storage
-
- # change font size to min
- self.app.main_view.drag_horizontal_slider("slFont", 8)
- self.assertThat(font_size, Eventually(Equals(8)))
-
- # change font size to max
- self.app.main_view.drag_horizontal_slider("slFont", 32)
- self.assertThat(font_size, Eventually(Equals(32)))
-
- # change font size to random sizes
- for loop in range(1, 3):
- randSize = random.randrange(9, 31, 1)
- self.app.main_view.drag_horizontal_slider("slFont", randSize)
- self.assertThat(font_size, Eventually(Equals(randSize)))
=== modified file 'po/com.ubuntu.terminal.pot'
--- po/com.ubuntu.terminal.pot 2016-02-07 18:30:11 +0000
+++ po/com.ubuntu.terminal.pot 2016-03-07 21:17:09 +0000
@@ -1,6 +1,6 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Canonical Ltd.
-# This file is distributed under the same license as the PACKAGE package.
+# This file is distributed under the same license as the package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
@@ -8,7 +8,7 @@
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-02-07 19:27+0100\n"
+"POT-Creation-Date: 2016-03-07 16:06-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -25,7 +25,7 @@
msgid "Copy"
msgstr ""
-#: ../src/app/qml/AlternateActionPopover.qml:21
+#: ../src/app/qml/AlternateActionPopover.qml:22
msgid "Paste"
msgstr ""
@@ -37,19 +37,19 @@
msgid "Enter passcode or passphrase:"
msgstr ""
-#: ../src/app/qml/AuthenticationDialog.qml:40
+#: ../src/app/qml/AuthenticationDialog.qml:48
msgid "passcode or passphrase"
msgstr ""
-#: ../src/app/qml/AuthenticationDialog.qml:50
+#: ../src/app/qml/AuthenticationDialog.qml:58
msgid "OK"
msgstr ""
-#: ../src/app/qml/AuthenticationDialog.qml:62
+#: ../src/app/qml/AuthenticationDialog.qml:70
msgid "Cancel"
msgstr ""
-#: ../src/app/qml/AuthenticationService.qml:55
+#: ../src/app/qml/AuthenticationService.qml:58
msgid "Authentication failed"
msgstr ""
@@ -181,44 +181,44 @@
msgid "New tab"
msgstr ""
-#: ../src/app/qml/TerminalPage.qml:170
+#: ../src/app/qml/TerminalPage.qml:179
msgid "Selection Mode"
msgstr ""
#. TRANSLATORS: This is the name of a terminal color scheme which is displayed in the settings
-#: ../src/app/qml/ubuntu-terminal-app.qml:128
+#: ../src/app/qml/ubuntu-terminal-app.qml:126
msgid "Green on black"
msgstr ""
-#: ../src/app/qml/ubuntu-terminal-app.qml:128
+#: ../src/app/qml/ubuntu-terminal-app.qml:126
msgid "White on black"
msgstr ""
-#: ../src/app/qml/ubuntu-terminal-app.qml:128
+#: ../src/app/qml/ubuntu-terminal-app.qml:126
msgid "Black on white"
msgstr ""
-#: ../src/app/qml/ubuntu-terminal-app.qml:128
+#: ../src/app/qml/ubuntu-terminal-app.qml:126
msgid "Black on random light"
msgstr ""
-#: ../src/app/qml/ubuntu-terminal-app.qml:128
+#: ../src/app/qml/ubuntu-terminal-app.qml:126
msgid "Linux"
msgstr ""
-#: ../src/app/qml/ubuntu-terminal-app.qml:128
+#: ../src/app/qml/ubuntu-terminal-app.qml:126
msgid "Cool retro term"
msgstr ""
-#: ../src/app/qml/ubuntu-terminal-app.qml:128
+#: ../src/app/qml/ubuntu-terminal-app.qml:126
msgid "Dark pastels / Ubuntu (old)"
msgstr ""
-#: ../src/app/qml/ubuntu-terminal-app.qml:128
+#: ../src/app/qml/ubuntu-terminal-app.qml:126
msgid "Black on light yellow"
msgstr ""
-#: ../src/app/qml/ubuntu-terminal-app.qml:128
+#: ../src/app/qml/ubuntu-terminal-app.qml:126
msgid "Ubuntu"
msgstr ""
=== modified file 'tests/autopilot/ubuntu_terminal_app/__init__.py'
--- tests/autopilot/ubuntu_terminal_app/__init__.py 2015-02-25 00:09:54 +0000
+++ tests/autopilot/ubuntu_terminal_app/__init__.py 2016-03-07 21:17:09 +0000
@@ -16,4 +16,26 @@
"""Terminal app autopilot helpers."""
-# TODO Insert new tests here
+import ubuntuuitoolkit
+
+
+class TerminalApp(object):
+
+ """Autopilot helper object for the terminal application."""
+
+ def __init__(self, app_proxy):
+ self.app = app_proxy
+ self.main_view = self.app.select_single(MainView)
+
+ @property
+ def pointing_device(self):
+ return self.app.pointing_device
+
+
+class MainView(ubuntuuitoolkit.MainView):
+
+ """Autopilot custom proxy object for the MainView."""
+
+ def __init__(self, *args):
+ super(MainView, self).__init__(*args)
+ self.visible.wait_for(True)
=== modified file 'tests/autopilot/ubuntu_terminal_app/tests/__init__.py'
--- tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2015-02-25 00:09:54 +0000
+++ tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2016-03-07 21:17:09 +0000
@@ -7,4 +7,149 @@
"""Terminal app autopilot tests."""
-# TODO Insert new tests here.
+import os.path
+import fixtures
+import logging
+import tempfile
+import gi
+
+from autopilot import logging as autopilot_logging
+from autopilot.testcase import AutopilotTestCase
+import ubuntuuitoolkit
+
+import ubuntu_terminal_app
+gi.require_version('Click', '0.4')
+from gi.repository import Click
+
+
+logger = logging.getLogger(__name__)
+
+
+class TerminalTestCase(AutopilotTestCase):
+
+ """A common testcase class that provides useful methods for the terminal
+ app.
+
+ """
+
+ local_build_location = os.path.dirname(os.path.dirname(os.getcwd()))
+ sdk_build_location = os.path.join(os.path.dirname(local_build_location),
+ os.path.basename(local_build_location)
+ + '-build')
+
+ local_build_location_qml = os.path.join(
+ local_build_location, 'src', 'app', 'qml', 'ubuntu-terminal-app.qml')
+ local_build_location_binary = os.path.join(local_build_location, 'src', 'app', 'terminal')
+ sdk_build_location_qml = os.path.join(
+ sdk_build_location, 'src', 'app', 'qml', 'ubuntu-terminal-app.qml')
+ sdk_build_location_binary = os.path.join(sdk_build_location, 'src', 'app', 'terminal')
+ installed_location_binary = '/usr/bin/ubuntu-terminal-app'
+ installed_location_qml = '/usr/share/ubuntu-terminal-app/qml/ubuntu-terminal-app.qml'
+
+ def setUp(self):
+ super(TerminalTestCase, self).setUp()
+ launcher_method, _ = self.get_launcher_method_and_type()
+ self.app = ubuntu_terminal_app.TerminalApp(launcher_method())
+
+ def get_launcher_method_and_type(self):
+ if os.path.exists(self.local_build_location_binary):
+ launcher = self.launch_test_local
+ test_type = 'local'
+ elif os.path.exists(self.sdk_build_location_binary):
+ launcher = self.launch_test_sdk
+ test_type = 'sdk'
+ elif os.path.exists(self.installed_location_binary):
+ launcher = self.launch_test_installed
+ test_type = 'deb'
+ else:
+ launcher = self.launch_test_click
+ test_type = 'click'
+ return launcher, test_type
+
+ @autopilot_logging.log_action(logger.info)
+ def launch_test_local(self):
+ self.useFixture(fixtures.EnvironmentVariable(
+ 'QML2_IMPORT_PATH', newvalue=os.path.join(self.local_build_location,
+ 'src', 'plugin')))
+ return self.launch_test_application(
+ self.local_build_location_binary,
+ app_type='qt',
+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
+
+ @autopilot_logging.log_action(logger.info)
+ def launch_test_sdk(self):
+ self.useFixture(fixtures.EnvironmentVariable(
+ 'QML2_IMPORT_PATH', newvalue=os.path.join(self.sdk_build_location,
+ 'src', 'plugin')))
+ return self.launch_test_application(
+ self.sdk_build_location_binary,
+ app_type='qt',
+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
+
+
+ @autopilot_logging.log_action(logger.info)
+ def launch_test_installed(self):
+ return self.launch_test_application(
+ self.installed_location_binary,
+ '-q', self.installed_location_qml,
+ app_type='qt',
+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
+
+ @autopilot_logging.log_action(logger.info)
+ def launch_test_click(self):
+ # We need to pass the "--forceAuth false" argument to the terminal app
+ # binary, but ubuntu-app-launch doesn't pass arguments to the exec line
+ # on the desktop file. So we make a test desktop file that has the
+ # "--forceAuth false" on the exec line.
+ desktop_file_path = self.write_sandbox_desktop_file()
+ desktop_file_name = os.path.basename(desktop_file_path)
+ application_name, _ = os.path.splitext(desktop_file_name)
+ return self.launch_upstart_application(
+ application_name,
+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
+
+ def write_sandbox_desktop_file(self):
+ desktop_file_dir = self.get_local_desktop_file_directory()
+ desktop_file = self.get_named_temporary_file(
+ suffix='.desktop', dir=desktop_file_dir)
+ desktop_file.write('[Desktop Entry]\n')
+ version, installed_path = self.get_installed_version_and_directory()
+ terminal_sandbox_exec = (
+ 'aa-exec-click -p com.ubuntu.terminal_terminal_{}'
+ ' -- terminal --forceAuth false'.format(version))
+ desktop_file_dict = {
+ 'Type': 'Application',
+ 'Name': 'terminal',
+ 'Exec': terminal_sandbox_exec,
+ 'Icon': 'Not important',
+ 'Path': installed_path
+ }
+ for key, value in desktop_file_dict.items():
+ desktop_file.write('{key}={value}\n'.format(key=key, value=value))
+ desktop_file.close()
+ logger.debug(terminal_sandbox_exec)
+ for key, value in desktop_file_dict.items():
+ logger.debug("%s: %s" % (key, value))
+ return desktop_file.name
+
+ def get_local_desktop_file_directory(self):
+ return os.path.join(
+ os.path.expanduser('~'), '.local', 'share', 'applications')
+
+ def get_named_temporary_file(
+ self, dir=None, mode='w+t', delete=False, suffix=''):
+ # Discard files with underscores which look like an APP_ID to Unity
+ # See https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1329141
+ chars = tempfile._RandomNameSequence.characters.strip("_")
+ tempfile._RandomNameSequence.characters = chars
+ return tempfile.NamedTemporaryFile(
+ dir=dir, mode=mode, delete=delete, suffix=suffix)
+
+ def get_installed_version_and_directory(self):
+ db = Click.DB()
+ db.read()
+ package_name = 'com.ubuntu.terminal'
+ registry = Click.User.for_user(db, name=os.environ.get('USER'))
+ version = registry.get_version(package_name)
+ directory = registry.get_path(package_name)
+ return version, directory
=== modified file 'tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py'
--- tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2015-02-25 18:37:32 +0000
+++ tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2016-03-07 21:17:09 +0000
@@ -7,12 +7,11 @@
"""Terminal app autopilot tests."""
-from autopilot.testcase import AutopilotTestCase
-
-# TODO Insert new tests here.
-
-
-class DummyTest(AutopilotTestCase):
- """This is just a placeholder test"""
- def test_dummy_true(self):
- self.assertTrue(True)
+from ubuntu_terminal_app.tests import TerminalTestCase
+
+
+class TestMainWindow(TerminalTestCase):
+ def test_example_test(self):
+ """Just launch app, assert on main view"""
+ main_view = self.app.main_view
+ self.assertTrue(main_view)
Follow ups
-
[Merge] lp:~nskaggs/ubuntu-terminal-app/restore-autopilot into lp:ubuntu-terminal-app
From: noreply, 2016-03-08
-
[Merge] lp:~nskaggs/ubuntu-terminal-app/restore-autopilot into lp:ubuntu-terminal-app
From: Stefano Verzegnassi, 2016-03-08
-
Re: [Merge] lp:~nskaggs/ubuntu-terminal-app/restore-autopilot into lp:ubuntu-terminal-app
From: Stefano Verzegnassi, 2016-03-08
-
Re: [Merge] lp:~nskaggs/ubuntu-terminal-app/restore-autopilot into lp:ubuntu-terminal-app
From: Jenkins Bot, 2016-03-08
-
Re: [Merge] lp:~nskaggs/ubuntu-terminal-app/restore-autopilot into lp:ubuntu-terminal-app
From: Nicholas Skaggs, 2016-03-08
-
Re: [Merge] lp:~nskaggs/ubuntu-terminal-app/restore-autopilot into lp:ubuntu-terminal-app
From: Stefano Verzegnassi, 2016-03-08
-
Re: [Merge] lp:~nskaggs/ubuntu-terminal-app/restore-autopilot into lp:ubuntu-terminal-app
From: Nicholas Skaggs, 2016-03-07
-
Re: [Merge] lp:~nskaggs/ubuntu-terminal-app/restore-autopilot into lp:ubuntu-terminal-app
From: Jenkins Bot, 2016-03-07
-
Re: [Merge] lp:~nskaggs/ubuntu-terminal-app/restore-autopilot into lp:ubuntu-terminal-app
From: Jenkins Bot, 2016-03-07
-
Re: [Merge] lp:~nskaggs/ubuntu-terminal-app/restore-autopilot into lp:ubuntu-terminal-app
From: Jenkins Bot, 2016-03-07