Merge lp:~nskaggs/ubuntu-clock-app/fix-clock-launching into lp:ubuntu-clock-app

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Nekhelesh Ramananthan
Approved revision: 445
Merged at revision: 443
Proposed branch: lp:~nskaggs/ubuntu-clock-app/fix-clock-launching
Merge into: lp:ubuntu-clock-app
Diff against target: 338 lines (+49/-209)
4 files modified
tests/autopilot/ubuntu_clock_app/CMakePluginParser.py (+0/-119)
tests/autopilot/ubuntu_clock_app/__init__.py (+7/-3)
tests/autopilot/ubuntu_clock_app/fixture_setup.py (+0/-44)
tests/autopilot/ubuntu_clock_app/tests/__init__.py (+42/-43)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-clock-app/fix-clock-launching
Reviewer Review Type Date Requested Status
Jenkins Bot continuous-integration Approve
Nekhelesh Ramananthan Approve
Review via email: mp+287238@code.launchpad.net

Commit message

Autopilot test cleanup for clock

* fix launching and add option for building with SDK
* remove fixtures
* Remove debug print_trees

Description of the change

Autopilot test cleanup for clock

* fix launching and add option for building with SDK
* remove fixtures
* Remove debug print_trees

To post a comment you must log in.
445. By Nicholas Skaggs

catch lack of animation on bottom edge

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

ooh lots of red color..love the code removal. The debian changelog hasn't been updated, but I will do that in my upcoming bottom edge MP. Thanks for this.

