Nicholas Skaggs has proposed merging lp:~nskaggs/ubuntu-clock-app/fix-clock-launching into lp:ubuntu-clock-app.
Commit message: Autopilot test cleanup for clock * fix launching and add option for building with SDK * remove fixtures * Remove debug print_trees Requested reviews: Ubuntu Clock Developers (ubuntu-clock-dev) For more details, see: https://code.launchpad.net/~nskaggs/ubuntu-clock-app/fix-clock-launching/+merge/287238 Autopilot test cleanup for clock * fix launching and add option for building with SDK * remove fixtures * Remove debug print_trees -- Your team Ubuntu Clock Developers is requested to review the proposed merge of lp:~nskaggs/ubuntu-clock-app/fix-clock-launching into lp:ubuntu-clock-app.
=== removed file 'tests/autopilot/ubuntu_clock_app/CMakePluginParser.py' --- tests/autopilot/ubuntu_clock_app/CMakePluginParser.py 2015-08-14 05:34:49 +0000 +++ tests/autopilot/ubuntu_clock_app/CMakePluginParser.py 1970-01-01 00:00:00 +0000 @@ -1,119 +0,0 @@ -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- -# -# Copyright (C) 2014-2015 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/>. -# -# Author: -# David Planella <david.plane...@ubuntu.com> - -""" -This module parses a configuration file from the Qt Creator's CMake plugin and -enables programmatical read-only access to several of its configuration options -""" - -from lxml import etree - - -class CMakePluginParseError(Exception): - """ - Custom exception for errors during the parsing of a - CMakeLists.txt.user file - """ - def __init__(self, message): - Exception.__init__(self, message) - - -class CMakePluginParser(object): - """ - Parses a CMake plugin's config file and provides R/O access to its - configuration options """ - - def __init__(self, cmakelists_usr_file='CMakeLists.txt.user'): - self.usr_file = cmakelists_usr_file - - try: - self.info = etree.parse(self.usr_file) - except: - raise CMakePluginParseError("Could not open the given " + - "CMakeLists.txt.user file: " + - self.info) - - def _get_active_build_target(self): - """ - Return the active build target from the current project in Qt Creator - """ - - try: - active_build_target_nr = self.info.xpath( - "./data/variable" + - "[text()='ProjectExplorer.Project.ActiveTarget']" + - "/../value")[0].text - except: - raise CMakePluginParseError("Could not find the active build " + - "target in the CMake plugin's config") - - active_build_target = "ProjectExplorer.Project.Target." + \ - active_build_target_nr - - return active_build_target - - def _get_active_build_config(self, active_build_target): - """Return the active build config from the active build targed""" - - try: - active_build_config_nr = self.info.xpath( - "./data/variable[text()='{0}']".format(active_build_target) + - "/..//value[@key=" - "'ProjectExplorer.Target.ActiveBuildConfiguration']")[0].text - except: - raise CMakePluginParseError("Could not find the active build " + - "target's active build config " + - "in the CMake plugin's config") - - active_build_config = "ProjectExplorer.Target.BuildConfiguration." + \ - active_build_config_nr - - return active_build_config - - def _get_active_build_config_path(self): - """Return the active build config's absolute path""" - - active_build_target = self._get_active_build_target() - active_build_config = \ - self._get_active_build_config(active_build_target) - - try: - active_build_config_node = self.info.xpath( - "./data/variable[text()='{0}']".format(active_build_target) + - "/..//valuemap[@key='{0}']".format(active_build_config))[0] - except: - raise CMakePluginParseError("Could not find the active " + - "build config's node " + - "in the CMake plugin's config") - - try: - active_build_config_path = active_build_config_node.xpath( - "./value[@key=" + - "'ProjectExplorer.BuildConfiguration.BuildDirectory']")[0].text - except: - raise CMakePluginParseError("Could not find the active build " + - "directory in the CMake plugin's " + - "config") - - return active_build_config_path - - @property - def active_build_dir(self): - """Return the active build config's directory as an absolute path""" - return self._get_active_build_config_path() === modified file 'tests/autopilot/ubuntu_clock_app/__init__.py' --- tests/autopilot/ubuntu_clock_app/__init__.py 2016-02-02 23:45:47 +0000 +++ tests/autopilot/ubuntu_clock_app/__init__.py 2016-02-25 22:13:23 +0000 @@ -289,7 +289,7 @@ cityList.count.wait_for(GreaterThan(0)) - cityList.print_tree() # Debug line + #cityList.print_tree() # Debug line for index in range(int(cityList.count)): world_city_item = self.wait_select_single( @@ -402,7 +402,7 @@ self.unselect_selected_days() index = 0 - self.print_tree() # Debug line + #self.print_tree() # Debug line for index in range(len(days)): for index2 in range(self._get_num_of_days()): === removed file 'tests/autopilot/ubuntu_clock_app/fixture_setup.py' --- tests/autopilot/ubuntu_clock_app/fixture_setup.py 2015-09-14 20:53:36 +0000 +++ tests/autopilot/ubuntu_clock_app/fixture_setup.py 1970-01-01 00:00:00 +0000 @@ -1,44 +0,0 @@ -# Copyright (C) 2014-2015 Canonical Ltd -# -# This file is part of Ubuntu Clock App -# -# Ubuntu Clock App 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. -# -# Ubuntu Clock App 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -"""Clock app autopilot fixtures.""" - -import fixtures -import logging -import subprocess - - -class LocationServiceTestEnvironment(fixtures.Fixture): - - def setUp(self): - super(LocationServiceTestEnvironment, self).setUp() - self._set_location_service_testing(True) - self.addCleanup(self._set_location_service_testing, False) - - def _set_location_service_testing(self, test_mode): - test = 'true' if test_mode else 'false' - try: - subprocess.check_call( - 'sudo setprop custom.location.testing {}'.format(test), - shell=True) - subprocess.check_call( - 'sudo restart ubuntu-location-service && ' - 'restart ubuntu-location-service-trust-stored', - shell=True) - except subprocess.CalledProcessError: - logger = logging.getLogger(__name__) - logger.error('Unable to start location service in testing mode ' - 'tests may fail as a result.') === modified file 'tests/autopilot/ubuntu_clock_app/tests/__init__.py' --- tests/autopilot/ubuntu_clock_app/tests/__init__.py 2015-08-14 05:34:49 +0000 +++ tests/autopilot/ubuntu_clock_app/tests/__init__.py 2016-02-25 22:13:23 +0000 @@ -30,7 +30,6 @@ from ubuntuuitoolkit import base import ubuntu_clock_app -from ubuntu_clock_app import fixture_setup, CMakePluginParser logger = logging.getLogger(__name__) @@ -42,26 +41,33 @@ """ + # Source built locally paths + local_location = os.path.dirname(os.path.dirname(os.getcwd())) + local_build_location = os.path.join(local_location, 'builddir') + local_build_location_qml = os.path.join( + local_location, 'app/ubuntu-clock-app.qml') + #local_build_location_binary = os.path.join(local_build_location, 'app') + local_build_location_backend = os.path.join(local_build_location, 'backend') + + + # Source built with SDK paths + sdk_build_location = os.path.join(os.path.dirname(local_location), + os.path.basename(local_location) + + '-build') + sdk_build_location_qml = os.path.join( + local_location, 'app/ubuntu-clock-app.qml') + #sdk_build_location_binary = os.path.join(sdk_build_location, 'app/ubuntu-clock-app') + sdk_build_location_backend = os.path.join(sdk_build_location, 'backend') + + # Installed binary paths + #installed_location_binary = '/usr/bin/ubuntu-clock-app' + installed_location_qml = '/usr/share/ubuntu-clock-app/ubuntu-clock-app.qml' + installed_location_backend = "" + if glob.glob('/usr/lib/*/qt5/qml/ClockApp'): + self.installed_location_backend = \ + glob.glob('/usr/lib/*/qt5/qml/ClockApp')[0] + def setUp(self): - # setup paths - self.binary = 'ubuntu-clock-app' - self.source_dir = os.path.dirname( - os.path.dirname(os.path.abspath('.'))) - self.build_dir = self._get_build_dir() - - self.local_location = self.source_dir - self.local_location_qml = os.path.join(self.source_dir, - 'app', self.binary + '.qml') - - self.local_location_backend = os.path.join(self.build_dir, 'backend') - - self.installed_location_backend = "" - if glob.glob('/usr/lib/*/qt5/qml/ClockApp'): - self.installed_location_backend = \ - glob.glob('/usr/lib/*/qt5/qml/ClockApp')[0] - self.installed_location_qml = \ - '/usr/share/ubuntu-clock-app/ubuntu-clock-app.qml' - self.sqlite_dir = os.path.expanduser( "~/.local/share/com.ubuntu.clock") self.backup_dir = self.sqlite_dir + ".backup" @@ -70,9 +76,7 @@ self.temp_move_sqlite_db() self.addCleanup(self.restore_sqlite_db) - # setup fixtures and launcher - self.useFixture(fixture_setup.LocationServiceTestEnvironment()) - self.useFixture(fixtures.EnvironmentVariable('LC_ALL', newvalue='C')) + # setup launcher self.launcher, self.test_type = self.get_launcher_and_type() # launch application under introspection @@ -80,9 +84,12 @@ self.app = ubuntu_clock_app.ClockApp(self.launcher(), self.test_type) def get_launcher_and_type(self): - if os.path.exists(self.local_location_backend): + if os.path.exists(self.local_build_location_backend): launcher = self.launch_test_local test_type = 'local' + elif os.path.exists(self.sdk_build_location_backend): + launcher = self.launch_test_sdk + test_type = 'sdk' elif os.path.exists(self.installed_location_backend): launcher = self.launch_test_installed test_type = 'deb' @@ -95,8 +102,17 @@ def launch_test_local(self): return self.launch_test_application( base.get_qmlscene_launch_command(), - self.local_location_qml, - "-I", self.local_location_backend, + self.local_build_location_qml, + "-I", self.local_build_location_backend, + app_type='qt', + emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase) + + @autopilot_logging.log_action(logger.info) + def launch_test_sdk(self): + return self.launch_test_application( + base.get_qmlscene_launch_command(), + self.sdk_build_location_qml, + "-I", self.sdk_build_location_backend, app_type='qt', emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase) @@ -143,20 +159,3 @@ shutil.move(self.backup_dir, self.sqlite_dir) except: logger.error("Failed to restore database") - - def _get_build_dir(self): - """ - Returns the build dir after having parsed the CMake config file - generated by Qt Creator. If it cannot find it or it cannot be parsed, - an in-tree build is assumed and thus returned. - """ - try: - cmake_config = CMakePluginParser.CMakePluginParser(os.path.join( - self.source_dir, 'CMakeLists.txt.user')) - build_dir = cmake_config.active_build_dir - except: - logger.error("Error parsing CMakeLists.txt.user %s", - sys.exc_info()[0]) - build_dir = os.path.join(self.source_dir, 'builddir') - - return build_dir
-- Mailing list: https://launchpad.net/~ubuntu-touch-coreapps-reviewers Post to : ubuntu-touch-coreapps-reviewers@lists.launchpad.net Unsubscribe : https://launchpad.net/~ubuntu-touch-coreapps-reviewers More help : https://help.launchpad.net/ListHelp