Merge lp:~abreu-alexandre/webapps-core/webapps-core-tests-click into lp:webapps-core
- webapps-core-tests-click
- Merge into trunk
Proposed by
Alexandre Abreu
| Status: | Needs review | ||||
|---|---|---|---|---|---|
| Proposed branch: | lp:~abreu-alexandre/webapps-core/webapps-core-tests-click | ||||
| Merge into: | lp:webapps-core | ||||
| Diff against target: |
1442 lines (+1321/-2) 17 files modified
debian/control (+19/-2) tests/unittests/CMakeLists.txt (+1/-0) tests/unittests/flake8/CMakeLists.txt (+1/-0) webapp-ebay/tests/autopilot/ebay_webapp/__init_.py (+162/-0) webapp-ebay/tests/autopilot/ebay_webapp/test_ebay_webapp.py (+21/-0) webapp-facebook/tests/autopilot/facebook_webapp/__init__.py (+130/-0) webapp-facebook/tests/autopilot/facebook_webapp/test_facebook.py (+72/-0) webapp-gmail/tests/autopilot/gmail_webapp/__init_.py (+162/-0) webapp-gmail/tests/autopilot/gmail_webapp/test_gmail_webapp.py (+21/-0) webapp-googlecalendar/tests/autopilot/googlecalendar_webapp/__init_.py (+162/-0) webapp-googlecalendar/tests/autopilot/googlecalendar_webapp/test_googlecalendar_webapp.py (+21/-0) webapp-googlemaps/tests/autopilot/googlemaps_webapp/__init_.py (+162/-0) webapp-googlemaps/tests/autopilot/googlemaps_webapp/test_googlemaps_webapp.py (+21/-0) webapp-googleplus/tests/autopilot/googleplus_webapp/__init_.py (+162/-0) webapp-googleplus/tests/autopilot/googleplus_webapp/test_googleplus_webapp.py (+21/-0) webapp-twitter/tests/autopilot/twitter_webapp/__init_.py (+162/-0) webapp-twitter/tests/autopilot/twitter_webapp/test_twitter_webapp.py (+21/-0) |
||||
| To merge this branch: | bzr merge lp:~abreu-alexandre/webapps-core/webapps-core-tests-click | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Ubuntu Phablet Team | Pending | ||
|
Review via email:
|
|||
Commit message
Individual tests for webapps
Description of the change
Individual tests for webapps
To post a comment you must log in.
Unmerged revisions
- 119. By Alexandre Abreu
-
Individual click packages for webapp tests
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
| 1 | === modified file 'debian/control' |
| 2 | --- debian/control 2013-09-27 13:51:02 +0000 |
| 3 | +++ debian/control 2015-07-13 15:30:05 +0000 |
| 4 | @@ -3,8 +3,10 @@ |
| 5 | Priority: extra |
| 6 | Maintainer: Ubuntu Developers <[email protected]> |
| 7 | XSBC-Original-Maintainer: Ricardo Mendoza <[email protected]> |
| 8 | -Build-Depends: debhelper (>= 9.0.0), |
| 9 | - click |
| 10 | +Build-Depends: cmake (>= 2.8.9), |
| 11 | + debhelper (>= 9.0.0), |
| 12 | + click, |
| 13 | + python-flake8 |
| 14 | Standards-Version: 3.9.3 |
| 15 | Vcs-Bzr: lp:webapps-demo |
| 16 | |
| 17 | @@ -22,3 +24,18 @@ |
| 18 | This package contains click packages that will are pre-installed |
| 19 | in the base image. |
| 20 | |
| 21 | +Package: webapps-core-autopilot |
| 22 | +Architecture: all |
| 23 | +Depends: ${shlibs:Depends}, |
| 24 | + ${misc:Depends}, |
| 25 | + dpkg-dev, |
| 26 | + autopilot-touch, |
| 27 | + libqt5test5, |
| 28 | + liboxideqt-qmlplugin (>= 1.4), |
| 29 | + oxideqt-chromedriver, |
| 30 | + python-selenium |
| 31 | +Description: Autopilot tests for the Default web applications set (as click packages) |
| 32 | + Default web applications set, to demonstrate the integration |
| 33 | + of popuplar web services on Ubuntu. |
| 34 | + This package contains click packages that will are pre-installed |
| 35 | + in the base image. |
| 36 | |
| 37 | === added directory 'tests' |
| 38 | === added directory 'tests/unittests' |
| 39 | === added file 'tests/unittests/CMakeLists.txt' |
| 40 | --- tests/unittests/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
| 41 | +++ tests/unittests/CMakeLists.txt 2015-07-13 15:30:05 +0000 |
| 42 | @@ -0,0 +1,1 @@ |
| 43 | +add_subdirectory(flake8) |
| 44 | \ No newline at end of file |
| 45 | |
| 46 | === added directory 'tests/unittests/flake8' |
| 47 | === added file 'tests/unittests/flake8/CMakeLists.txt' |
| 48 | --- tests/unittests/flake8/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
| 49 | +++ tests/unittests/flake8/CMakeLists.txt 2015-07-13 15:30:05 +0000 |
| 50 | @@ -0,0 +1,1 @@ |
| 51 | +add_test(flake8 flake8 ${autopilot-tests_SOURCE_DIR}) |
| 52 | |
| 53 | === added directory 'webapp-ebay/tests' |
| 54 | === added directory 'webapp-ebay/tests/autopilot' |
| 55 | === added directory 'webapp-ebay/tests/autopilot/ebay_webapp' |
| 56 | === added file 'webapp-ebay/tests/autopilot/ebay_webapp/__init_.py' |
| 57 | --- webapp-ebay/tests/autopilot/ebay_webapp/__init_.py 1970-01-01 00:00:00 +0000 |
| 58 | +++ webapp-ebay/tests/autopilot/ebay_webapp/__init_.py 2015-07-13 15:30:05 +0000 |
| 59 | @@ -0,0 +1,162 @@ |
| 60 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 61 | + |
| 62 | +# |
| 63 | +# Ubuntu Core Webapps |
| 64 | +# Copyright (C) 2015 Canonical |
| 65 | +# |
| 66 | +# This program is free software: you can redistribute it and/or modify |
| 67 | +# it under the terms of the GNU General Public License as published by |
| 68 | +# the Free Software Foundation, either version 3 of the License, or |
| 69 | +# (at your option) any later version. |
| 70 | +# |
| 71 | +# This program is distributed in the hope that it will be useful, |
| 72 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 73 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 74 | +# GNU General Public License for more details. |
| 75 | +# |
| 76 | +# You should have received a copy of the GNU General Public License |
| 77 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 78 | +# |
| 79 | + |
| 80 | +import contextlib |
| 81 | +import logging |
| 82 | +import os |
| 83 | +import shutil |
| 84 | +import subprocess |
| 85 | + |
| 86 | +from autopilot import ( |
| 87 | + get_test_configuration, |
| 88 | + testcase |
| 89 | +) |
| 90 | + |
| 91 | +from selenium import webdriver |
| 92 | +from selenium.webdriver.chrome import options |
| 93 | +from ubuntuuitoolkit import fixture_setup |
| 94 | + |
| 95 | +import autopilot.logging |
| 96 | +from autopilot import platform |
| 97 | + |
| 98 | +logger = logging.getLogger(__name__) |
| 99 | + |
| 100 | +DESKTOP_FILE_NAME = 'webapp-ebay.desktop' |
| 101 | + |
| 102 | +DEFAULT_IMPLICIT_WAIT = 10 # seconds |
| 103 | + |
| 104 | + |
| 105 | +def get_source_desktop_file_path(): |
| 106 | + return os.path.join( |
| 107 | + os.path.dirname(__file__), '..', '..', '..', |
| 108 | + DESKTOP_FILE_NAME) |
| 109 | + |
| 110 | + |
| 111 | +def get_local_desktop_file_directory(): |
| 112 | + return os.path.join( |
| 113 | + os.environ.get('HOME'), '.local', 'share', 'applications') |
| 114 | + |
| 115 | + |
| 116 | +def get_chrome_driver_path(): |
| 117 | + env = os.environ.copy() |
| 118 | + readonly_dependencies_path = get_readonly_dependencies_path() |
| 119 | + if readonly_dependencies_path: |
| 120 | + # XXX When running with adt-run, this is needed if the image is |
| 121 | + # read-only so we can find the chromium driver path. |
| 122 | + env['PERL5LIB'] = os.path.join( |
| 123 | + readonly_dependencies_path, 'usr', 'share', 'perl5') |
| 124 | + |
| 125 | + architecture = subprocess.check_output( |
| 126 | + ['dpkg-architecture', '-qDEB_HOST_MULTIARCH'], |
| 127 | + env=env, universal_newlines=True).strip() |
| 128 | + |
| 129 | + chrome_driver_path = '/usr/lib/{}/oxide-qt/chromedriver'.format( |
| 130 | + architecture) |
| 131 | + |
| 132 | + if readonly_dependencies_path and not os.path.exists(chrome_driver_path): |
| 133 | + # Try the read-only install path. |
| 134 | + chrome_driver_path = os.path.join( |
| 135 | + readonly_dependencies_path, chrome_driver_path.lstrip('/')) |
| 136 | + |
| 137 | + return chrome_driver_path |
| 138 | + |
| 139 | + |
| 140 | +def get_readonly_dependencies_path(): |
| 141 | + adt_artifacts_path = os.environ.get('ADT_ARTIFACTS', None) |
| 142 | + if adt_artifacts_path: |
| 143 | + return os.path.join(os.path.dirname(adt_artifacts_path), 'deps') |
| 144 | + else: |
| 145 | + return None |
| 146 | + |
| 147 | + |
| 148 | +class EbayWebappTestCase(testcase.AutopilotTestCase): |
| 149 | + |
| 150 | + DEFAULT_WEBVIEW_INSPECTOR_IP = '127.0.0.1' |
| 151 | + DEFAULT_WEBVIEW_INSPECTOR_PORT = 9221 |
| 152 | + |
| 153 | + def __init__(self, proxy, driver): |
| 154 | + """Initialize the page object. |
| 155 | + |
| 156 | + :param proxy: The autopilot application proxy. |
| 157 | + :param driver: The webdriver used to introspect and control the web |
| 158 | + container. |
| 159 | + |
| 160 | + """ |
| 161 | + super().__init__() |
| 162 | + self.proxy = proxy |
| 163 | + self.driver = driver |
| 164 | + |
| 165 | + def get_container_proxy(self): |
| 166 | + return self.proxy.select_single('WebappContainerWebview') |
| 167 | + |
| 168 | + def setUp(self): |
| 169 | + super().setUp() |
| 170 | + self.setup_webdriver_environment() |
| 171 | + |
| 172 | + def setup_webdriver_environment(self): |
| 173 | + self.useFixture(fixture_setup.InitctlEnvironmentVariable( |
| 174 | + global_=True, |
| 175 | + UBUNTU_WEBVIEW_DEVTOOLS_HOST=self.DEFAULT_WEBVIEW_INSPECTOR_IP, |
| 176 | + UBUNTU_WEBVIEW_DEVTOOLS_PORT=str( |
| 177 | + self.DEFAULT_WEBVIEW_INSPECTOR_PORT) |
| 178 | + )) |
| 179 | + |
| 180 | + def validate_title(self, title): |
| 181 | + window = self.get_webcontainer_proxy() |
| 182 | + self.assertThat( |
| 183 | + lambda: window.title.lower(), |
| 184 | + Eventually(Contains(title.lower()))) |
| 185 | + |
| 186 | + def launch_application(self): |
| 187 | + if (get_test_configuration().get('from_source', None) and |
| 188 | + os.path.exists(get_source_desktop_file_path())): |
| 189 | + return self.launch_application_from_source() |
| 190 | + else: |
| 191 | + return self.launch_installed_application() |
| 192 | + |
| 193 | + def launch_application_from_source(self): |
| 194 | + test_desktop_file_path = os.path.join( |
| 195 | + get_local_desktop_file_directory(), 'webapps-test.desktop') |
| 196 | + shutil.copy(get_source_desktop_file_path(), test_desktop_file_path) |
| 197 | + self.addCleanup(os.remove, test_desktop_file_path) |
| 198 | + |
| 199 | + return self.launch_upstart_application('webapps-test') |
| 200 | + |
| 201 | + def get_webdriver(self): |
| 202 | + driver_options = options.Options() |
| 203 | + driver_options.binary_location = '' |
| 204 | + driver_options.debugger_address = '{}:{}'.format( |
| 205 | + self.DEFAULT_WEBVIEW_INSPECTOR_IP, |
| 206 | + self.DEFAULT_WEBVIEW_INSPECTOR_PORT) |
| 207 | + driver = webdriver.Chrome( |
| 208 | + executable_path=get_chrome_driver_path(), |
| 209 | + chrome_options=driver_options |
| 210 | + ) |
| 211 | + |
| 212 | + self.assertIsNot(driver, None) |
| 213 | + |
| 214 | + self.addCleanup(self.close_webdriver, driver) |
| 215 | + |
| 216 | + driver.implicitly_wait(DEFAULT_IMPLICIT_WAIT) |
| 217 | + return driver |
| 218 | + |
| 219 | + def close_webdriver(self, driver): |
| 220 | + driver.close() |
| 221 | + driver.quit() |
| 222 | |
| 223 | === added file 'webapp-ebay/tests/autopilot/ebay_webapp/test_ebay_webapp.py' |
| 224 | --- webapp-ebay/tests/autopilot/ebay_webapp/test_ebay_webapp.py 1970-01-01 00:00:00 +0000 |
| 225 | +++ webapp-ebay/tests/autopilot/ebay_webapp/test_ebay_webapp.py 2015-07-13 15:30:05 +0000 |
| 226 | @@ -0,0 +1,21 @@ |
| 227 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 228 | +# Copyright 2014 Canonical |
| 229 | +# |
| 230 | +# This program is free software: you can redistribute it and/or modify it |
| 231 | +# under the terms of the GNU General Public License version 3, as published |
| 232 | +# by the Free Software Foundation. |
| 233 | + |
| 234 | +from autopilot import platform |
| 235 | +from testtools import skipUnless |
| 236 | + |
| 237 | +import ebay_webapp |
| 238 | + |
| 239 | +class ClickWebappsLaunchTestCaseBase(EbayWebappTestCase): |
| 240 | + def setUp(self): |
| 241 | + super(ClickWebappsLaunchTestCaseBase, self).setUp() |
| 242 | + |
| 243 | + def test_launch_ebay(self): |
| 244 | + proxy = self.launch_application() |
| 245 | + driver = self.get_webdriver() |
| 246 | + |
| 247 | + self.validate_title('ebay') |
| 248 | |
| 249 | === added directory 'webapp-facebook/tests' |
| 250 | === added directory 'webapp-facebook/tests/autopilot' |
| 251 | === added directory 'webapp-facebook/tests/autopilot/facebook_webapp' |
| 252 | === added file 'webapp-facebook/tests/autopilot/facebook_webapp/__init__.py' |
| 253 | --- webapp-facebook/tests/autopilot/facebook_webapp/__init__.py 1970-01-01 00:00:00 +0000 |
| 254 | +++ webapp-facebook/tests/autopilot/facebook_webapp/__init__.py 2015-07-13 15:30:05 +0000 |
| 255 | @@ -0,0 +1,130 @@ |
| 256 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 257 | + |
| 258 | +# |
| 259 | +# Ubuntu Core Webapps |
| 260 | +# Copyright (C) 2015 Canonical |
| 261 | +# |
| 262 | +# This program is free software: you can redistribute it and/or modify |
| 263 | +# it under the terms of the GNU General Public License as published by |
| 264 | +# the Free Software Foundation, either version 3 of the License, or |
| 265 | +# (at your option) any later version. |
| 266 | +# |
| 267 | +# This program is distributed in the hope that it will be useful, |
| 268 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 269 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 270 | +# GNU General Public License for more details. |
| 271 | +# |
| 272 | +# You should have received a copy of the GNU General Public License |
| 273 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 274 | +# |
| 275 | + |
| 276 | +import subprocess |
| 277 | + |
| 278 | +from selenium import webdriver |
| 279 | +from selenium.webdriver.chrome.options import Options |
| 280 | + |
| 281 | +import ubuntuuitoolkit as uitk |
| 282 | + |
| 283 | +from testtools.matchers import Contains, NotEquals |
| 284 | +from autopilot.matchers import Eventually |
| 285 | +from autopilot.platform import model |
| 286 | +from autopilot import platform |
| 287 | + |
| 288 | +from autopilot.testcase import AutopilotTestCase |
| 289 | + |
| 290 | +CURRENT_ARCHITECTURE = subprocess.check_output( |
| 291 | + ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip() |
| 292 | +CHROMEDRIVER_EXEC_PATH = \ |
| 293 | + "/usr/lib/{}/oxide-qt/chromedriver".format(CURRENT_ARCHITECTURE) |
| 294 | +DEFAULT_WEBVIEW_INSPECTOR_IP = '127.0.0.1' |
| 295 | +DEFAULT_WEBVIEW_INSPECTOR_PORT = 9221 |
| 296 | + |
| 297 | + |
| 298 | +class WebappsCoreTestCaseBase(AutopilotTestCase): |
| 299 | + def setUp(self): |
| 300 | + self.driver = None |
| 301 | + self.app_proxy = None |
| 302 | + super(WebappsCoreTestCaseBase, self).setUp() |
| 303 | + |
| 304 | + def tearDown(self): |
| 305 | + if self.driver: |
| 306 | + self.page.close() |
| 307 | + self.page.quit() |
| 308 | + # XXX: This should not be there but AP hangs |
| 309 | + # if we dont extra force the process to be killed |
| 310 | + # (although AP already tries to kill part of its teardown) |
| 311 | + if platform.model() == 'Desktop' and self.app_proxy and self.app_proxy.process: |
| 312 | + self.app_proxy.process.kill() |
| 313 | + super(WebappsCoreTestCaseBase, self).tearDown() |
| 314 | + |
| 315 | + def get_webview(self): |
| 316 | + return self.app_proxy.select_single(objectName="webview") |
| 317 | + |
| 318 | + def get_oxide_webview(self): |
| 319 | + container = self.get_webview().select_single( |
| 320 | + objectName='containerWebviewLoader') |
| 321 | + return container.wait_select_single('WebViewImplOxide') |
| 322 | + |
| 323 | + def launch_webdriver(self, ip, port): |
| 324 | + options = Options() |
| 325 | + options.binary_location = '' |
| 326 | + options.debugger_address = '{}:{}'.format(ip, port) |
| 327 | + |
| 328 | + self.driver = webdriver.Chrome( |
| 329 | + executable_path=CHROMEDRIVER_EXEC_PATH, |
| 330 | + chrome_options=options) |
| 331 | + self.assertThat(self.driver, NotEquals(None)) |
| 332 | + |
| 333 | + @property |
| 334 | + def page(self): |
| 335 | + return self.driver |
| 336 | + |
| 337 | + def launch_webcontainer_app(self, args): |
| 338 | + return self.launch_test_application( |
| 339 | + 'webapp-container', |
| 340 | + *args, |
| 341 | + emulator_base=uitk.UbuntuUIToolkitCustomProxyObjectBase) |
| 342 | + |
| 343 | + def launch_webapp( |
| 344 | + self, |
| 345 | + package_id, |
| 346 | + app_name, |
| 347 | + with_chrome_driver=False, |
| 348 | + envvars={}, |
| 349 | + ip=DEFAULT_WEBVIEW_INSPECTOR_IP, |
| 350 | + port=DEFAULT_WEBVIEW_INSPECTOR_PORT, |
| 351 | + homepage=''): |
| 352 | + |
| 353 | + # setup devtools environment |
| 354 | + self.patch_environment( |
| 355 | + 'UBUNTU_WEBVIEW_DEVTOOLS_HOST', |
| 356 | + ip) |
| 357 | + self.patch_environment( |
| 358 | + 'UBUNTU_WEBVIEW_DEVTOOLS_PORT', |
| 359 | + str(port)) |
| 360 | + |
| 361 | + if envvars: |
| 362 | + for envvar_key in envvars: |
| 363 | + self.patch_environment(envvar_key, envvars[envvar_key]) |
| 364 | + |
| 365 | + if model() == 'Desktop': |
| 366 | + self.app_proxy = self.launch_webcontainer_app( |
| 367 | + [homepage]) |
| 368 | + else: |
| 369 | + self.app_proxy = self.launch_click_package( |
| 370 | + package_id) |
| 371 | + self.validate_url_for_current_proxy() |
| 372 | + |
| 373 | + if with_chrome_driver: |
| 374 | + self.launch_webdriver(ip, port) |
| 375 | + |
| 376 | + def validate_url_for_current_proxy(self): |
| 377 | + self.assertThat(self.app_proxy, NotEquals(None)) |
| 378 | + webview = self.get_webview() |
| 379 | + self.assertThat(webview.url, NotEquals("")) |
| 380 | + |
| 381 | + def validate_title(self, title): |
| 382 | + window = self.get_webcontainer_window() |
| 383 | + self.assertThat( |
| 384 | + lambda: window.title.lower(), |
| 385 | + Eventually(Contains(title.lower()))) |
| 386 | |
| 387 | === added file 'webapp-facebook/tests/autopilot/facebook_webapp/test_facebook.py' |
| 388 | --- webapp-facebook/tests/autopilot/facebook_webapp/test_facebook.py 1970-01-01 00:00:00 +0000 |
| 389 | +++ webapp-facebook/tests/autopilot/facebook_webapp/test_facebook.py 2015-07-13 15:30:05 +0000 |
| 390 | @@ -0,0 +1,72 @@ |
| 391 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 392 | + |
| 393 | +# |
| 394 | +# Ubuntu Core Webapps |
| 395 | +# Copyright (C) 2015 Canonical |
| 396 | +# |
| 397 | +# This program is free software: you can redistribute it and/or modify |
| 398 | +# it under the terms of the GNU General Public License as published by |
| 399 | +# the Free Software Foundation, either version 3 of the License, or |
| 400 | +# (at your option) any later version. |
| 401 | +# |
| 402 | +# This program is distributed in the hope that it will be useful, |
| 403 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 404 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 405 | +# GNU General Public License for more details. |
| 406 | +# |
| 407 | +# You should have received a copy of the GNU General Public License |
| 408 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 409 | +# |
| 410 | + |
| 411 | +from webapps_core.tests import WebappsCoreTestCaseBase |
| 412 | + |
| 413 | +from testtools.matchers import NotEquals, GreaterThan |
| 414 | +from autopilot.matchers import Eventually |
| 415 | + |
| 416 | + |
| 417 | +class ClickWebappsLaunchTestCaseBase(WebappsCoreTestCaseBase): |
| 418 | + def setUp(self): |
| 419 | + super(ClickWebappsLaunchTestCaseBase, self).setUp() |
| 420 | + |
| 421 | + def test_click_photo(self): |
| 422 | + package_name = 'com.ubuntu.developer.webapps.webapp-facebook' |
| 423 | + app_name = 'webapp-facebook' |
| 424 | + self.launch_webapp( |
| 425 | + package_name, |
| 426 | + app_name, |
| 427 | + True, |
| 428 | + homepage='https://m.facebook.com') |
| 429 | + photo_button = self.page.find_element_by_css_selector( |
| 430 | + "button[data-sigil~='photo_link']") |
| 431 | + self.assertThat(photo_button, NotEquals(None)) |
| 432 | + |
| 433 | + photo_button.click() |
| 434 | + |
| 435 | + post_button = self.page.find_element_by_css_selector( |
| 436 | + "button[type='submit']") |
| 437 | + self.assertThat(post_button, NotEquals(None)) |
| 438 | + |
| 439 | + def test_redirect_url(self): |
| 440 | + package_name = 'com.ubuntu.developer.webapps.webapp-facebook' |
| 441 | + app_name = 'webapp-facebook' |
| 442 | + self.launch_webapp( |
| 443 | + package_name, |
| 444 | + app_name, |
| 445 | + True, |
| 446 | + {'WEBAPP_CONTAINER_BLOCK_OPEN_URL_EXTERNALLY': '1'}, |
| 447 | + homepage='https://m.facebook.com') |
| 448 | + |
| 449 | + external_link = self.page.find_element_by_css_selector( |
| 450 | + "a[href^='http://lm.facebook.com/l.php?u='][target='_blank']") |
| 451 | + self.assertThat(external_link, NotEquals(None)) |
| 452 | + |
| 453 | + webview = self.get_webview() |
| 454 | + watcher = webview.watch_signal( |
| 455 | + 'openExternalUrlTriggered(QString)') |
| 456 | + previous = watcher.num_emissions |
| 457 | + |
| 458 | + external_link.click() |
| 459 | + |
| 460 | + self.assertThat( |
| 461 | + lambda: watcher.num_emissions, |
| 462 | + Eventually(GreaterThan(previous))) |
| 463 | |
| 464 | === added directory 'webapp-gmail/tests' |
| 465 | === added directory 'webapp-gmail/tests/autopilot' |
| 466 | === added directory 'webapp-gmail/tests/autopilot/gmail_webapp' |
| 467 | === added file 'webapp-gmail/tests/autopilot/gmail_webapp/__init_.py' |
| 468 | --- webapp-gmail/tests/autopilot/gmail_webapp/__init_.py 1970-01-01 00:00:00 +0000 |
| 469 | +++ webapp-gmail/tests/autopilot/gmail_webapp/__init_.py 2015-07-13 15:30:05 +0000 |
| 470 | @@ -0,0 +1,162 @@ |
| 471 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 472 | + |
| 473 | +# |
| 474 | +# Ubuntu Core Webapps |
| 475 | +# Copyright (C) 2015 Canonical |
| 476 | +# |
| 477 | +# This program is free software: you can redistribute it and/or modify |
| 478 | +# it under the terms of the GNU General Public License as published by |
| 479 | +# the Free Software Foundation, either version 3 of the License, or |
| 480 | +# (at your option) any later version. |
| 481 | +# |
| 482 | +# This program is distributed in the hope that it will be useful, |
| 483 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 484 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 485 | +# GNU General Public License for more details. |
| 486 | +# |
| 487 | +# You should have received a copy of the GNU General Public License |
| 488 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 489 | +# |
| 490 | + |
| 491 | +import contextlib |
| 492 | +import logging |
| 493 | +import os |
| 494 | +import shutil |
| 495 | +import subprocess |
| 496 | + |
| 497 | +from autopilot import ( |
| 498 | + get_test_configuration, |
| 499 | + testcase |
| 500 | +) |
| 501 | + |
| 502 | +from selenium import webdriver |
| 503 | +from selenium.webdriver.chrome import options |
| 504 | +from ubuntuuitoolkit import fixture_setup |
| 505 | + |
| 506 | +import autopilot.logging |
| 507 | +from autopilot import platform |
| 508 | + |
| 509 | +logger = logging.getLogger(__name__) |
| 510 | + |
| 511 | +DESKTOP_FILE_NAME = 'webapp-gmail.desktop' |
| 512 | + |
| 513 | +DEFAULT_IMPLICIT_WAIT = 10 # seconds |
| 514 | + |
| 515 | + |
| 516 | +def get_source_desktop_file_path(): |
| 517 | + return os.path.join( |
| 518 | + os.path.dirname(__file__), '..', '..', '..', |
| 519 | + DESKTOP_FILE_NAME) |
| 520 | + |
| 521 | + |
| 522 | +def get_local_desktop_file_directory(): |
| 523 | + return os.path.join( |
| 524 | + os.environ.get('HOME'), '.local', 'share', 'applications') |
| 525 | + |
| 526 | + |
| 527 | +def get_chrome_driver_path(): |
| 528 | + env = os.environ.copy() |
| 529 | + readonly_dependencies_path = get_readonly_dependencies_path() |
| 530 | + if readonly_dependencies_path: |
| 531 | + # XXX When running with adt-run, this is needed if the image is |
| 532 | + # read-only so we can find the chromium driver path. |
| 533 | + env['PERL5LIB'] = os.path.join( |
| 534 | + readonly_dependencies_path, 'usr', 'share', 'perl5') |
| 535 | + |
| 536 | + architecture = subprocess.check_output( |
| 537 | + ['dpkg-architecture', '-qDEB_HOST_MULTIARCH'], |
| 538 | + env=env, universal_newlines=True).strip() |
| 539 | + |
| 540 | + chrome_driver_path = '/usr/lib/{}/oxide-qt/chromedriver'.format( |
| 541 | + architecture) |
| 542 | + |
| 543 | + if readonly_dependencies_path and not os.path.exists(chrome_driver_path): |
| 544 | + # Try the read-only install path. |
| 545 | + chrome_driver_path = os.path.join( |
| 546 | + readonly_dependencies_path, chrome_driver_path.lstrip('/')) |
| 547 | + |
| 548 | + return chrome_driver_path |
| 549 | + |
| 550 | + |
| 551 | +def get_readonly_dependencies_path(): |
| 552 | + adt_artifacts_path = os.environ.get('ADT_ARTIFACTS', None) |
| 553 | + if adt_artifacts_path: |
| 554 | + return os.path.join(os.path.dirname(adt_artifacts_path), 'deps') |
| 555 | + else: |
| 556 | + return None |
| 557 | + |
| 558 | + |
| 559 | +class GMailWebappTestCase(testcase.AutopilotTestCase): |
| 560 | + |
| 561 | + DEFAULT_WEBVIEW_INSPECTOR_IP = '127.0.0.1' |
| 562 | + DEFAULT_WEBVIEW_INSPECTOR_PORT = 9221 |
| 563 | + |
| 564 | + def __init__(self, proxy, driver): |
| 565 | + """Initialize the page object. |
| 566 | + |
| 567 | + :param proxy: The autopilot application proxy. |
| 568 | + :param driver: The webdriver used to introspect and control the web |
| 569 | + container. |
| 570 | + |
| 571 | + """ |
| 572 | + super().__init__() |
| 573 | + self.proxy = proxy |
| 574 | + self.driver = driver |
| 575 | + |
| 576 | + def get_container_proxy(self): |
| 577 | + return self.proxy.select_single('WebappContainerWebview') |
| 578 | + |
| 579 | + def setUp(self): |
| 580 | + super().setUp() |
| 581 | + self.setup_webdriver_environment() |
| 582 | + |
| 583 | + def setup_webdriver_environment(self): |
| 584 | + self.useFixture(fixture_setup.InitctlEnvironmentVariable( |
| 585 | + global_=True, |
| 586 | + UBUNTU_WEBVIEW_DEVTOOLS_HOST=self.DEFAULT_WEBVIEW_INSPECTOR_IP, |
| 587 | + UBUNTU_WEBVIEW_DEVTOOLS_PORT=str( |
| 588 | + self.DEFAULT_WEBVIEW_INSPECTOR_PORT) |
| 589 | + )) |
| 590 | + |
| 591 | + def validate_title(self, title): |
| 592 | + window = self.get_webcontainer_proxy() |
| 593 | + self.assertThat( |
| 594 | + lambda: window.title.lower(), |
| 595 | + Eventually(Contains(title.lower()))) |
| 596 | + |
| 597 | + def launch_application(self): |
| 598 | + if (get_test_configuration().get('from_source', None) and |
| 599 | + os.path.exists(get_source_desktop_file_path())): |
| 600 | + return self.launch_application_from_source() |
| 601 | + else: |
| 602 | + return self.launch_installed_application() |
| 603 | + |
| 604 | + def launch_application_from_source(self): |
| 605 | + test_desktop_file_path = os.path.join( |
| 606 | + get_local_desktop_file_directory(), 'webapps-test.desktop') |
| 607 | + shutil.copy(get_source_desktop_file_path(), test_desktop_file_path) |
| 608 | + self.addCleanup(os.remove, test_desktop_file_path) |
| 609 | + |
| 610 | + return self.launch_upstart_application('webapps-test') |
| 611 | + |
| 612 | + def get_webdriver(self): |
| 613 | + driver_options = options.Options() |
| 614 | + driver_options.binary_location = '' |
| 615 | + driver_options.debugger_address = '{}:{}'.format( |
| 616 | + self.DEFAULT_WEBVIEW_INSPECTOR_IP, |
| 617 | + self.DEFAULT_WEBVIEW_INSPECTOR_PORT) |
| 618 | + driver = webdriver.Chrome( |
| 619 | + executable_path=get_chrome_driver_path(), |
| 620 | + chrome_options=driver_options |
| 621 | + ) |
| 622 | + |
| 623 | + self.assertIsNot(driver, None) |
| 624 | + |
| 625 | + self.addCleanup(self.close_webdriver, driver) |
| 626 | + |
| 627 | + driver.implicitly_wait(DEFAULT_IMPLICIT_WAIT) |
| 628 | + return driver |
| 629 | + |
| 630 | + def close_webdriver(self, driver): |
| 631 | + driver.close() |
| 632 | + driver.quit() |
| 633 | |
| 634 | === added file 'webapp-gmail/tests/autopilot/gmail_webapp/test_gmail_webapp.py' |
| 635 | --- webapp-gmail/tests/autopilot/gmail_webapp/test_gmail_webapp.py 1970-01-01 00:00:00 +0000 |
| 636 | +++ webapp-gmail/tests/autopilot/gmail_webapp/test_gmail_webapp.py 2015-07-13 15:30:05 +0000 |
| 637 | @@ -0,0 +1,21 @@ |
| 638 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 639 | +# Copyright 2014 Canonical |
| 640 | +# |
| 641 | +# This program is free software: you can redistribute it and/or modify it |
| 642 | +# under the terms of the GNU General Public License version 3, as published |
| 643 | +# by the Free Software Foundation. |
| 644 | + |
| 645 | +from autopilot import platform |
| 646 | +from testtools import skipUnless |
| 647 | + |
| 648 | +import gmail_webapp |
| 649 | + |
| 650 | +class ClickWebappsLaunchTestCaseBase(GMailWebappTestCase): |
| 651 | + def setUp(self): |
| 652 | + super(ClickWebappsLaunchTestCaseBase, self).setUp() |
| 653 | + |
| 654 | + def test_launch_gmail(self): |
| 655 | + proxy = self.launch_application() |
| 656 | + driver = self.get_webdriver() |
| 657 | + |
| 658 | + self.validate_title('gmail') |
| 659 | |
| 660 | === added directory 'webapp-googlecalendar/tests' |
| 661 | === added directory 'webapp-googlecalendar/tests/autopilot' |
| 662 | === added directory 'webapp-googlecalendar/tests/autopilot/googlecalendar_webapp' |
| 663 | === added file 'webapp-googlecalendar/tests/autopilot/googlecalendar_webapp/__init_.py' |
| 664 | --- webapp-googlecalendar/tests/autopilot/googlecalendar_webapp/__init_.py 1970-01-01 00:00:00 +0000 |
| 665 | +++ webapp-googlecalendar/tests/autopilot/googlecalendar_webapp/__init_.py 2015-07-13 15:30:05 +0000 |
| 666 | @@ -0,0 +1,162 @@ |
| 667 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 668 | + |
| 669 | +# |
| 670 | +# Ubuntu Core Webapps |
| 671 | +# Copyright (C) 2015 Canonical |
| 672 | +# |
| 673 | +# This program is free software: you can redistribute it and/or modify |
| 674 | +# it under the terms of the GNU General Public License as published by |
| 675 | +# the Free Software Foundation, either version 3 of the License, or |
| 676 | +# (at your option) any later version. |
| 677 | +# |
| 678 | +# This program is distributed in the hope that it will be useful, |
| 679 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 680 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 681 | +# GNU General Public License for more details. |
| 682 | +# |
| 683 | +# You should have received a copy of the GNU General Public License |
| 684 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 685 | +# |
| 686 | + |
| 687 | +import contextlib |
| 688 | +import logging |
| 689 | +import os |
| 690 | +import shutil |
| 691 | +import subprocess |
| 692 | + |
| 693 | +from autopilot import ( |
| 694 | + get_test_configuration, |
| 695 | + testcase |
| 696 | +) |
| 697 | + |
| 698 | +from selenium import webdriver |
| 699 | +from selenium.webdriver.chrome import options |
| 700 | +from ubuntuuitoolkit import fixture_setup |
| 701 | + |
| 702 | +import autopilot.logging |
| 703 | +from autopilot import platform |
| 704 | + |
| 705 | +logger = logging.getLogger(__name__) |
| 706 | + |
| 707 | +DESKTOP_FILE_NAME = 'webapp-googlecalendar.desktop' |
| 708 | + |
| 709 | +DEFAULT_IMPLICIT_WAIT = 10 # seconds |
| 710 | + |
| 711 | + |
| 712 | +def get_source_desktop_file_path(): |
| 713 | + return os.path.join( |
| 714 | + os.path.dirname(__file__), '..', '..', '..', |
| 715 | + DESKTOP_FILE_NAME) |
| 716 | + |
| 717 | + |
| 718 | +def get_local_desktop_file_directory(): |
| 719 | + return os.path.join( |
| 720 | + os.environ.get('HOME'), '.local', 'share', 'applications') |
| 721 | + |
| 722 | + |
| 723 | +def get_chrome_driver_path(): |
| 724 | + env = os.environ.copy() |
| 725 | + readonly_dependencies_path = get_readonly_dependencies_path() |
| 726 | + if readonly_dependencies_path: |
| 727 | + # XXX When running with adt-run, this is needed if the image is |
| 728 | + # read-only so we can find the chromium driver path. |
| 729 | + env['PERL5LIB'] = os.path.join( |
| 730 | + readonly_dependencies_path, 'usr', 'share', 'perl5') |
| 731 | + |
| 732 | + architecture = subprocess.check_output( |
| 733 | + ['dpkg-architecture', '-qDEB_HOST_MULTIARCH'], |
| 734 | + env=env, universal_newlines=True).strip() |
| 735 | + |
| 736 | + chrome_driver_path = '/usr/lib/{}/oxide-qt/chromedriver'.format( |
| 737 | + architecture) |
| 738 | + |
| 739 | + if readonly_dependencies_path and not os.path.exists(chrome_driver_path): |
| 740 | + # Try the read-only install path. |
| 741 | + chrome_driver_path = os.path.join( |
| 742 | + readonly_dependencies_path, chrome_driver_path.lstrip('/')) |
| 743 | + |
| 744 | + return chrome_driver_path |
| 745 | + |
| 746 | + |
| 747 | +def get_readonly_dependencies_path(): |
| 748 | + adt_artifacts_path = os.environ.get('ADT_ARTIFACTS', None) |
| 749 | + if adt_artifacts_path: |
| 750 | + return os.path.join(os.path.dirname(adt_artifacts_path), 'deps') |
| 751 | + else: |
| 752 | + return None |
| 753 | + |
| 754 | + |
| 755 | +class GoogleCalendarWebappTestCase(testcase.AutopilotTestCase): |
| 756 | + |
| 757 | + DEFAULT_WEBVIEW_INSPECTOR_IP = '127.0.0.1' |
| 758 | + DEFAULT_WEBVIEW_INSPECTOR_PORT = 9221 |
| 759 | + |
| 760 | + def __init__(self, proxy, driver): |
| 761 | + """Initialize the page object. |
| 762 | + |
| 763 | + :param proxy: The autopilot application proxy. |
| 764 | + :param driver: The webdriver used to introspect and control the web |
| 765 | + container. |
| 766 | + |
| 767 | + """ |
| 768 | + super().__init__() |
| 769 | + self.proxy = proxy |
| 770 | + self.driver = driver |
| 771 | + |
| 772 | + def get_container_proxy(self): |
| 773 | + return self.proxy.select_single('WebappContainerWebview') |
| 774 | + |
| 775 | + def setUp(self): |
| 776 | + super().setUp() |
| 777 | + self.setup_webdriver_environment() |
| 778 | + |
| 779 | + def setup_webdriver_environment(self): |
| 780 | + self.useFixture(fixture_setup.InitctlEnvironmentVariable( |
| 781 | + global_=True, |
| 782 | + UBUNTU_WEBVIEW_DEVTOOLS_HOST=self.DEFAULT_WEBVIEW_INSPECTOR_IP, |
| 783 | + UBUNTU_WEBVIEW_DEVTOOLS_PORT=str( |
| 784 | + self.DEFAULT_WEBVIEW_INSPECTOR_PORT) |
| 785 | + )) |
| 786 | + |
| 787 | + def validate_title(self, title): |
| 788 | + window = self.get_webcontainer_proxy() |
| 789 | + self.assertThat( |
| 790 | + lambda: window.title.lower(), |
| 791 | + Eventually(Contains(title.lower()))) |
| 792 | + |
| 793 | + def launch_application(self): |
| 794 | + if (get_test_configuration().get('from_source', None) and |
| 795 | + os.path.exists(get_source_desktop_file_path())): |
| 796 | + return self.launch_application_from_source() |
| 797 | + else: |
| 798 | + return self.launch_installed_application() |
| 799 | + |
| 800 | + def launch_application_from_source(self): |
| 801 | + test_desktop_file_path = os.path.join( |
| 802 | + get_local_desktop_file_directory(), 'webapps-test.desktop') |
| 803 | + shutil.copy(get_source_desktop_file_path(), test_desktop_file_path) |
| 804 | + self.addCleanup(os.remove, test_desktop_file_path) |
| 805 | + |
| 806 | + return self.launch_upstart_application('webapps-test') |
| 807 | + |
| 808 | + def get_webdriver(self): |
| 809 | + driver_options = options.Options() |
| 810 | + driver_options.binary_location = '' |
| 811 | + driver_options.debugger_address = '{}:{}'.format( |
| 812 | + self.DEFAULT_WEBVIEW_INSPECTOR_IP, |
| 813 | + self.DEFAULT_WEBVIEW_INSPECTOR_PORT) |
| 814 | + driver = webdriver.Chrome( |
| 815 | + executable_path=get_chrome_driver_path(), |
| 816 | + chrome_options=driver_options |
| 817 | + ) |
| 818 | + |
| 819 | + self.assertIsNot(driver, None) |
| 820 | + |
| 821 | + self.addCleanup(self.close_webdriver, driver) |
| 822 | + |
| 823 | + driver.implicitly_wait(DEFAULT_IMPLICIT_WAIT) |
| 824 | + return driver |
| 825 | + |
| 826 | + def close_webdriver(self, driver): |
| 827 | + driver.close() |
| 828 | + driver.quit() |
| 829 | |
| 830 | === added file 'webapp-googlecalendar/tests/autopilot/googlecalendar_webapp/test_googlecalendar_webapp.py' |
| 831 | --- webapp-googlecalendar/tests/autopilot/googlecalendar_webapp/test_googlecalendar_webapp.py 1970-01-01 00:00:00 +0000 |
| 832 | +++ webapp-googlecalendar/tests/autopilot/googlecalendar_webapp/test_googlecalendar_webapp.py 2015-07-13 15:30:05 +0000 |
| 833 | @@ -0,0 +1,21 @@ |
| 834 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 835 | +# Copyright 2014 Canonical |
| 836 | +# |
| 837 | +# This program is free software: you can redistribute it and/or modify it |
| 838 | +# under the terms of the GNU General Public License version 3, as published |
| 839 | +# by the Free Software Foundation. |
| 840 | + |
| 841 | +from autopilot import platform |
| 842 | +from testtools import skipUnless |
| 843 | + |
| 844 | +import googlecalendar_webapp |
| 845 | + |
| 846 | +class ClickWebappsLaunchTestCaseBase(GoogleCalendarWebappTestCase): |
| 847 | + def setUp(self): |
| 848 | + super(ClickWebappsLaunchTestCaseBase, self).setUp() |
| 849 | + |
| 850 | + def test_launch_googlecalendar(self): |
| 851 | + proxy = self.launch_application() |
| 852 | + driver = self.get_webdriver() |
| 853 | + |
| 854 | + self.validate_title('Calendar') |
| 855 | |
| 856 | === added directory 'webapp-googlemaps/tests' |
| 857 | === added directory 'webapp-googlemaps/tests/autopilot' |
| 858 | === added directory 'webapp-googlemaps/tests/autopilot/googlemaps_webapp' |
| 859 | === added file 'webapp-googlemaps/tests/autopilot/googlemaps_webapp/__init_.py' |
| 860 | --- webapp-googlemaps/tests/autopilot/googlemaps_webapp/__init_.py 1970-01-01 00:00:00 +0000 |
| 861 | +++ webapp-googlemaps/tests/autopilot/googlemaps_webapp/__init_.py 2015-07-13 15:30:05 +0000 |
| 862 | @@ -0,0 +1,162 @@ |
| 863 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 864 | + |
| 865 | +# |
| 866 | +# Ubuntu Core Webapps |
| 867 | +# Copyright (C) 2015 Canonical |
| 868 | +# |
| 869 | +# This program is free software: you can redistribute it and/or modify |
| 870 | +# it under the terms of the GNU General Public License as published by |
| 871 | +# the Free Software Foundation, either version 3 of the License, or |
| 872 | +# (at your option) any later version. |
| 873 | +# |
| 874 | +# This program is distributed in the hope that it will be useful, |
| 875 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 876 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 877 | +# GNU General Public License for more details. |
| 878 | +# |
| 879 | +# You should have received a copy of the GNU General Public License |
| 880 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 881 | +# |
| 882 | + |
| 883 | +import contextlib |
| 884 | +import logging |
| 885 | +import os |
| 886 | +import shutil |
| 887 | +import subprocess |
| 888 | + |
| 889 | +from autopilot import ( |
| 890 | + get_test_configuration, |
| 891 | + testcase |
| 892 | +) |
| 893 | + |
| 894 | +from selenium import webdriver |
| 895 | +from selenium.webdriver.chrome import options |
| 896 | +from ubuntuuitoolkit import fixture_setup |
| 897 | + |
| 898 | +import autopilot.logging |
| 899 | +from autopilot import platform |
| 900 | + |
| 901 | +logger = logging.getLogger(__name__) |
| 902 | + |
| 903 | +DESKTOP_FILE_NAME = 'webapp-googlemaps.desktop' |
| 904 | + |
| 905 | +DEFAULT_IMPLICIT_WAIT = 10 # seconds |
| 906 | + |
| 907 | + |
| 908 | +def get_source_desktop_file_path(): |
| 909 | + return os.path.join( |
| 910 | + os.path.dirname(__file__), '..', '..', '..', |
| 911 | + DESKTOP_FILE_NAME) |
| 912 | + |
| 913 | + |
| 914 | +def get_local_desktop_file_directory(): |
| 915 | + return os.path.join( |
| 916 | + os.environ.get('HOME'), '.local', 'share', 'applications') |
| 917 | + |
| 918 | + |
| 919 | +def get_chrome_driver_path(): |
| 920 | + env = os.environ.copy() |
| 921 | + readonly_dependencies_path = get_readonly_dependencies_path() |
| 922 | + if readonly_dependencies_path: |
| 923 | + # XXX When running with adt-run, this is needed if the image is |
| 924 | + # read-only so we can find the chromium driver path. |
| 925 | + env['PERL5LIB'] = os.path.join( |
| 926 | + readonly_dependencies_path, 'usr', 'share', 'perl5') |
| 927 | + |
| 928 | + architecture = subprocess.check_output( |
| 929 | + ['dpkg-architecture', '-qDEB_HOST_MULTIARCH'], |
| 930 | + env=env, universal_newlines=True).strip() |
| 931 | + |
| 932 | + chrome_driver_path = '/usr/lib/{}/oxide-qt/chromedriver'.format( |
| 933 | + architecture) |
| 934 | + |
| 935 | + if readonly_dependencies_path and not os.path.exists(chrome_driver_path): |
| 936 | + # Try the read-only install path. |
| 937 | + chrome_driver_path = os.path.join( |
| 938 | + readonly_dependencies_path, chrome_driver_path.lstrip('/')) |
| 939 | + |
| 940 | + return chrome_driver_path |
| 941 | + |
| 942 | + |
| 943 | +def get_readonly_dependencies_path(): |
| 944 | + adt_artifacts_path = os.environ.get('ADT_ARTIFACTS', None) |
| 945 | + if adt_artifacts_path: |
| 946 | + return os.path.join(os.path.dirname(adt_artifacts_path), 'deps') |
| 947 | + else: |
| 948 | + return None |
| 949 | + |
| 950 | + |
| 951 | +class GoogleMapsWebappTestCase(testcase.AutopilotTestCase): |
| 952 | + |
| 953 | + DEFAULT_WEBVIEW_INSPECTOR_IP = '127.0.0.1' |
| 954 | + DEFAULT_WEBVIEW_INSPECTOR_PORT = 9221 |
| 955 | + |
| 956 | + def __init__(self, proxy, driver): |
| 957 | + """Initialize the page object. |
| 958 | + |
| 959 | + :param proxy: The autopilot application proxy. |
| 960 | + :param driver: The webdriver used to introspect and control the web |
| 961 | + container. |
| 962 | + |
| 963 | + """ |
| 964 | + super().__init__() |
| 965 | + self.proxy = proxy |
| 966 | + self.driver = driver |
| 967 | + |
| 968 | + def get_container_proxy(self): |
| 969 | + return self.proxy.select_single('WebappContainerWebview') |
| 970 | + |
| 971 | + def setUp(self): |
| 972 | + super().setUp() |
| 973 | + self.setup_webdriver_environment() |
| 974 | + |
| 975 | + def setup_webdriver_environment(self): |
| 976 | + self.useFixture(fixture_setup.InitctlEnvironmentVariable( |
| 977 | + global_=True, |
| 978 | + UBUNTU_WEBVIEW_DEVTOOLS_HOST=self.DEFAULT_WEBVIEW_INSPECTOR_IP, |
| 979 | + UBUNTU_WEBVIEW_DEVTOOLS_PORT=str( |
| 980 | + self.DEFAULT_WEBVIEW_INSPECTOR_PORT) |
| 981 | + )) |
| 982 | + |
| 983 | + def validate_title(self, title): |
| 984 | + window = self.get_webcontainer_proxy() |
| 985 | + self.assertThat( |
| 986 | + lambda: window.title.lower(), |
| 987 | + Eventually(Contains(title.lower()))) |
| 988 | + |
| 989 | + def launch_application(self): |
| 990 | + if (get_test_configuration().get('from_source', None) and |
| 991 | + os.path.exists(get_source_desktop_file_path())): |
| 992 | + return self.launch_application_from_source() |
| 993 | + else: |
| 994 | + return self.launch_installed_application() |
| 995 | + |
| 996 | + def launch_application_from_source(self): |
| 997 | + test_desktop_file_path = os.path.join( |
| 998 | + get_local_desktop_file_directory(), 'webapps-test.desktop') |
| 999 | + shutil.copy(get_source_desktop_file_path(), test_desktop_file_path) |
| 1000 | + self.addCleanup(os.remove, test_desktop_file_path) |
| 1001 | + |
| 1002 | + return self.launch_upstart_application('webapps-test') |
| 1003 | + |
| 1004 | + def get_webdriver(self): |
| 1005 | + driver_options = options.Options() |
| 1006 | + driver_options.binary_location = '' |
| 1007 | + driver_options.debugger_address = '{}:{}'.format( |
| 1008 | + self.DEFAULT_WEBVIEW_INSPECTOR_IP, |
| 1009 | + self.DEFAULT_WEBVIEW_INSPECTOR_PORT) |
| 1010 | + driver = webdriver.Chrome( |
| 1011 | + executable_path=get_chrome_driver_path(), |
| 1012 | + chrome_options=driver_options |
| 1013 | + ) |
| 1014 | + |
| 1015 | + self.assertIsNot(driver, None) |
| 1016 | + |
| 1017 | + self.addCleanup(self.close_webdriver, driver) |
| 1018 | + |
| 1019 | + driver.implicitly_wait(DEFAULT_IMPLICIT_WAIT) |
| 1020 | + return driver |
| 1021 | + |
| 1022 | + def close_webdriver(self, driver): |
| 1023 | + driver.close() |
| 1024 | + driver.quit() |
| 1025 | |
| 1026 | === added file 'webapp-googlemaps/tests/autopilot/googlemaps_webapp/test_googlemaps_webapp.py' |
| 1027 | --- webapp-googlemaps/tests/autopilot/googlemaps_webapp/test_googlemaps_webapp.py 1970-01-01 00:00:00 +0000 |
| 1028 | +++ webapp-googlemaps/tests/autopilot/googlemaps_webapp/test_googlemaps_webapp.py 2015-07-13 15:30:05 +0000 |
| 1029 | @@ -0,0 +1,21 @@ |
| 1030 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 1031 | +# Copyright 2014 Canonical |
| 1032 | +# |
| 1033 | +# This program is free software: you can redistribute it and/or modify it |
| 1034 | +# under the terms of the GNU General Public License version 3, as published |
| 1035 | +# by the Free Software Foundation. |
| 1036 | + |
| 1037 | +from autopilot import platform |
| 1038 | +from testtools import skipUnless |
| 1039 | + |
| 1040 | +import googlemaps_webapp |
| 1041 | + |
| 1042 | +class ClickWebappsLaunchTestCaseBase(GoogleMapsWebappTestCase): |
| 1043 | + def setUp(self): |
| 1044 | + super(ClickWebappsLaunchTestCaseBase, self).setUp() |
| 1045 | + |
| 1046 | + def test_launch_googlemaps(self): |
| 1047 | + proxy = self.launch_application() |
| 1048 | + driver = self.get_webdriver() |
| 1049 | + |
| 1050 | + self.validate_title('maps') |
| 1051 | |
| 1052 | === added directory 'webapp-googleplus/tests' |
| 1053 | === added directory 'webapp-googleplus/tests/autopilot' |
| 1054 | === added directory 'webapp-googleplus/tests/autopilot/googleplus_webapp' |
| 1055 | === added file 'webapp-googleplus/tests/autopilot/googleplus_webapp/__init_.py' |
| 1056 | --- webapp-googleplus/tests/autopilot/googleplus_webapp/__init_.py 1970-01-01 00:00:00 +0000 |
| 1057 | +++ webapp-googleplus/tests/autopilot/googleplus_webapp/__init_.py 2015-07-13 15:30:05 +0000 |
| 1058 | @@ -0,0 +1,162 @@ |
| 1059 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 1060 | + |
| 1061 | +# |
| 1062 | +# Ubuntu Core Webapps |
| 1063 | +# Copyright (C) 2015 Canonical |
| 1064 | +# |
| 1065 | +# This program is free software: you can redistribute it and/or modify |
| 1066 | +# it under the terms of the GNU General Public License as published by |
| 1067 | +# the Free Software Foundation, either version 3 of the License, or |
| 1068 | +# (at your option) any later version. |
| 1069 | +# |
| 1070 | +# This program is distributed in the hope that it will be useful, |
| 1071 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1072 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1073 | +# GNU General Public License for more details. |
| 1074 | +# |
| 1075 | +# You should have received a copy of the GNU General Public License |
| 1076 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1077 | +# |
| 1078 | + |
| 1079 | +import contextlib |
| 1080 | +import logging |
| 1081 | +import os |
| 1082 | +import shutil |
| 1083 | +import subprocess |
| 1084 | + |
| 1085 | +from autopilot import ( |
| 1086 | + get_test_configuration, |
| 1087 | + testcase |
| 1088 | +) |
| 1089 | + |
| 1090 | +from selenium import webdriver |
| 1091 | +from selenium.webdriver.chrome import options |
| 1092 | +from ubuntuuitoolkit import fixture_setup |
| 1093 | + |
| 1094 | +import autopilot.logging |
| 1095 | +from autopilot import platform |
| 1096 | + |
| 1097 | +logger = logging.getLogger(__name__) |
| 1098 | + |
| 1099 | +DESKTOP_FILE_NAME = 'googleplus.desktop' |
| 1100 | + |
| 1101 | +DEFAULT_IMPLICIT_WAIT = 10 # seconds |
| 1102 | + |
| 1103 | + |
| 1104 | +def get_source_desktop_file_path(): |
| 1105 | + return os.path.join( |
| 1106 | + os.path.dirname(__file__), '..', '..', '..', |
| 1107 | + DESKTOP_FILE_NAME) |
| 1108 | + |
| 1109 | + |
| 1110 | +def get_local_desktop_file_directory(): |
| 1111 | + return os.path.join( |
| 1112 | + os.environ.get('HOME'), '.local', 'share', 'applications') |
| 1113 | + |
| 1114 | + |
| 1115 | +def get_chrome_driver_path(): |
| 1116 | + env = os.environ.copy() |
| 1117 | + readonly_dependencies_path = get_readonly_dependencies_path() |
| 1118 | + if readonly_dependencies_path: |
| 1119 | + # XXX When running with adt-run, this is needed if the image is |
| 1120 | + # read-only so we can find the chromium driver path. |
| 1121 | + env['PERL5LIB'] = os.path.join( |
| 1122 | + readonly_dependencies_path, 'usr', 'share', 'perl5') |
| 1123 | + |
| 1124 | + architecture = subprocess.check_output( |
| 1125 | + ['dpkg-architecture', '-qDEB_HOST_MULTIARCH'], |
| 1126 | + env=env, universal_newlines=True).strip() |
| 1127 | + |
| 1128 | + chrome_driver_path = '/usr/lib/{}/oxide-qt/chromedriver'.format( |
| 1129 | + architecture) |
| 1130 | + |
| 1131 | + if readonly_dependencies_path and not os.path.exists(chrome_driver_path): |
| 1132 | + # Try the read-only install path. |
| 1133 | + chrome_driver_path = os.path.join( |
| 1134 | + readonly_dependencies_path, chrome_driver_path.lstrip('/')) |
| 1135 | + |
| 1136 | + return chrome_driver_path |
| 1137 | + |
| 1138 | + |
| 1139 | +def get_readonly_dependencies_path(): |
| 1140 | + adt_artifacts_path = os.environ.get('ADT_ARTIFACTS', None) |
| 1141 | + if adt_artifacts_path: |
| 1142 | + return os.path.join(os.path.dirname(adt_artifacts_path), 'deps') |
| 1143 | + else: |
| 1144 | + return None |
| 1145 | + |
| 1146 | + |
| 1147 | +class GooglePlusWebappTestCase(testcase.AutopilotTestCase): |
| 1148 | + |
| 1149 | + DEFAULT_WEBVIEW_INSPECTOR_IP = '127.0.0.1' |
| 1150 | + DEFAULT_WEBVIEW_INSPECTOR_PORT = 9221 |
| 1151 | + |
| 1152 | + def __init__(self, proxy, driver): |
| 1153 | + """Initialize the page object. |
| 1154 | + |
| 1155 | + :param proxy: The autopilot application proxy. |
| 1156 | + :param driver: The webdriver used to introspect and control the web |
| 1157 | + container. |
| 1158 | + |
| 1159 | + """ |
| 1160 | + super().__init__() |
| 1161 | + self.proxy = proxy |
| 1162 | + self.driver = driver |
| 1163 | + |
| 1164 | + def get_container_proxy(self): |
| 1165 | + return self.proxy.select_single('WebappContainerWebview') |
| 1166 | + |
| 1167 | + def setUp(self): |
| 1168 | + super().setUp() |
| 1169 | + self.setup_webdriver_environment() |
| 1170 | + |
| 1171 | + def setup_webdriver_environment(self): |
| 1172 | + self.useFixture(fixture_setup.InitctlEnvironmentVariable( |
| 1173 | + global_=True, |
| 1174 | + UBUNTU_WEBVIEW_DEVTOOLS_HOST=self.DEFAULT_WEBVIEW_INSPECTOR_IP, |
| 1175 | + UBUNTU_WEBVIEW_DEVTOOLS_PORT=str( |
| 1176 | + self.DEFAULT_WEBVIEW_INSPECTOR_PORT) |
| 1177 | + )) |
| 1178 | + |
| 1179 | + def validate_title(self, title): |
| 1180 | + window = self.get_webcontainer_proxy() |
| 1181 | + self.assertThat( |
| 1182 | + lambda: window.title.lower(), |
| 1183 | + Eventually(Contains(title.lower()))) |
| 1184 | + |
| 1185 | + def launch_application(self): |
| 1186 | + if (get_test_configuration().get('from_source', None) and |
| 1187 | + os.path.exists(get_source_desktop_file_path())): |
| 1188 | + return self.launch_application_from_source() |
| 1189 | + else: |
| 1190 | + return self.launch_installed_application() |
| 1191 | + |
| 1192 | + def launch_application_from_source(self): |
| 1193 | + test_desktop_file_path = os.path.join( |
| 1194 | + get_local_desktop_file_directory(), 'webapps-test.desktop') |
| 1195 | + shutil.copy(get_source_desktop_file_path(), test_desktop_file_path) |
| 1196 | + self.addCleanup(os.remove, test_desktop_file_path) |
| 1197 | + |
| 1198 | + return self.launch_upstart_application('webapps-test') |
| 1199 | + |
| 1200 | + def get_webdriver(self): |
| 1201 | + driver_options = options.Options() |
| 1202 | + driver_options.binary_location = '' |
| 1203 | + driver_options.debugger_address = '{}:{}'.format( |
| 1204 | + self.DEFAULT_WEBVIEW_INSPECTOR_IP, |
| 1205 | + self.DEFAULT_WEBVIEW_INSPECTOR_PORT) |
| 1206 | + driver = webdriver.Chrome( |
| 1207 | + executable_path=get_chrome_driver_path(), |
| 1208 | + chrome_options=driver_options |
| 1209 | + ) |
| 1210 | + |
| 1211 | + self.assertIsNot(driver, None) |
| 1212 | + |
| 1213 | + self.addCleanup(self.close_webdriver, driver) |
| 1214 | + |
| 1215 | + driver.implicitly_wait(DEFAULT_IMPLICIT_WAIT) |
| 1216 | + return driver |
| 1217 | + |
| 1218 | + def close_webdriver(self, driver): |
| 1219 | + driver.close() |
| 1220 | + driver.quit() |
| 1221 | |
| 1222 | === added file 'webapp-googleplus/tests/autopilot/googleplus_webapp/test_googleplus_webapp.py' |
| 1223 | --- webapp-googleplus/tests/autopilot/googleplus_webapp/test_googleplus_webapp.py 1970-01-01 00:00:00 +0000 |
| 1224 | +++ webapp-googleplus/tests/autopilot/googleplus_webapp/test_googleplus_webapp.py 2015-07-13 15:30:05 +0000 |
| 1225 | @@ -0,0 +1,21 @@ |
| 1226 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 1227 | +# Copyright 2014 Canonical |
| 1228 | +# |
| 1229 | +# This program is free software: you can redistribute it and/or modify it |
| 1230 | +# under the terms of the GNU General Public License version 3, as published |
| 1231 | +# by the Free Software Foundation. |
| 1232 | + |
| 1233 | +from autopilot import platform |
| 1234 | +from testtools import skipUnless |
| 1235 | + |
| 1236 | +import googleplus_webapp |
| 1237 | + |
| 1238 | +class ClickWebappsLaunchTestCaseBase(GooglePlusWebappTestCase): |
| 1239 | + def setUp(self): |
| 1240 | + super(ClickWebappsLaunchTestCaseBase, self).setUp() |
| 1241 | + |
| 1242 | + def test_launch_googleplus(self): |
| 1243 | + proxy = self.launch_application() |
| 1244 | + driver = self.get_webdriver() |
| 1245 | + |
| 1246 | + self.validate_title('plus') |
| 1247 | |
| 1248 | === added directory 'webapp-twitter/tests' |
| 1249 | === added directory 'webapp-twitter/tests/autopilot' |
| 1250 | === added directory 'webapp-twitter/tests/autopilot/twitter_webapp' |
| 1251 | === added file 'webapp-twitter/tests/autopilot/twitter_webapp/__init_.py' |
| 1252 | --- webapp-twitter/tests/autopilot/twitter_webapp/__init_.py 1970-01-01 00:00:00 +0000 |
| 1253 | +++ webapp-twitter/tests/autopilot/twitter_webapp/__init_.py 2015-07-13 15:30:05 +0000 |
| 1254 | @@ -0,0 +1,162 @@ |
| 1255 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 1256 | + |
| 1257 | +# |
| 1258 | +# Ubuntu Core Webapps |
| 1259 | +# Copyright (C) 2015 Canonical |
| 1260 | +# |
| 1261 | +# This program is free software: you can redistribute it and/or modify |
| 1262 | +# it under the terms of the GNU General Public License as published by |
| 1263 | +# the Free Software Foundation, either version 3 of the License, or |
| 1264 | +# (at your option) any later version. |
| 1265 | +# |
| 1266 | +# This program is distributed in the hope that it will be useful, |
| 1267 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1268 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1269 | +# GNU General Public License for more details. |
| 1270 | +# |
| 1271 | +# You should have received a copy of the GNU General Public License |
| 1272 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1273 | +# |
| 1274 | + |
| 1275 | +import contextlib |
| 1276 | +import logging |
| 1277 | +import os |
| 1278 | +import shutil |
| 1279 | +import subprocess |
| 1280 | + |
| 1281 | +from autopilot import ( |
| 1282 | + get_test_configuration, |
| 1283 | + testcase |
| 1284 | +) |
| 1285 | + |
| 1286 | +from selenium import webdriver |
| 1287 | +from selenium.webdriver.chrome import options |
| 1288 | +from ubuntuuitoolkit import fixture_setup |
| 1289 | + |
| 1290 | +import autopilot.logging |
| 1291 | +from autopilot import platform |
| 1292 | + |
| 1293 | +logger = logging.getLogger(__name__) |
| 1294 | + |
| 1295 | +DESKTOP_FILE_NAME = 'webapp-twitter.desktop' |
| 1296 | + |
| 1297 | +DEFAULT_IMPLICIT_WAIT = 10 # seconds |
| 1298 | + |
| 1299 | + |
| 1300 | +def get_source_desktop_file_path(): |
| 1301 | + return os.path.join( |
| 1302 | + os.path.dirname(__file__), '..', '..', '..', |
| 1303 | + DESKTOP_FILE_NAME) |
| 1304 | + |
| 1305 | + |
| 1306 | +def get_local_desktop_file_directory(): |
| 1307 | + return os.path.join( |
| 1308 | + os.environ.get('HOME'), '.local', 'share', 'applications') |
| 1309 | + |
| 1310 | + |
| 1311 | +def get_chrome_driver_path(): |
| 1312 | + env = os.environ.copy() |
| 1313 | + readonly_dependencies_path = get_readonly_dependencies_path() |
| 1314 | + if readonly_dependencies_path: |
| 1315 | + # XXX When running with adt-run, this is needed if the image is |
| 1316 | + # read-only so we can find the chromium driver path. |
| 1317 | + env['PERL5LIB'] = os.path.join( |
| 1318 | + readonly_dependencies_path, 'usr', 'share', 'perl5') |
| 1319 | + |
| 1320 | + architecture = subprocess.check_output( |
| 1321 | + ['dpkg-architecture', '-qDEB_HOST_MULTIARCH'], |
| 1322 | + env=env, universal_newlines=True).strip() |
| 1323 | + |
| 1324 | + chrome_driver_path = '/usr/lib/{}/oxide-qt/chromedriver'.format( |
| 1325 | + architecture) |
| 1326 | + |
| 1327 | + if readonly_dependencies_path and not os.path.exists(chrome_driver_path): |
| 1328 | + # Try the read-only install path. |
| 1329 | + chrome_driver_path = os.path.join( |
| 1330 | + readonly_dependencies_path, chrome_driver_path.lstrip('/')) |
| 1331 | + |
| 1332 | + return chrome_driver_path |
| 1333 | + |
| 1334 | + |
| 1335 | +def get_readonly_dependencies_path(): |
| 1336 | + adt_artifacts_path = os.environ.get('ADT_ARTIFACTS', None) |
| 1337 | + if adt_artifacts_path: |
| 1338 | + return os.path.join(os.path.dirname(adt_artifacts_path), 'deps') |
| 1339 | + else: |
| 1340 | + return None |
| 1341 | + |
| 1342 | + |
| 1343 | +class TwitterWebappTestCase(testcase.AutopilotTestCase): |
| 1344 | + |
| 1345 | + DEFAULT_WEBVIEW_INSPECTOR_IP = '127.0.0.1' |
| 1346 | + DEFAULT_WEBVIEW_INSPECTOR_PORT = 9221 |
| 1347 | + |
| 1348 | + def __init__(self, proxy, driver): |
| 1349 | + """Initialize the page object. |
| 1350 | + |
| 1351 | + :param proxy: The autopilot application proxy. |
| 1352 | + :param driver: The webdriver used to introspect and control the web |
| 1353 | + container. |
| 1354 | + |
| 1355 | + """ |
| 1356 | + super().__init__() |
| 1357 | + self.proxy = proxy |
| 1358 | + self.driver = driver |
| 1359 | + |
| 1360 | + def get_container_proxy(self): |
| 1361 | + return self.proxy.select_single('WebappContainerWebview') |
| 1362 | + |
| 1363 | + def setUp(self): |
| 1364 | + super().setUp() |
| 1365 | + self.setup_webdriver_environment() |
| 1366 | + |
| 1367 | + def setup_webdriver_environment(self): |
| 1368 | + self.useFixture(fixture_setup.InitctlEnvironmentVariable( |
| 1369 | + global_=True, |
| 1370 | + UBUNTU_WEBVIEW_DEVTOOLS_HOST=self.DEFAULT_WEBVIEW_INSPECTOR_IP, |
| 1371 | + UBUNTU_WEBVIEW_DEVTOOLS_PORT=str( |
| 1372 | + self.DEFAULT_WEBVIEW_INSPECTOR_PORT) |
| 1373 | + )) |
| 1374 | + |
| 1375 | + def validate_title(self, title): |
| 1376 | + window = self.get_webcontainer_proxy() |
| 1377 | + self.assertThat( |
| 1378 | + lambda: window.title.lower(), |
| 1379 | + Eventually(Contains(title.lower()))) |
| 1380 | + |
| 1381 | + def launch_application(self): |
| 1382 | + if (get_test_configuration().get('from_source', None) and |
| 1383 | + os.path.exists(get_source_desktop_file_path())): |
| 1384 | + return self.launch_application_from_source() |
| 1385 | + else: |
| 1386 | + return self.launch_installed_application() |
| 1387 | + |
| 1388 | + def launch_application_from_source(self): |
| 1389 | + test_desktop_file_path = os.path.join( |
| 1390 | + get_local_desktop_file_directory(), 'webapps-test.desktop') |
| 1391 | + shutil.copy(get_source_desktop_file_path(), test_desktop_file_path) |
| 1392 | + self.addCleanup(os.remove, test_desktop_file_path) |
| 1393 | + |
| 1394 | + return self.launch_upstart_application('webapps-test') |
| 1395 | + |
| 1396 | + def get_webdriver(self): |
| 1397 | + driver_options = options.Options() |
| 1398 | + driver_options.binary_location = '' |
| 1399 | + driver_options.debugger_address = '{}:{}'.format( |
| 1400 | + self.DEFAULT_WEBVIEW_INSPECTOR_IP, |
| 1401 | + self.DEFAULT_WEBVIEW_INSPECTOR_PORT) |
| 1402 | + driver = webdriver.Chrome( |
| 1403 | + executable_path=get_chrome_driver_path(), |
| 1404 | + chrome_options=driver_options |
| 1405 | + ) |
| 1406 | + |
| 1407 | + self.assertIsNot(driver, None) |
| 1408 | + |
| 1409 | + self.addCleanup(self.close_webdriver, driver) |
| 1410 | + |
| 1411 | + driver.implicitly_wait(DEFAULT_IMPLICIT_WAIT) |
| 1412 | + return driver |
| 1413 | + |
| 1414 | + def close_webdriver(self, driver): |
| 1415 | + driver.close() |
| 1416 | + driver.quit() |
| 1417 | |
| 1418 | === added file 'webapp-twitter/tests/autopilot/twitter_webapp/test_twitter_webapp.py' |
| 1419 | --- webapp-twitter/tests/autopilot/twitter_webapp/test_twitter_webapp.py 1970-01-01 00:00:00 +0000 |
| 1420 | +++ webapp-twitter/tests/autopilot/twitter_webapp/test_twitter_webapp.py 2015-07-13 15:30:05 +0000 |
| 1421 | @@ -0,0 +1,21 @@ |
| 1422 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 1423 | +# Copyright 2014 Canonical |
| 1424 | +# |
| 1425 | +# This program is free software: you can redistribute it and/or modify it |
| 1426 | +# under the terms of the GNU General Public License version 3, as published |
| 1427 | +# by the Free Software Foundation. |
| 1428 | + |
| 1429 | +from autopilot import platform |
| 1430 | +from testtools import skipUnless |
| 1431 | + |
| 1432 | +import twitter_webapp |
| 1433 | + |
| 1434 | +class ClickWebappsLaunchTestCaseBase(TwitterWebappTestCase): |
| 1435 | + def setUp(self): |
| 1436 | + super(ClickWebappsLaunchTestCaseBase, self).setUp() |
| 1437 | + |
| 1438 | + def test_launch_twitter(self): |
| 1439 | + proxy = self.launch_application() |
| 1440 | + driver = self.get_webdriver() |
| 1441 | + |
| 1442 | + self.validate_title('twitter') |