review: Approve
Revision history for this message
Jenkins Bot (ubuntu-core-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=== removed file 'tests/autopilot/ubuntu_clock_app/CMakePluginParser.py'
2--- tests/autopilot/ubuntu_clock_app/CMakePluginParser.py 2015-08-14 05:34:49 +0000
3+++ tests/autopilot/ubuntu_clock_app/CMakePluginParser.py 1970-01-01 00:00:00 +0000
4@@ -1,119 +0,0 @@
5-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
6-#
7-# Copyright (C) 2014-2015 Canonical Ltd.
8-#
9-# This program is free software; you can redistribute it and/or modify
10-# it under the terms of the GNU Lesser General Public License as published by
11-# the Free Software Foundation; version 3.
12-#
13-# This program is distributed in the hope that it will be useful,
14-# but WITHOUT ANY WARRANTY; without even the implied warranty of
15-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16-# GNU Lesser General Public License for more details.
17-#
18-# You should have received a copy of the GNU Lesser General Public License
19-# along with this program. If not, see <http://www.gnu.org/licenses/>.
20-#
21-# Author:
22-# David Planella <david.planella@ubuntu.com>
23-
24-"""
25-This module parses a configuration file from the Qt Creator's CMake plugin and
26-enables programmatical read-only access to several of its configuration options
27-"""
28-
29-from lxml import etree
30-
31-
32-class CMakePluginParseError(Exception):
33- """
34- Custom exception for errors during the parsing of a
35- CMakeLists.txt.user file
36- """
37- def __init__(self, message):
38- Exception.__init__(self, message)
39-
40-
41-class CMakePluginParser(object):
42- """
43- Parses a CMake plugin's config file and provides R/O access to its
44- configuration options """
45-
46- def __init__(self, cmakelists_usr_file='CMakeLists.txt.user'):
47- self.usr_file = cmakelists_usr_file
48-
49- try:
50- self.info = etree.parse(self.usr_file)
51- except:
52- raise CMakePluginParseError("Could not open the given " +
53- "CMakeLists.txt.user file: " +
54- self.info)
55-
56- def _get_active_build_target(self):
57- """
58- Return the active build target from the current project in Qt Creator
59- """
60-
61- try:
62- active_build_target_nr = self.info.xpath(
63- "./data/variable" +
64- "[text()='ProjectExplorer.Project.ActiveTarget']" +
65- "/../value")[0].text
66- except:
67- raise CMakePluginParseError("Could not find the active build " +
68- "target in the CMake plugin's config")
69-
70- active_build_target = "ProjectExplorer.Project.Target." + \
71- active_build_target_nr
72-
73- return active_build_target
74-
75- def _get_active_build_config(self, active_build_target):
76- """Return the active build config from the active build targed"""
77-
78- try:
79- active_build_config_nr = self.info.xpath(
80- "./data/variable[text()='{0}']".format(active_build_target) +
81- "/..//value[@key="
82- "'ProjectExplorer.Target.ActiveBuildConfiguration']")[0].text
83- except:
84- raise CMakePluginParseError("Could not find the active build " +
85- "target's active build config " +
86- "in the CMake plugin's config")
87-
88- active_build_config = "ProjectExplorer.Target.BuildConfiguration." + \
89- active_build_config_nr
90-
91- return active_build_config
92-
93- def _get_active_build_config_path(self):
94- """Return the active build config's absolute path"""
95-
96- active_build_target = self._get_active_build_target()
97- active_build_config = \
98- self._get_active_build_config(active_build_target)
99-
100- try:
101- active_build_config_node = self.info.xpath(
102- "./data/variable[text()='{0}']".format(active_build_target) +
103- "/..//valuemap[@key='{0}']".format(active_build_config))[0]
104- except:
105- raise CMakePluginParseError("Could not find the active " +
106- "build config's node " +
107- "in the CMake plugin's config")
108-
109- try:
110- active_build_config_path = active_build_config_node.xpath(
111- "./value[@key=" +
112- "'ProjectExplorer.BuildConfiguration.BuildDirectory']")[0].text
113- except:
114- raise CMakePluginParseError("Could not find the active build " +
115- "directory in the CMake plugin's " +
116- "config")
117-
118- return active_build_config_path
119-
120- @property
121- def active_build_dir(self):
122- """Return the active build config's directory as an absolute path"""
123- return self._get_active_build_config_path()
124
125=== modified file 'tests/autopilot/ubuntu_clock_app/__init__.py'
126--- tests/autopilot/ubuntu_clock_app/__init__.py 2016-02-02 23:45:47 +0000
127+++ tests/autopilot/ubuntu_clock_app/__init__.py 2016-02-25 22:18:48 +0000
128@@ -115,7 +115,11 @@
129 try:
130 action_item = self.wait_select_single(objectName='bottomEdgeTip')
131 action_item.visible.wait_for(True)
132- action_item.isAnimating.wait_for(False)
133+ try:
134+ action_item.isAnimating.wait_for(False)
135+ except:
136+ logger.debug("Bottom edge isn't animating")
137+ pass
138 start_x = (action_item.globalRect.x +
139 (action_item.globalRect.width * 0.5))
140 start_y = (action_item.globalRect.y +
141@@ -289,7 +293,7 @@
142
143 cityList.count.wait_for(GreaterThan(0))
144
145- cityList.print_tree() # Debug line
146+ #cityList.print_tree() # Debug line
147
148 for index in range(int(cityList.count)):
149 world_city_item = self.wait_select_single(
150@@ -402,7 +406,7 @@
151 self.unselect_selected_days()
152 index = 0
153
154- self.print_tree() # Debug line
155+ #self.print_tree() # Debug line
156
157 for index in range(len(days)):
158 for index2 in range(self._get_num_of_days()):
159
160=== removed file 'tests/autopilot/ubuntu_clock_app/fixture_setup.py'
161--- tests/autopilot/ubuntu_clock_app/fixture_setup.py 2015-09-14 20:53:36 +0000
162+++ tests/autopilot/ubuntu_clock_app/fixture_setup.py 1970-01-01 00:00:00 +0000
163@@ -1,44 +0,0 @@
164-# Copyright (C) 2014-2015 Canonical Ltd
165-#
166-# This file is part of Ubuntu Clock App
167-#
168-# Ubuntu Clock App is free software: you can redistribute it and/or modify
169-# it under the terms of the GNU General Public License version 3 as
170-# published by the Free Software Foundation.
171-#
172-# Ubuntu Clock App is distributed in the hope that it will be useful,
173-# but WITHOUT ANY WARRANTY; without even the implied warranty of
174-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
175-# GNU General Public License for more details.
176-#
177-# You should have received a copy of the GNU General Public License
178-# along with this program. If not, see <http://www.gnu.org/licenses/>.
179-
180-"""Clock app autopilot fixtures."""
181-
182-import fixtures
183-import logging
184-import subprocess
185-
186-
187-class LocationServiceTestEnvironment(fixtures.Fixture):
188-
189- def setUp(self):
190- super(LocationServiceTestEnvironment, self).setUp()
191- self._set_location_service_testing(True)
192- self.addCleanup(self._set_location_service_testing, False)
193-
194- def _set_location_service_testing(self, test_mode):
195- test = 'true' if test_mode else 'false'
196- try:
197- subprocess.check_call(
198- 'sudo setprop custom.location.testing {}'.format(test),
199- shell=True)
200- subprocess.check_call(
201- 'sudo restart ubuntu-location-service && '
202- 'restart ubuntu-location-service-trust-stored',
203- shell=True)
204- except subprocess.CalledProcessError:
205- logger = logging.getLogger(__name__)
206- logger.error('Unable to start location service in testing mode '
207- 'tests may fail as a result.')
208
209=== modified file 'tests/autopilot/ubuntu_clock_app/tests/__init__.py'
210--- tests/autopilot/ubuntu_clock_app/tests/__init__.py 2015-08-14 05:34:49 +0000
211+++ tests/autopilot/ubuntu_clock_app/tests/__init__.py 2016-02-25 22:18:48 +0000
212@@ -30,7 +30,6 @@
213 from ubuntuuitoolkit import base
214
215 import ubuntu_clock_app
216-from ubuntu_clock_app import fixture_setup, CMakePluginParser
217
218 logger = logging.getLogger(__name__)
219
220@@ -42,26 +41,33 @@
221
222 """
223
224+ # Source built locally paths
225+ local_location = os.path.dirname(os.path.dirname(os.getcwd()))
226+ local_build_location = os.path.join(local_location, 'builddir')
227+ local_build_location_qml = os.path.join(
228+ local_location, 'app/ubuntu-clock-app.qml')
229+ #local_build_location_binary = os.path.join(local_build_location, 'app')
230+ local_build_location_backend = os.path.join(local_build_location, 'backend')
231+
232+
233+ # Source built with SDK paths
234+ sdk_build_location = os.path.join(os.path.dirname(local_location),
235+ os.path.basename(local_location)
236+ + '-build')
237+ sdk_build_location_qml = os.path.join(
238+ local_location, 'app/ubuntu-clock-app.qml')
239+ #sdk_build_location_binary = os.path.join(sdk_build_location, 'app/ubuntu-clock-app')
240+ sdk_build_location_backend = os.path.join(sdk_build_location, 'backend')
241+
242+ # Installed binary paths
243+ #installed_location_binary = '/usr/bin/ubuntu-clock-app'
244+ installed_location_qml = '/usr/share/ubuntu-clock-app/ubuntu-clock-app.qml'
245+ installed_location_backend = ""
246+ if glob.glob('/usr/lib/*/qt5/qml/ClockApp'):
247+ self.installed_location_backend = \
248+ glob.glob('/usr/lib/*/qt5/qml/ClockApp')[0]
249+
250 def setUp(self):
251- # setup paths
252- self.binary = 'ubuntu-clock-app'
253- self.source_dir = os.path.dirname(
254- os.path.dirname(os.path.abspath('.')))
255- self.build_dir = self._get_build_dir()
256-
257- self.local_location = self.source_dir
258- self.local_location_qml = os.path.join(self.source_dir,
259- 'app', self.binary + '.qml')
260-
261- self.local_location_backend = os.path.join(self.build_dir, 'backend')
262-
263- self.installed_location_backend = ""
264- if glob.glob('/usr/lib/*/qt5/qml/ClockApp'):
265- self.installed_location_backend = \
266- glob.glob('/usr/lib/*/qt5/qml/ClockApp')[0]
267- self.installed_location_qml = \
268- '/usr/share/ubuntu-clock-app/ubuntu-clock-app.qml'
269-
270 self.sqlite_dir = os.path.expanduser(
271 "~/.local/share/com.ubuntu.clock")
272 self.backup_dir = self.sqlite_dir + ".backup"
273@@ -70,9 +76,7 @@
274 self.temp_move_sqlite_db()
275 self.addCleanup(self.restore_sqlite_db)
276
277- # setup fixtures and launcher
278- self.useFixture(fixture_setup.LocationServiceTestEnvironment())
279- self.useFixture(fixtures.EnvironmentVariable('LC_ALL', newvalue='C'))
280+ # setup launcher
281 self.launcher, self.test_type = self.get_launcher_and_type()
282
283 # launch application under introspection
284@@ -80,9 +84,12 @@
285 self.app = ubuntu_clock_app.ClockApp(self.launcher(), self.test_type)
286
287 def get_launcher_and_type(self):
288- if os.path.exists(self.local_location_backend):
289+ if os.path.exists(self.local_build_location_backend):
290 launcher = self.launch_test_local
291 test_type = 'local'
292+ elif os.path.exists(self.sdk_build_location_backend):
293+ launcher = self.launch_test_sdk
294+ test_type = 'sdk'
295 elif os.path.exists(self.installed_location_backend):
296 launcher = self.launch_test_installed
297 test_type = 'deb'
298@@ -95,8 +102,17 @@
299 def launch_test_local(self):
300 return self.launch_test_application(
301 base.get_qmlscene_launch_command(),
302- self.local_location_qml,
303- "-I", self.local_location_backend,
304+ self.local_build_location_qml,
305+ "-I", self.local_build_location_backend,
306+ app_type='qt',
307+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
308+
309+ @autopilot_logging.log_action(logger.info)
310+ def launch_test_sdk(self):
311+ return self.launch_test_application(
312+ base.get_qmlscene_launch_command(),
313+ self.sdk_build_location_qml,
314+ "-I", self.sdk_build_location_backend,
315 app_type='qt',
316 emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
317
318@@ -143,20 +159,3 @@
319 shutil.move(self.backup_dir, self.sqlite_dir)
320 except:
321 logger.error("Failed to restore database")
322-
323- def _get_build_dir(self):
324- """
325- Returns the build dir after having parsed the CMake config file
326- generated by Qt Creator. If it cannot find it or it cannot be parsed,
327- an in-tree build is assumed and thus returned.
328- """
329- try:
330- cmake_config = CMakePluginParser.CMakePluginParser(os.path.join(
331- self.source_dir, 'CMakeLists.txt.user'))
332- build_dir = cmake_config.active_build_dir
333- except:
334- logger.error("Error parsing CMakeLists.txt.user %s",
335- sys.exc_info()[0])
336- build_dir = os.path.join(self.source_dir, 'builddir')
337-
338- return build_dir

Subscribers

People subscribed via source and target branches