Merge lp:~dobey/pay-ui/adt-run-ap into lp:pay-ui

Proposed by dobey on 2015-02-11
Status: Merged
Approved by: dobey on 2015-02-13
Approved revision: 111
Merged at revision: 99
Proposed branch: lp:~dobey/pay-ui/adt-run-ap
Merge into: lp:pay-ui
Diff against target: 507 lines (+226/-106)
9 files modified
CMakeLists.txt (+83/-66)
HACKING (+62/-5)
backend/CMakeLists.txt (+4/-0)
cmake/Click.cmake (+0/-17)
manifest.json.in (+20/-3)
payui_payui.desktop.in.in (+1/-1)
tests/autopilot/pay_ui/tests/__init__.py (+50/-12)
tests/autopilot/pay_ui/tests/mock_server.py (+3/-1)
tests/autopilot/pay_ui/tests/test_pay_ui.py (+3/-1)
To merge this branch: bzr merge lp:~dobey/pay-ui/adt-run-ap
Reviewer Review Type Date Requested Status
Leo Arias (community) Approve on 2015-02-13
PS Jenkins bot continuous-integration Approve on 2015-02-13
Charles Kerr (community) 2015-02-11 Approve on 2015-02-12
Review via email: mp+249387@code.launchpad.net

Commit Message

Enable autopkgtest integration for autopilot tests.

Description of the Change

This branch is a pretty big set of changes to accomplish the goal of running autopilot tests with autopkgtest. There are still some additional changes which need to happen, so the tests can be run on actual devices or emulators where Mir is running, and there are some issues still with a click event for the "Buy Now" button not making it through to the application. I will file separate bugs for these.

There are instructions for how to build and test this in the HACKING file.

To post a comment you must log in.
lp:~dobey/pay-ui/adt-run-ap updated on 2015-02-11
106. By dobey on 2015-02-11

Add instructions to create click chroot to HACKING.

lp:~dobey/pay-ui/adt-run-ap updated on 2015-02-11
107. By dobey on 2015-02-11

Fix the path in the .desktop file.

108. By dobey on 2015-02-11

Doh. Missing create in click chroot command.

Leo Arias (elopio) wrote :

The HACKING file is gold, thanks for that.
I just don't understand why you need to get the deb from https://launchpad.net/ubuntu/+source/autopkgtest
Wouldn't it be enough to apt-get update and upgrade?

436 + import logging
437 + logger = logging.getLogger()
438 + logger.error('Error getting arch triplet: %s' % e)
439 + return ''

Here I would make the logger a global variable, and use it more. It would be useful to log the method you are using to launch the app, for example.
You could use the autopilot decorator, like in http://bazaar.launchpad.net/~ubuntuone-control-tower/unity-scope-click/trunk/view/head:/autopilot/unityclickscope/__init__.py

Also, I don't understand why are you returning '' instead of raising the exception. Will it work with '' instead of the arch?

I think I might found something useful related to the skipped tests. I removed the skip in one, and I got the same error when doing make autopilot as when running on the qemu with adt-run:

http://paste.ubuntu.com/10182187/

When I do make autopilot, I have some seconds while the test is waiting for the expected results. There I hit the buy button many times, and nothing happens. So, maybe it has nothing to do with qemu. Does the same happen to you?

And finally, your branch is not passing flake8. Some of the errors come from before, so maybe that could be fixed in a different branch. And it would be useful to add the check as part of the build process.

I'm not good for reviewing the cmake files. I'll just take a look there to see if I can learn something.

Thanks dobey!

lp:~dobey/pay-ui/adt-run-ap updated on 2015-02-12
109. By dobey on 2015-02-12

Cleanups for pep8/pyflakes.
Move logging import and logger definition to global space.
Let exceptions raise instead of logging and returning empty string.

110. By dobey on 2015-02-12

Remove the logging as it's now unused.

dobey (dobey) wrote :

On Thu, 2015-02-12 at 03:45 +0000, Leo Arias wrote:
> The HACKING file is gold, thanks for that.
> I just don't understand why you need to get the deb from
> https://launchpad.net/ubuntu/+source/autopkgtest
> Wouldn't it be enough to apt-get update and upgrade?

If you are running the latest devel version of Ubuntu, then yes apt-get
update will work. But if you are on 14.04 for example, then you need to
grab it manually.

>
> 436 + import logging
> 437 + logger = logging.getLogger()
> 438 + logger.error('Error getting arch triplet: %s' % e)
> 439 + return ''
>
> Here I would make the logger a global variable, and use it more. It
> would be useful to log the method you are using to launch the app, for
> example.

Ended up just removing the logging in favor of just raising always in
the places where logging was used.

> You could use the autopilot decorator, like in
> http://bazaar.launchpad.net/~ubuntuone-control-tower/unity-scope-click/trunk/view/head:/autopilot/unityclickscope/__init__.py

I don't quite understand what that is doing exactly. Seems perhaps not
needed here though.

> Also, I don't understand why are you returning '' instead of raising
> the exception. Will it work with '' instead of the arch?

Was just playing it safe because I don't want autopilot to explode when
plausible error conditions come up. But I just remembered unittest traps
the exception as a failure anyway, so I just got rid of the logging
there, and let it raise naturally.

> I think I might found something useful related to the skipped tests. I
> removed the skip in one, and I got the same error when doing make
> autopilot as when running on the qemu with adt-run:
>
> http://paste.ubuntu.com/10182187/
>
> When I do make autopilot, I have some seconds while the test is
> waiting for the expected results. There I hit the buy button many
> times, and nothing happens. So, maybe it has nothing to do with qemu.
> Does the same happen to you?

Thanks for poking at this. I see what's happening there now, and have
filed bug #1421277 for this.

> And finally, your branch is not passing flake8. Some of the errors
> come from before, so maybe that could be fixed in a different branch.
> And it would be useful to add the check as part of the build process.

I've fixed the pep8/pyflakes warnings that came up from running the
versions I have installed.

[1421277] https://launchpad.net/bugs/1421277

Leo Arias (elopio) wrote :

lgtm.

review: Approve (autopilot code and reamde instructions)
dobey (dobey) wrote :

Also just filed bug #1421343 about static checking not being done on the Python code. I think it should be fixed in another branch.

Charles Kerr (charlesk) wrote :

Good stuff.

review: Approve
Leo Arias (elopio) wrote :

237 +We output the image to ~/ rather than the current directory, so it will in
238 +a safer place to avoid rebuilding images every time. You can store it in any

There's a typo here. Should be:

so it will BE in a safer place

review: Needs Fixing
lp:~dobey/pay-ui/adt-run-ap updated on 2015-02-13
111. By dobey on 2015-02-13

Fix typo in HACKING.

Leo Arias (elopio) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-02-05 22:54:40 +0000
3+++ CMakeLists.txt 2015-02-13 14:04:51 +0000
4@@ -1,72 +1,52 @@
5 project(payui C CXX)
6 cmake_minimum_required(VERSION 2.8.9)
7
8-set (UBUNTU_PROJECT_TYPE "ClickApp" CACHE INTERNAL "Tells QtCreator this is a Click application project")
9-set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
10-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")
11-set(DATA_DIR /)
12+find_program(INTLTOOL_MERGE intltool-merge)
13+find_program(INTLTOOL_EXTRACT intltool-extract)
14+
15+set(CMAKE_AUTOMOC ON)
16+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
17+
18+# Standard install paths
19+include(GNUInstallDirs)
20+
21+option(CLICK_MODE "Installs to a contained location for click packaging" on)
22+
23 set(APP_NAME payui)
24-set(APPLICATION_DIR ${DATA_DIR})
25 set(CLICK_NAMESPACE com.canonical.payui)
26 set(APPLICATION_FILE "${CLICK_NAMESPACE}_${APP_NAME}.application")
27 set(DESKTOP_FILE "${PROJECT_NAME}_${APP_NAME}.desktop")
28
29-find_package(Qt5Core)
30-find_package(Qt5Qml)
31-find_package(Qt5Quick)
32-
33-include(GNUInstallDirs)
34-
35-#find_package(ubuntu-sdk-libs)
36-find_program(INTLTOOL_MERGE intltool-merge)
37-find_program(INTLTOOL_EXTRACT intltool-extract)
38-
39-#automatically create moc files
40-set(CMAKE_AUTOMOC ON)
41-
42-# components PATH
43-execute_process(
44- COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
45- OUTPUT_VARIABLE ARCH_TRIPLET
46- OUTPUT_STRIP_TRAILING_WHITESPACE
47-)
48+# Set the bzr revno to "last" if not provided as argument to cmake
49+if(NOT BZR_REVNO)
50+ set(BZR_REVNO "last")
51+endif(NOT BZR_REVNO)
52+
53+# Get the arch triplet for binary file lcations
54+execute_process(
55+ COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
56+ OUTPUT_VARIABLE ARCH_TRIPLET
57+ OUTPUT_STRIP_TRAILING_WHITESPACE
58+ )
59+
60+# Get the host arch value for the packaging
61+execute_process(
62+ COMMAND dpkg-architecture -qDEB_HOST_ARCH
63+ OUTPUT_VARIABLE PACKAGE_ARCH
64+ OUTPUT_STRIP_TRAILING_WHITESPACE
65+ )
66+
67 set(QT_IMPORTS_DIR "lib/${ARCH_TRIPLET}")
68-
69-option(INSTALL_TESTS "Install the tests on make install" on)
70-
71-set(APP_NAME payui)
72-set(PAYUI_DIR "share/qml/payui")
73-set(MAIN_QML "payui.qml")
74-set(ICON "grapics/credit_card@8.png")
75-
76-#set install paths
77-set(CMAKE_INSTALL_PREFIX /)
78-set(DATA_DIR /)
79-set(DESKTOP_DIR ${DATA_DIR})
80-set(ICON ".${DATA_DIR}/${ICON}")
81-
82-set(EXEC "qmlscene $@ ${PAYUI_DIR}/${MAIN_QML}")
83-
84-install(FILES manifest.json DESTINATION ${CMAKE_INSTALL_PREFIX})
85-install(DIRECTORY "app/graphics" DESTINATION ${DATA_DIR})
86-install(FILES "${CMAKE_PROJECT_NAME}.json" DESTINATION ${DATA_DIR})
87-configure_file(${APPLICATION_FILE}.in ${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_FILE})
88-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_FILE} DESTINATION ${APPLICATION_DIR})
89-
90-add_subdirectory(app)
91-add_subdirectory(backend)
92-
93-add_custom_target("run" /usr/bin/qmlscene -I ${CMAKE_BINARY_DIR}/backend ${CMAKE_SOURCE_DIR}/app/payui.qml
94- DEPENDS payuibackend payuibackend-qmldir
95- WORKING_DIRECTORY ./app)
96-
97-add_custom_target("autopilot" PYTHONPATH=${CMAKE_SOURCE_DIR}/tests/autopilot BUILD_DIR=${CMAKE_BINARY_DIR} SOURCE_DIR=${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/tests/autopilot/run_autopilot
98- DEPENDS payuibackend payuibackend-qmldir)
99-
100-file(GLOB SRC_FILES
101- RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
102- *.qml *.js *.png *.js *.svg)
103-install(FILES ${SRC_FILES} ${ICON_FILE} DESTINATION ${DATA_DIR})
104+set(BIN_DIR "${QT_IMPORTS_DIR}/bin")
105+
106+set(PAYUI_DIR "${DATA_DIR}/qml")
107+
108+file(GLOB CLICK_FILES
109+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
110+ manifest.json.in payui.json
111+ )
112+
113+add_custom_target(payui_CLICKFiles ALL SOURCES ${CLICK_FILES})
114
115 file(GLOB_RECURSE I18N_SRC_FILES
116 RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po
117@@ -76,14 +56,51 @@
118
119 configure_file(${DESKTOP_FILE}.in.in ${DESKTOP_FILE}.in)
120 add_custom_target(${DESKTOP_FILE} ALL
121- COMMENT "Merging translations into ${DESKTOP_FILE}"
122- COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_CURRENT_SOURCE_DIR}/po
123- ${DESKTOP_FILE}.in ${DESKTOP_FILE} >/dev/null)
124-
125-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE} DESTINATION ${DESKTOP_DIR})
126-
127+ COMMENT "Merging translations into ${DESKTOP_FILE}"
128+ COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_CURRENT_SOURCE_DIR}/po
129+ ${DESKTOP_FILE}.in ${DESKTOP_FILE} >/dev/null
130+ )
131+
132+configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json)
133+configure_file(${APPLICATION_FILE}.in ${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_FILE})
134+
135+if(CLICK_MODE)
136+ # Set directory paths
137+ set(CMAKE_INSTALL_PREFIX /)
138+ set(CMAKE_INSTALL_BINDIR /)
139+ set(DATA_DIR /)
140+
141+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json payui.json
142+ DESTINATION ${CMAKE_INSTALL_PREFIX}
143+ )
144+
145+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_FILE}
146+ DESTINATION ${DATA_DIR}
147+ )
148+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE}
149+ DESTINATION ${DATA_DIR}
150+ )
151+
152+ install(DIRECTORY "app/graphics" DESTINATION ${DATA_DIR})
153+else(CLICK_MODE)
154+ message("Click mode disabled. Not installing files.")
155+endif(CLICK_MODE)
156+
157+add_subdirectory(app)
158+add_subdirectory(backend)
159 add_subdirectory(po)
160
161+add_custom_target("run"
162+ COMMAND /usr/bin/qmlscene -I ${CMAKE_BINARY_DIR}/backend ${CMAKE_SOURCE_DIR}/app/payui.qml
163+ DEPENDS payuibackend payuibackend-qmldir
164+ WORKING_DIRECTORY ./app
165+ )
166+
167+add_custom_target("autopilot"
168+ COMMAND PYTHONPATH=${CMAKE_SOURCE_DIR}/tests/autopilot BUILD_DIR=${CMAKE_BINARY_DIR} SOURCE_DIR=${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/tests/autopilot/run_autopilot
169+ DEPENDS payuibackend payuibackend-qmldir
170+ )
171+
172 add_custom_target(check
173 DEPENDS cppunit-tests
174 )
175
176=== modified file 'HACKING'
177--- HACKING 2014-08-19 14:52:13 +0000
178+++ HACKING 2015-02-13 14:04:51 +0000
179@@ -12,9 +12,9 @@
180 Getting dependencies
181 --------------------
182
183-To succesfully build pay-ui there are a few packages required:
184+To succesfully build pay-ui extra packages are required, beyond the SDK:
185
186- $ sudo apt-get install libubuntuoneauth-2.0-dev libqt5webkit5-qmlwebkitplugin
187+ $ sudo apt-get install libubuntuoneauth-2.0-dev
188
189
190 Building pay-ui
191@@ -28,9 +28,66 @@
192 $ make -j 8
193
194
195+Building a click package of pay-ui
196+----------------------------------
197+
198+To build a package for the amd64 architecture, you can run the following
199+command. Replace amd64 with i386 or armhf to build a package for those
200+architectures instead. If you've already created a chroot for the framework
201+and architecture, you can skip that command.
202+
203+ $ click chroot -f ubuntu-sdk-14.10 -a amd64 create
204+ $ click-buddy --framework ubuntu-sdk-14.10 --arch amd64 \
205+ --extra-deps libubuntuoneauth-2.0-dev
206+
207 Running the unit tests
208 ----------------------
209
210- $ cd tests/autopilot
211- $ ./run_autopilot
212-
213+ $ make check
214+
215+
216+Running the autopilot tests
217+---------------------------
218+
219+To run the autopilot tests locally, you first need to build pay-ui.
220+
221+ $ make autopilot
222+
223+The autopilot tests can also be run against a built click package, under
224+qemu. To do so, you will need some additional packages. Most importantly,
225+you will need the latest version of the autopkgtest package. You can download
226+it at https://launchpad.net/ubuntu/+source/autopkgtest by selecting the most
227+recent build for the most recent version of Ubuntu.
228+
229+ $ sudo dpkg -i autopkgtest*.deb
230+ $ sudo apt-get install qemu
231+
232+After installing autopkgtest and qemu, you need to build an image for qemu
233+to use. We use vivid here, as building an image to closely resemble the actual
234+stable phone images is quite difficult. When this is easier in the future, we
235+will switch to using stable phone images for this. The architecture argument
236+should match the architecture of the click package you are trying to test.
237+We output the image to ~/ rather than the current directory, so it will be in
238+a safer place to avoid rebuilding images every time. You can store it in any
239+directory you wish.
240+
241+ $ adt-buildvm-ubuntu-cloud -r vivid -a amd64 -o ~/
242+
243+Then the tests may be run using adt-run with the qemu virtualization host.
244+The output directory option here can be wherever you like, and is where the
245+test artifacts will be placed. The ordering of the arguments to adt-run is
246+important so try to keep them in this order.
247+
248+ $ adt-run --click-source . \
249+ --click ./com.canonical.payui_15.01.*_amd64.click \
250+ -o /tmp/adt-payui-test -U --apt-pocket proposed \
251+ --setup-commands ubuntu-touch-session
252+ --- qemu ~/adt-vivid-amd64-cloud.img
253+
254+To examine the test results, which are in subunit format, additional tools are
255+required.
256+
257+ $ sudo add-apt-repository ppa:thomir/trv
258+ $ sudo apt-get update
259+ $ sudo apt-get install trv
260+ $ trv /tmp/adt-payui-test/artifacts/autopilot.subunit
261
262=== modified file 'backend/CMakeLists.txt'
263--- backend/CMakeLists.txt 2014-12-03 17:17:49 +0000
264+++ backend/CMakeLists.txt 2015-02-13 14:04:51 +0000
265@@ -2,6 +2,10 @@
266 set(CMAKE_INCLUDE_CURRENT_DIR ON)
267 set(CMAKE_AUTOMOC ON)
268
269+find_package(Qt5Core)
270+find_package(Qt5Qml)
271+find_package(Qt5Quick)
272+
273 include_directories(
274 ${CMAKE_CURRENT_SOURCE_DIR}
275 )
276
277=== removed directory 'cmake'
278=== removed file 'cmake/Click.cmake'
279--- cmake/Click.cmake 2014-06-23 18:20:45 +0000
280+++ cmake/Click.cmake 1970-01-01 00:00:00 +0000
281@@ -1,17 +0,0 @@
282-if(CLICK_MODE)
283- STRING(REPLACE "/usr/" "/" QT_IMPORTS_DIR ${QT_IMPORTS_DIR})
284- set(CMAKE_INSTALL_PREFIX /)
285- set(CMAKE_INSTALL_BINDIR /)
286- set(DATA_DIR /)
287- set(EXEC "qmlscene $@ -I .${QT_IMPORTS_DIR} ${PAY-UI_DIR}/${MAIN_QML}")
288- set(DESKTOP_DIR ${DATA_DIR})
289- set(ICON ".${DATA_DIR}/${ICON}")
290- install(FILES manifest.json DESTINATION ${CMAKE_INSTALL_PREFIX})
291- install(DIRECTORY "app/graphics" DESTINATION ${DATA_DIR})
292- install(FILES "${CMAKE_PROJECT_NAME}.json" DESTINATION ${DATA_DIR})
293-else(CLICK_MODE)
294- set(DATA_DIR ${CMAKE_INSTALL_DATADIR}/${APP_NAME})
295- set(EXEC "qmlscene $@ ${CMAKE_INSTALL_PREFIX}/${DATA_DIR}/qml/${MAIN_QML}")
296- set(ICON "${CMAKE_INSTALL_PREFIX}/${DATA_DIR}/${ICON}")
297- set(DESKTOP_DIR ${CMAKE_INSTALL_DATADIR}/applications)
298-endif(CLICK_MODE)
299
300=== renamed file 'manifest.json' => 'manifest.json.in'
301--- manifest.json 2015-02-05 20:42:52 +0000
302+++ manifest.json.in 2015-02-13 14:04:51 +0000
303@@ -2,7 +2,7 @@
304 "name": "com.canonical.payui",
305 "description": "UI for Pay Service",
306 "framework": "ubuntu-sdk-14.10-qml-dev3",
307- "architecture": "armhf",
308+ "architecture": "@PACKAGE_ARCH@",
309 "title": "PayUI",
310 "hooks": {
311 "payui": {
312@@ -11,6 +11,23 @@
313 "pay-ui": "payui_payui.desktop"
314 }
315 },
316- "version": "0.4.5",
317- "maintainer": "Ubuntu Appstore Developers <ubuntu-appstore-developers@lists.launchpad.net>"
318+ "version": "15.01.@BZR_REVNO@",
319+ "maintainer": "Ubuntu Appstore Developers <ubuntu-appstore-developers@lists.launchpad.net>",
320+ "x-source": {
321+ "vcs-bzr": "lp:pay-ui",
322+ "vcs-bzr-revno": "@BZR_REVNO@"
323+ },
324+ "x-test": {
325+ "autopilot": {
326+ "autopilot_module": "pay_ui",
327+ "depends": [
328+ "click",
329+ "libubuntuoneauth-2.0-0",
330+ "python3-fixtures",
331+ "python3-testtools",
332+ "qtdeclarative5-ubuntu-ui-toolkit-plugin",
333+ "ubuntu-sdk-libs"
334+ ]
335+ }
336+ }
337 }
338
339=== modified file 'payui_payui.desktop.in.in'
340--- payui_payui.desktop.in.in 2014-08-20 19:30:32 +0000
341+++ payui_payui.desktop.in.in 2015-02-13 14:04:51 +0000
342@@ -1,7 +1,7 @@
343 [Desktop Entry]
344 _Name=Pay UI
345 _Comment=The application for completing a purchase.
346-Exec=@EXEC@ --transparent %u
347+Exec=qmlscene $@ qml/payui.qml --transparent %u
348 Icon=graphics/credit_card@8.png
349 Terminal=false
350 Type=Application
351
352=== modified file 'tests/autopilot/pay_ui/tests/__init__.py'
353--- tests/autopilot/pay_ui/tests/__init__.py 2014-12-18 19:26:13 +0000
354+++ tests/autopilot/pay_ui/tests/__init__.py 2015-02-13 14:04:51 +0000
355@@ -14,14 +14,15 @@
356 # You should have received a copy of the GNU General Public License
357 # along with this program. If not, see <http://www.gnu.org/licenses/>.
358
359+import fixtures
360+import json
361 import os
362+import shutil
363+import subprocess
364 import tempfile
365-import shutil
366+import ubuntuuitoolkit as uutk
367
368-import fixtures
369-import ubuntuuitoolkit
370 from autopilot import testcase
371-from ubuntuuitoolkit import base
372
373
374 class BasePayUITestCase(testcase.AutopilotTestCase):
375@@ -49,7 +50,7 @@
376
377 def launch_application(self, build_dir=None, source_dir=None):
378 if build_dir is None:
379- self.launch_installed_app()
380+ return self.launch_click_package('com.canonical.payui')
381 else:
382 return self.launch_built_application(build_dir, source_dir)
383
384@@ -62,15 +63,52 @@
385 fixtures.EnvironmentVariable(
386 'QML2_IMPORT_PATH', newvalue=built_import_path))
387 main_qml_path = os.path.join(source_dir, 'app', 'payui.qml')
388- desktop_file_path = os.path.join(build_dir, 'app', 'payui.desktop')
389- app = self.launch_test_application(
390- base.get_qmlscene_launch_command(),
391+ desktop_file_path = os.path.join(build_dir, 'payui_payui.desktop')
392+ return self.launch_test_application(
393+ uutk.base.get_qmlscene_launch_command(),
394 main_qml_path,
395 '--desktop_file_hint={0}'.format(desktop_file_path),
396- app_type='qt',
397- emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
398-
399- return app
400+ '--transparent',
401+ 'purchase://com.example.testapp',
402+ app_type='qt',
403+ emulator_base=uutk.UbuntuUIToolkitCustomProxyObjectBase)
404+
405+ def launch_click_package(self, package):
406+ """Launch the payui from the installed click package."""
407+ installed_directory = self.get_installed_directory(package)
408+ qml_import_path = os.path.join(
409+ installed_directory,
410+ 'lib', self.get_arch_triplet())
411+ self.useFixture(
412+ fixtures.EnvironmentVariable(
413+ 'QML2_IMPORT_PATH', newvalue=qml_import_path))
414+ qml_file_path = os.path.join(
415+ installed_directory, 'qml', 'payui.qml')
416+ desktop_file_path = os.path.join(
417+ installed_directory, 'payui_payui.desktop')
418+ return self.launch_test_application(
419+ uutk.base.get_qmlscene_launch_command(),
420+ qml_file_path,
421+ '--desktop_file_hint=%s' % desktop_file_path,
422+ '--transparent',
423+ 'purchase://com.example.testapp',
424+ app_type='qt',
425+ emulator_base=uutk.UbuntuUIToolkitCustomProxyObjectBase)
426+
427+ def get_arch_triplet(self):
428+ """Return the dpkg-architecture triplet for shared objects."""
429+ triplet = subprocess.Popen(
430+ ['dpkg-architecture', '-qDEB_HOST_MULTIARCH'],
431+ stdout=subprocess.PIPE).communicate()[0].decode('utf8')
432+ return triplet.strip()
433+
434+ def get_installed_directory(self, package):
435+ """Return the installed path for %package."""
436+ manifest = json.loads(
437+ subprocess.Popen(
438+ ['click', 'info', package],
439+ stdout=subprocess.PIPE).communicate()[0].decode('utf8'))
440+ return manifest['_directory']
441
442 @property
443 def main_view(self):
444
445=== modified file 'tests/autopilot/pay_ui/tests/mock_server.py'
446--- tests/autopilot/pay_ui/tests/mock_server.py 2015-02-05 20:39:05 +0000
447+++ tests/autopilot/pay_ui/tests/mock_server.py 2015-02-13 14:04:51 +0000
448@@ -38,6 +38,7 @@
449 </html>"
450 """
451
452+
453 class MyHandler(BaseHTTPRequestHandler):
454
455 def do_HEAD(self):
456@@ -216,6 +217,7 @@
457 }
458 ]
459
460+
461 class MockServer:
462 def __init__(self):
463 server_address = ('', 0)
464@@ -231,7 +233,7 @@
465
466 def set_purchase_needs_cc_interaction(self):
467 # Real server returns path starting with / here, not full URL.
468- self.server.buy_cc_interaction = "/creditcard_interaction")
469+ self.server.buy_cc_interaction = "/creditcard_interaction"
470
471 def set_interaction_result_cancelled(self):
472 self.server.interaction_cancel = True
473
474=== modified file 'tests/autopilot/pay_ui/tests/test_pay_ui.py'
475--- tests/autopilot/pay_ui/tests/test_pay_ui.py 2015-02-06 19:16:42 +0000
476+++ tests/autopilot/pay_ui/tests/test_pay_ui.py 2015-02-13 14:04:51 +0000
477@@ -15,7 +15,6 @@
478 # along with this program. If not, see <http://www.gnu.org/licenses/>.
479
480 import fixtures
481-import time
482 import ubuntuuitoolkit
483 from testtools.matchers import Equals, NotEquals
484 from autopilot.matchers import Eventually
485@@ -60,6 +59,7 @@
486 self.assertThat(self.app_returncode(), Equals(1))
487
488 def test_basic_purchase(self):
489+ self.skipTest('Mouse clicks on buyButton not registering.')
490 self.type_text("passwordField", "password123")
491 self.tap('buyButton')
492 self.assertThat(self.app_returncode(), Equals(0))
493@@ -80,12 +80,14 @@
494 self.assertThat(payment_types.get_option_count, Eventually(Equals(3)))
495
496 def test_purchase_with_web_interaction_completed(self):
497+ self.skipTest('Mouse clicks on buyButton not registering.')
498 self.mock_server.set_purchase_needs_cc_interaction()
499 self.tap('buyButton')
500 self.tap('webView')
501 self.assertThat(self.app_returncode(), Equals(0))
502
503 def test_purchase_with_web_interaction_cancelled(self):
504+ self.skipTest('Mouse clicks on buyButton not registering.')
505 self.mock_server.set_purchase_needs_cc_interaction()
506 self.mock_server.set_interaction_result_cancelled()
507 self.tap('buyButton')

Subscribers

People subscribed via source and target branches

to all changes: