Merge lp:~elopio/webapps-demo/fix_autopilot_tests into lp:webapps-demo

Proposed by Leo Arias
Status: Needs review
Proposed branch: lp:~elopio/webapps-demo/fix_autopilot_tests
Merge into: lp:webapps-demo
Diff against target: 113 lines (+4/-54)
3 files modified
tests/autopilot/webapps_click_packages_autopilot/emulators/__init__.py (+0/-8)
tests/autopilot/webapps_click_packages_autopilot/tests/__init__.py (+4/-36)
tests/autopilot/webapps_click_packages_autopilot/tests/test_click_packages.py (+0/-10)
To merge this branch: bzr merge lp:~elopio/webapps-demo/fix_autopilot_tests
Reviewer Review Type Date Requested Status
Víctor R. Ruiz (community) Approve
Alexandre Abreu (community) Approve
PS Jenkins bot continuous-integration Approve
Allan LeSage Pending
Richard Huddie Pending
Ubuntu Phablet Team Pending
Review via email: mp+212529@code.launchpad.net

Commit message

Update the autopilot tests.

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

This is the smallest possible diff to get the tests passing. There's still some cleaning and improvements to do.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

LGTM & works on N4

review: Approve
Revision history for this message
Víctor R. Ruiz (vrruiz) wrote :

Looks good to me.

review: Approve

Unmerged revisions

41. By Leo Arias

No need for tear down, autopilot kills the apps.

40. By Leo Arias

Removed unused imports.

39. By Leo Arias

Changed the name of the webview class.

38. By Leo Arias

Removed the unused code.

37. By Leo Arias

Assign the app proxy.

36. By Leo Arias

Use autopilot's launch_click_package.

35. By Leo Arias

Removed all the unused stuff.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed directory 'tests/autopilot/webapps_click_packages_autopilot/emulators'
2=== removed file 'tests/autopilot/webapps_click_packages_autopilot/emulators/__init__.py'
3--- tests/autopilot/webapps_click_packages_autopilot/emulators/__init__.py 2013-10-10 17:47:30 +0000
4+++ tests/autopilot/webapps_click_packages_autopilot/emulators/__init__.py 1970-01-01 00:00:00 +0000
5@@ -1,8 +0,0 @@
6-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
7-# Copyright 2013 Canonical
8-#
9-# This program is free software: you can redistribute it and/or modify it
10-# under the terms of the GNU General Public License version 3, as published
11-# by the Free Software Foundation.
12-
13-""" webapps-click-packages-autopilot autopilot tests and emulators - top level package."""
14
15=== modified file 'tests/autopilot/webapps_click_packages_autopilot/tests/__init__.py'
16--- tests/autopilot/webapps_click_packages_autopilot/tests/__init__.py 2014-01-08 15:44:03 +0000
17+++ tests/autopilot/webapps_click_packages_autopilot/tests/__init__.py 2014-03-25 02:51:31 +0000
18@@ -12,13 +12,9 @@
19 import subprocess
20 import re
21
22-from testtools.matchers import Contains, Equals, GreaterThan, NotEquals
23-from autopilot.matchers import Eventually
24+from testtools.matchers import NotEquals
25
26 from autopilot.testcase import AutopilotTestCase
27-from autopilot.introspection import get_proxy_object_for_existing_process
28-
29-from autopilot import platform
30
31
32 def get_click_packages_list():
33@@ -27,7 +23,7 @@
34 if output and len(output) != 0:
35 return output.split('\n')
36 return []
37-
38+
39 def get_pid_for_appid(app_id):
40 command = "ps -ef"
41 output, errors = subprocess.Popen(["-c", command], stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True).communicate()
42@@ -40,50 +36,22 @@
43 return pid
44
45 class WebappsClickPackagesTestCaseBase(AutopilotTestCase):
46- def launch_click_with_appid(self, app_id):
47- os.system('/sbin/initctl set-env QT_LOAD_TESTABILITY=1; start application APP_ID={0}'.format(app_id))
48- self.app_id = app_id
49- self.assertThat(lambda: get_pid_for_appid(app_id), Eventually(NotEquals("")))
50-
51- def update_autopilot_proxy_for_pid(self, pid):
52- self.app_proxy = None
53- for x in range(10):
54- self.app_proxy = get_proxy_object_for_existing_process(pid=int(pid))
55- if not self.app_proxy is None:
56- break
57- sleep(1000)
58- self.assertThat(x, NotEquals(9))
59- self.assertThat(self.app_proxy, NotEquals(None))
60
61 def validate_url_for_current_proxy(self):
62 self.assertThat(self.app_proxy, NotEquals(None))
63- webviews = self.app_proxy.select_many('UbuntuWebView')
64+ webviews = self.app_proxy.select_many('WebViewImpl')
65 self.assertThat(len(webviews), NotEquals(0))
66 self.assertThat(webviews[0].url, NotEquals(""))
67
68- def get_app_version(self, app_id):
69- clicks = get_click_packages_list()
70- click_infos = [package for package in clicks if package.find(app_id) != -1][0].split()
71- return click_infos[1]
72-
73 def validate_click_app_exists(self, package_name):
74 clicks = get_click_packages_list()
75 self.assertThat(len([package for package in clicks if package.find(package_name) != -1]), NotEquals(0))
76
77 def validate_app_launch(self, package_name, app_name):
78 self.validate_click_app_exists(package_name)
79- app_version = self.get_app_version(package_name)
80- full_app_id = "{0}_{1}_{2}".format(package_name, app_name, app_version)
81- self.launch_click_with_appid(full_app_id)
82- pid = get_pid_for_appid(package_name)
83- self.update_autopilot_proxy_for_pid(pid)
84+ self.app_proxy = self.launch_click_package(package_name, app_name)
85 self.validate_url_for_current_proxy()
86
87 def setUp(self):
88 self.app_id = None
89 super(WebappsClickPackagesTestCaseBase, self).setUp()
90-
91- def tearDown(self):
92- if not self.app_id is None:
93- os.system('stop application APP_ID={0}'.format(self.app_id))
94- super(WebappsClickPackagesTestCaseBase, self).tearDown()
95
96=== modified file 'tests/autopilot/webapps_click_packages_autopilot/tests/test_click_packages.py'
97--- tests/autopilot/webapps_click_packages_autopilot/tests/test_click_packages.py 2013-10-11 15:52:27 +0000
98+++ tests/autopilot/webapps_click_packages_autopilot/tests/test_click_packages.py 2014-03-25 02:51:31 +0000
99@@ -12,16 +12,6 @@
100 # under the terms of the GNU General Public License version 3, as published
101 # by the Free Software Foundation.
102
103-import os
104-import time
105-
106-from testtools.matchers import Equals, GreaterThan, NotEquals
107-from testtools import skipUnless
108-
109-from autopilot.matchers import Eventually
110-
111-from autopilot import platform
112-
113 from webapps_click_packages_autopilot.tests import WebappsClickPackagesTestCaseBase
114
115

Subscribers

People subscribed via source and target branches

to all changes: