Merge lp:~nskaggs/help-app/functional-test-template into lp:help-app

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Daniel Holbach
Approved revision: 149
Merged at revision: 145
Proposed branch: lp:~nskaggs/help-app/functional-test-template
Merge into: lp:help-app
Diff against target: 157 lines (+129/-0)
4 files modified
HACKING (+16/-0)
internals/tests/functional/help_app/__init__.py (+14/-0)
internals/tests/functional/help_app/tests/__init__.py (+83/-0)
internals/tests/functional/help_app/tests/test_app_launch.py (+16/-0)
To merge this branch: bzr merge lp:~nskaggs/help-app/functional-test-template
Reviewer Review Type Date Requested Status
Daniel Holbach (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+260206@code.launchpad.net

Commit message

Add basic skeleton structure for adding functional tests

Description of the change

Add basic skeleton structure for adding functional tests

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

fix unwanted whitespace diffs

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
145. By Nicholas Skaggs

flake8 happiness

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel Holbach (dholbach) wrote :

Hum... do you know if a newer version of selenium is being put into Ubuntu too?

Revision history for this message
Daniel Holbach (dholbach) wrote :

This generally looks good, we might just want to add selenium to build-deps, etc and run it as part of the build.

review: Needs Information
Revision history for this message
Daniel Holbach (dholbach) wrote :
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Yes, the QA folks are trying to get properly updated packages into the archive so the ppa isn't needed.

I agree on running it as part of the build, and I'd also like to put the current tests into a 'unit' testing folder perhaps?

Revision history for this message
Daniel Holbach (dholbach) wrote :

Hum... where exactly would you like to move tests to?

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

internals/tests/*.py -> internals/tests/unit

Revision history for this message
Daniel Holbach (dholbach) wrote :

Is this going to make anything easier?

I had a bit of a hard time moving everything around because of imports and from which path certain scripts needed to be run.

Revision history for this message
Daniel Holbach (dholbach) wrote :

Please note: I'm not rejecting your idea, I'm just trying to understand which problem we're solving. :-)

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Yes, not in this MP regardless, lol. I guess I'll stop talking. This MP has everything in it I'd like to merge at the moment :-)

Revision history for this message
Daniel Holbach (dholbach) wrote :

In the HACKING doc, the "cd /...." command isn't quite right, ie remove the leading '/'.

Also: http://pastebin.ubuntu.com/11413858/

Would this also work with launching the 'web' version?

review: Needs Fixing
146. By Nicholas Skaggs

fix hacking guide

147. By Nicholas Skaggs

initial modification to add helper and multiple testsuites for web and app

148. By Nicholas Skaggs

initial version

149. By Nicholas Skaggs

flake8 happiness

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel Holbach (dholbach) wrote :

How can the two sets of tests (app vs web) be launched separately from each other?

review: Needs Information
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Yes, you can launch just app or web if you wish.

autopilot3 run help_app.tests.test_app_launch.LaunchTestApp
autopilot3 run help_app.tests.test_app_launch.LaunchTestWeb

However, this doesn't let you do

autopilot3 run help_app.tests.test_app
autopilot3 run help_app.tests.test_web

For that we would need to put them in separate source files. The downside is all the tests would end up in the same file.

Revision history for this message
Daniel Holbach (dholbach) wrote :

We had some code in the unit tests already to perform a 'web' or 'app' build in a tempdir already, so I attempted to make that available for the functional tests too, but it's not quite working yet... do you think you have some free cycles? lp:~dholbach/help-app/functional-test-template-improvements

Revision history for this message
Daniel Holbach (dholbach) wrote :

Coming to think of it... let's make this part of a separate bug.

review: Approve
Revision history for this message
Daniel Holbach (dholbach) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'HACKING'
2--- HACKING 2015-05-13 16:32:48 +0000
3+++ HACKING 2015-05-28 20:32:44 +0000
4@@ -163,6 +163,22 @@
5
6 make check
7
8+Functional (autopilot / selenium) tests
9+---------------------------------------
10+
11+Make sure that you have oxide-chromedriver and selenium installed:
12+
13+ sudo apt-get install oxideqt-chromedriver
14+ sudo apt-add-repository ppa:canonical-platform-qa/selenium
15+ sudo apt-get update
16+ sudo apt-get install python3-selenium
17+
18+Run the tests:
19+
20+ cd internals/tests/functional
21+ autopilot3 list help_app
22+ autopilot3 run help_app
23+
24 Debugging
25 ---------
26
27
28=== added directory 'internals/tests/functional'
29=== added directory 'internals/tests/functional/help_app'
30=== added file 'internals/tests/functional/help_app/__init__.py'
31--- internals/tests/functional/help_app/__init__.py 1970-01-01 00:00:00 +0000
32+++ internals/tests/functional/help_app/__init__.py 2015-05-28 20:32:44 +0000
33@@ -0,0 +1,14 @@
34+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
35+
36+
37+class HelpApp(object):
38+
39+ """Autopilot helper object for the help app."""
40+
41+ def __init__(self, app_proxy):
42+ self.app = app_proxy
43+ self.webview = self.app.select_single('UbuntuWebView02')
44+
45+ @property
46+ def pointing_device(self):
47+ return self.app.pointing_device
48
49=== added directory 'internals/tests/functional/help_app/tests'
50=== added file 'internals/tests/functional/help_app/tests/__init__.py'
51--- internals/tests/functional/help_app/tests/__init__.py 1970-01-01 00:00:00 +0000
52+++ internals/tests/functional/help_app/tests/__init__.py 2015-05-28 20:32:44 +0000
53@@ -0,0 +1,83 @@
54+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
55+
56+""" Autopilot tests """
57+
58+import os
59+import subprocess
60+
61+from help_app import HelpApp
62+
63+from selenium import webdriver
64+from selenium.webdriver.chrome.options import Options
65+
66+import ubuntuuitoolkit as uitk
67+from ubuntuuitoolkit import fixture_setup
68+
69+from autopilot import platform
70+from autopilot.testcase import AutopilotTestCase
71+
72+CURRENT_ARCHITECTURE = subprocess.check_output(
73+ ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip()
74+CHROMEDRIVER_EXEC_PATH = \
75+ "/usr/lib/{}/oxide-qt/chromedriver".format(
76+ CURRENT_ARCHITECTURE.decode("utf-8"))
77+DEFAULT_WEBVIEW_INSPECTOR_IP = '127.0.0.1'
78+DEFAULT_WEBVIEW_INSPECTOR_PORT = 9221
79+
80+
81+class HTML5TestCaseBase(AutopilotTestCase):
82+ def setUp(self):
83+ super(HTML5TestCaseBase, self).setUp()
84+ if platform.model() == 'Desktop':
85+ self.patch_environment(
86+ 'UBUNTU_WEBVIEW_DEVTOOLS_HOST',
87+ DEFAULT_WEBVIEW_INSPECTOR_IP)
88+ self.patch_environment(
89+ 'UBUNTU_WEBVIEW_DEVTOOLS_PORT',
90+ str(DEFAULT_WEBVIEW_INSPECTOR_PORT))
91+ else:
92+ self.useFixture(fixture_setup.InitctlEnvironmentVariable(
93+ global_=True,
94+ UBUNTU_WEBVIEW_DEVTOOLS_HOST=DEFAULT_WEBVIEW_INSPECTOR_IP,
95+ UBUNTU_WEBVIEW_DEVTOOLS_PORT=str(
96+ DEFAULT_WEBVIEW_INSPECTOR_PORT)
97+ ))
98+
99+ def launch_webdriver(self):
100+ options = Options()
101+ options.binary_location = ''
102+ options.debugger_address = '{}:{}'.format(
103+ DEFAULT_WEBVIEW_INSPECTOR_IP,
104+ DEFAULT_WEBVIEW_INSPECTOR_PORT)
105+
106+ return webdriver.Chrome(
107+ executable_path=CHROMEDRIVER_EXEC_PATH,
108+ chrome_options=options)
109+
110+ def launch_app(self, path):
111+ return self.launch_test_application(
112+ 'ubuntu-html5-app-launcher',
113+ '--www={}/{}'.format(
114+ os.path.dirname(
115+ os.path.realpath(__file__)), path),
116+ emulator_base=uitk.UbuntuUIToolkitCustomProxyObjectBase)
117+
118+
119+class HelpAppTest(HTML5TestCaseBase):
120+
121+ """Testcase that launches the help app"""
122+
123+ def setUp(self):
124+ super(HelpAppTest, self).setUp()
125+ self.app = HelpApp(self.launch_app('../../../../../build/app/www'))
126+ self.driver = self.launch_webdriver()
127+
128+
129+class HelpWebTest(HTML5TestCaseBase):
130+
131+ """Testcase that launches the help web version"""
132+
133+ def setUp(self):
134+ super(HelpWebTest, self).setUp()
135+ self.app = HelpApp(self.launch_app('../../../../../build/web/www'))
136+ self.driver = self.launch_webdriver()
137
138=== added file 'internals/tests/functional/help_app/tests/test_app_launch.py'
139--- internals/tests/functional/help_app/tests/test_app_launch.py 1970-01-01 00:00:00 +0000
140+++ internals/tests/functional/help_app/tests/test_app_launch.py 2015-05-28 20:32:44 +0000
141@@ -0,0 +1,16 @@
142+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
143+
144+from help_app.tests import HelpAppTest, HelpWebTest
145+from testtools.matchers import NotEquals
146+
147+
148+class LaunchTestApp(HelpAppTest):
149+
150+ def test_basic_launch(self):
151+ self.assertThat(self.app, NotEquals(None))
152+
153+
154+class LaunchTestWeb(HelpWebTest):
155+
156+ def test_basic_launch(self):
157+ self.assertThat(self.app, NotEquals(None))

Subscribers

People subscribed via source and target branches