webbrowser-app-0.23+14.04.20140428/0000755000015301777760000000000012327405043016777 5ustar pbusernogroup00000000000000webbrowser-app-0.23+14.04.20140428/cmake/0000755000015301777760000000000012327405043020057 5ustar pbusernogroup00000000000000webbrowser-app-0.23+14.04.20140428/cmake/FindLcov.cmake0000644000015301777760000000172012327404335022570 0ustar pbusernogroup00000000000000# - Find lcov # Will define: # # LCOV_EXECUTABLE - the lcov binary # GENHTML_EXECUTABLE - the genhtml executable # # Copyright (C) 2010 by Johannes Wienke # # This program is free software; you can redistribute it # and/or modify it under the terms of the GNU General # Public License as published by the Free Software Foundation; # either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # INCLUDE(FindPackageHandleStandardArgs) FIND_PROGRAM(LCOV_EXECUTABLE lcov) FIND_PROGRAM(GENHTML_EXECUTABLE genhtml) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lcov DEFAULT_MSG LCOV_EXECUTABLE GENHTML_EXECUTABLE) # only visible in advanced view MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE) webbrowser-app-0.23+14.04.20140428/cmake/EnableCoverageReport.cmake0000644000015301777760000001535012327404335025126 0ustar pbusernogroup00000000000000# - Creates a special coverage build type and target on GCC. # # Defines a function ENABLE_COVERAGE_REPORT which generates the coverage target # for selected targets. Optional arguments to this function are used to filter # unwanted results using globbing expressions. Moreover targets with tests for # the source code can be specified to trigger regenerating the report if the # test has changed # # ENABLE_COVERAGE_REPORT(TARGETS target... [FILTER filter...] [TESTS test targets...]) # # To generate a coverage report first build the project with # CMAKE_BUILD_TYPE=coverage, then call make test and afterwards make coverage. # # The coverage report is based on gcov. Depending on the availability of lcov # a HTML report will be generated and/or an XML report of gcovr is found. # The generated coverage target executes all found solutions. Special targets # exist to create e.g. only the xml report: coverage-xml. # # Copyright (C) 2010 by Johannes Wienke # # This program is free software; you can redistribute it # and/or modify it under the terms of the GNU General # Public License as published by the Free Software Foundation; # either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # INCLUDE(ParseArguments) FIND_PACKAGE(Lcov) FIND_PACKAGE(gcovr) FUNCTION(ENABLE_COVERAGE_REPORT) # argument parsing PARSE_ARGUMENTS(ARG "FILTER;TARGETS;TESTS;EXCLUDES" "" ${ARGN}) SET(COVERAGE_RAW_FILE "${CMAKE_BINARY_DIR}/coverage.raw.info") SET(COVERAGE_FILTERED_FILE "${CMAKE_BINARY_DIR}/coverage.info") SET(COVERAGE_REPORT_DIR "${CMAKE_BINARY_DIR}/coveragereport") SET(COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml") SET(COVERAGE_XML_COMMAND_FILE "${CMAKE_BINARY_DIR}/coverage-xml.cmake") # decide if there is any tool to create coverage data SET(TOOL_FOUND FALSE) IF(LCOV_FOUND OR GCOVR_FOUND) SET(TOOL_FOUND TRUE) ENDIF() IF(NOT TOOL_FOUND) MESSAGE(STATUS "Cannot enable coverage targets because neither lcov nor gcovr are found.") ENDIF() STRING(TOLOWER "${CMAKE_BUILD_TYPE}" COVERAGE_BUILD_TYPE) IF(CMAKE_COMPILER_IS_GNUCXX AND TOOL_FOUND AND "${COVERAGE_BUILD_TYPE}" MATCHES "coverage") MESSAGE(STATUS "Coverage support enabled for targets: ${ARG_TARGETS}") # create coverage build type SET(CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE) SET(CMAKE_C_FLAGS_COVERAGE ${CMAKE_C_FLAGS_DEBUG} PARENT_SCOPE) SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} coverage PARENT_SCOPE) # instrument targets SET_TARGET_PROPERTIES(${ARG_TARGETS} PROPERTIES COMPILE_FLAGS --coverage LINK_FLAGS --coverage) # html report IF (LCOV_FOUND) MESSAGE(STATUS "Enabling HTML coverage report") # set up coverage target ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_RAW_FILE} COMMAND ${LCOV_EXECUTABLE} -c -d ${CMAKE_BINARY_DIR} -o ${COVERAGE_RAW_FILE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Collecting coverage data" DEPENDS ${ARG_TARGETS} ${ARG_TESTS} VERBATIM) # filter unwanted stuff LIST(LENGTH ARG_FILTER FILTER_LENGTH) IF(${FILTER_LENGTH} GREATER 0) SET(FILTER COMMAND ${LCOV_EXECUTABLE}) FOREACH(F ${ARG_FILTER}) SET(FILTER ${FILTER} -r ${COVERAGE_FILTERED_FILE} ${F}) ENDFOREACH() SET(FILTER ${FILTER} -o ${COVERAGE_FILTERED_FILE}) ELSE() SET(FILTER "") ENDIF() ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_FILTERED_FILE} COMMAND ${LCOV_EXECUTABLE} -e ${COVERAGE_RAW_FILE} "${CMAKE_SOURCE_DIR}*" -o ${COVERAGE_FILTERED_FILE} ${FILTER} DEPENDS ${COVERAGE_RAW_FILE} COMMENT "Filtering recorded coverage data for project-relevant entries" VERBATIM) ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_REPORT_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_REPORT_DIR} COMMAND ${GENHTML_EXECUTABLE} --legend --show-details -t "${PROJECT_NAME} test coverage" -o ${COVERAGE_REPORT_DIR} ${COVERAGE_FILTERED_FILE} DEPENDS ${COVERAGE_FILTERED_FILE} COMMENT "Generating HTML coverage report in ${COVERAGE_REPORT_DIR}" VERBATIM) ADD_CUSTOM_TARGET(coverage-html DEPENDS ${COVERAGE_REPORT_DIR}) ENDIF() # xml coverage report IF(GCOVR_FOUND) MESSAGE(STATUS "Enabling XML coverage report") # gcovr cannot write directly to a file so the execution needs to # be wrapped in a cmake file that generates the file output FILE(WRITE ${COVERAGE_XML_COMMAND_FILE} "SET(ENV{LANG} en)\n") FILE(APPEND ${COVERAGE_XML_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND \"${GCOVR_EXECUTABLE}\" -x -e \"${ARG_EXCLUDES}\" -r \"${CMAKE_SOURCE_DIR}\" OUTPUT_FILE \"${COVERAGE_XML_FILE}\" WORKING_DIRECTORY \"${CMAKE_BINARY_DIR}\")\n") ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_XML_FILE} COMMAND ${CMAKE_COMMAND} ARGS -P ${COVERAGE_XML_COMMAND_FILE} COMMENT "Generating coverage XML report" VERBATIM) ADD_CUSTOM_TARGET(coverage-xml DEPENDS ${COVERAGE_XML_FILE}) ENDIF() # provide a global coverage target executing both steps if available SET(GLOBAL_DEPENDS "") IF(LCOV_FOUND) LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_REPORT_DIR}) ENDIF() IF(GCOVR_FOUND) LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_XML_FILE}) ENDIF() IF(LCOV_FOUND OR GCOVR_FOUND) ADD_CUSTOM_TARGET(coverage DEPENDS ${GLOBAL_DEPENDS}) ENDIF() ENDIF() ENDFUNCTION() webbrowser-app-0.23+14.04.20140428/cmake/Findgcovr.cmake0000644000015301777760000000170212327404335023005 0ustar pbusernogroup00000000000000# - Find gcovr scrip # Will define: # # GCOVR_EXECUTABLE - the gcovr script # # Uses: # # GCOVR_ROOT - root to search for the script # # Copyright (C) 2011 by Johannes Wienke # # This program is free software; you can redistribute it # and/or modify it under the terms of the GNU General # Public License as published by the Free Software Foundation; # either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # INCLUDE(FindPackageHandleStandardArgs) FIND_PROGRAM(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin") FIND_PACKAGE_HANDLE_STANDARD_ARGS(gcovr DEFAULT_MSG GCOVR_EXECUTABLE) # only visible in advanced view MARK_AS_ADVANCED(GCOVR_EXECUTABLE) webbrowser-app-0.23+14.04.20140428/cmake/ParseArguments.cmake0000644000015301777760000000340612327404335024027 0ustar pbusernogroup00000000000000# Parse arguments passed to a function into several lists separated by # upper-case identifiers and options that do not have an associated list e.g.: # # SET(arguments # hello OPTION3 world # LIST3 foo bar # OPTION2 # LIST1 fuz baz # ) # PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments}) # # results in 7 distinct variables: # * ARG_DEFAULT_ARGS: hello;world # * ARG_LIST1: fuz;baz # * ARG_LIST2: # * ARG_LIST3: foo;bar # * ARG_OPTION1: FALSE # * ARG_OPTION2: TRUE # * ARG_OPTION3: TRUE # # taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments MACRO(PARSE_ARGUMENTS prefix arg_names option_names) SET(DEFAULT_ARGS) FOREACH(arg_name ${arg_names}) SET(${prefix}_${arg_name}) ENDFOREACH(arg_name) FOREACH(option ${option_names}) SET(${prefix}_${option} FALSE) ENDFOREACH(option) SET(current_arg_name DEFAULT_ARGS) SET(current_arg_list) FOREACH(arg ${ARGN}) SET(larg_names ${arg_names}) LIST(FIND larg_names "${arg}" is_arg_name) IF (is_arg_name GREATER -1) SET(${prefix}_${current_arg_name} ${current_arg_list}) SET(current_arg_name ${arg}) SET(current_arg_list) ELSE (is_arg_name GREATER -1) SET(loption_names ${option_names}) LIST(FIND loption_names "${arg}" is_option) IF (is_option GREATER -1) SET(${prefix}_${arg} TRUE) ELSE (is_option GREATER -1) SET(current_arg_list ${current_arg_list} ${arg}) ENDIF (is_option GREATER -1) ENDIF (is_arg_name GREATER -1) ENDFOREACH(arg) SET(${prefix}_${current_arg_name} ${current_arg_list}) ENDMACRO(PARSE_ARGUMENTS) webbrowser-app-0.23+14.04.20140428/tests/0000755000015301777760000000000012327405043020141 5ustar pbusernogroup00000000000000webbrowser-app-0.23+14.04.20140428/tests/autopilot/0000755000015301777760000000000012327405043022161 5ustar pbusernogroup00000000000000webbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/0000755000015301777760000000000012327405043025202 5ustar pbusernogroup00000000000000webbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/tests/0000755000015301777760000000000012327405043026344 5ustar pbusernogroup00000000000000webbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/tests/test_chromeless.py0000644000015301777760000000223612327404335032127 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # # Copyright 2013 Canonical # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from __future__ import absolute_import from autopilot.introspection import dbus from webbrowser_app.tests import BrowserTestCaseBase class TestChromeless(BrowserTestCaseBase): """Tests the main browser features when run in chromeless mode.""" ARGS = ['--chromeless'] def test_chrome_is_not_loaded(self): try: self.main_window.get_chrome() except dbus.StateNotFoundError: pass else: self.fail("the chrome should not be loaded") ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000webbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/tests/test_addressbar_action_button.pywebbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/tests/test_addressbar_action_butto0000644000015301777760000000254412327404335034222 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # # Copyright 2013 Canonical # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from __future__ import absolute_import from testtools.matchers import Equals from autopilot.matchers import Eventually from webbrowser_app.tests import StartOpenRemotePageTestCaseBase class TestMainWindowAddressBarActionButton(StartOpenRemotePageTestCaseBase): def test_button_disabled_when_text_is_empty(self): self.assert_chrome_eventually_hidden() self.main_window.open_toolbar() self.clear_address_bar() action_button = self.main_window.get_address_bar_action_button() self.assertThat(action_button.enabled, Eventually(Equals(False))) self.type_in_address_bar("ubuntu") self.assertThat(action_button.enabled, Eventually(Equals(True))) webbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/tests/test_toolbar.py0000644000015301777760000000221112327404335031416 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # # Copyright 2013 Canonical # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from __future__ import absolute_import from webbrowser_app.tests import StartOpenRemotePageTestCaseBase class TestToolbar(StartOpenRemotePageTestCaseBase): """Tests interaction with the toolbar.""" def test_unfocus_chrome_hides_it(self): self.ensure_chrome_is_hidden() self.main_window.open_toolbar() webview = self.main_window.get_current_webview() self.pointing_device.click_object(webview) self.assert_chrome_eventually_hidden() webbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/tests/test_title.py0000644000015301777760000000311612327404335031102 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # # Copyright 2013 Canonical # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from __future__ import absolute_import from testtools.matchers import Contains from autopilot.matchers import Eventually from webbrowser_app.tests import StartOpenRemotePageTestCaseBase class TestWindowTitle(StartOpenRemotePageTestCaseBase): """Tests that the window’s title reflects the page title.""" def test_window_title(self): self.go_to_url(self.base_url + "/aleaiactaest") #window = self.app.select_single("QQuickWindow") # XXX: for some reason, autopilot finds two instances of QQuickWindow. # One is the correct one, and the other one is not visible, its # dimensions are 0×0, it has no title, its parent is the webbrowser-app # object, and it has no children. # See https://bugs.launchpad.net/bugs/1248620. window = self.app.select_single("QQuickWindow", visible=True) self.assertThat(window.title, Eventually(Contains("Alea Iacta Est"))) webbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/tests/test_errorsheet.py0000644000015301777760000000232412327404335032143 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # # Copyright 2013 Canonical # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from __future__ import absolute_import from testtools.matchers import Equals from autopilot.matchers import Eventually from webbrowser_app.tests import StartOpenRemotePageTestCaseBase class TestErrorSheet(StartOpenRemotePageTestCaseBase): """Tests the error message functionality.""" def test_invalid_url_triggers_error_message(self): error = self.main_window.get_error_sheet() self.assertThat(error.visible, Equals(False)) self.go_to_url("htpp://invalid") self.assertThat(error.visible, Eventually(Equals(True))) webbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/tests/test_activity.py0000644000015301777760000000245712327404335031624 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # # Copyright 2013 Canonical # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from __future__ import absolute_import from webbrowser_app.tests import StartOpenRemotePageTestCaseBase class TestActivity(StartOpenRemotePageTestCaseBase): """Tests the activity view.""" def test_validating_url_hides_activity_view(self): self.ensure_activity_view_visible() self.assert_chrome_eventually_hidden() self.main_window.open_toolbar() self.clear_address_bar() url = self.base_url + "/aleaiactaest" self.type_in_address_bar(url) self.keyboard.press_and_release("Enter") self.assert_activity_view_eventually_hidden() self.assert_page_eventually_loaded(url) webbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/tests/test_addressbar_states.py0000644000015301777760000000466012327404335033463 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # # Copyright 2013 Canonical # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from __future__ import absolute_import from testtools.matchers import Equals from autopilot.matchers import Eventually from webbrowser_app.tests import StartOpenRemotePageTestCaseBase class TestAddressBarStates(StartOpenRemotePageTestCaseBase): """Tests the address bar states.""" def test_state_idle_when_loaded(self): address_bar = self.main_window.get_address_bar() self.assertThat(address_bar.state, Eventually(Equals(""))) def test_state_loading_then_idle(self): self.assert_chrome_eventually_hidden() address_bar = self.main_window.get_address_bar() url = self.base_url + "/wait/2" self.go_to_url(url) self.assertThat(address_bar.state, Eventually(Equals("loading"))) self.assertThat(address_bar.state, Eventually(Equals(""))) def test_cancel_state_loading(self): self.assert_chrome_eventually_hidden() address_bar = self.main_window.get_address_bar() action_button = self.main_window.get_address_bar_action_button() url = self.base_url + "/wait/5" self.go_to_url(url) self.assertThat(address_bar.state, Eventually(Equals("loading"))) self.ensure_chrome_is_hidden() self.main_window.open_toolbar() self.pointing_device.click_object(action_button) self.assertThat(address_bar.state, Eventually(Equals(""))) def test_state_editing(self): address_bar = self.main_window.get_address_bar() self.assert_chrome_eventually_hidden() self.main_window.open_toolbar() self.pointing_device.click_object(address_bar) self.assertThat(address_bar.state, Eventually(Equals("editing"))) self.keyboard.press_and_release("Enter") self.assertThat(address_bar.state, Eventually(Equals(""))) webbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/tests/__init__.py0000644000015301777760000001627712327404335030475 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # # Copyright 2013 Canonical # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """webbrowser-app autopilot tests.""" import os import os.path import shutil import urllib2 from testtools.matchers import Contains, Equals from autopilot.matchers import Eventually from autopilot.platform import model from autopilot.testcase import AutopilotTestCase import http_server from ubuntuuitoolkit import emulators as toolkit_emulators from webbrowser_app.emulators.browser import Browser class BrowserTestCaseBase(AutopilotTestCase): """ A common test case class that provides several useful methods for webbrowser-app tests. """ local_location = "../../src/app/webbrowser/webbrowser-app" d_f = "--desktop_file_hint=/usr/share/applications/webbrowser-app.desktop" ARGS = [] def setUp(self): self.pointing_device = toolkit_emulators.get_pointing_device() super(BrowserTestCaseBase, self).setUp() if os.path.exists(self.local_location): self.launch_test_local() else: self.launch_test_installed() self.main_window.visible.wait_for(True) def launch_test_local(self): self.app = self.launch_test_application( self.local_location, *self.ARGS, emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) def launch_test_installed(self): if model() == 'Desktop': self.app = self.launch_test_application( "webbrowser-app", *self.ARGS, emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) else: self.app = self.launch_test_application( "webbrowser-app", "--fullscreen", self.d_f, *self.ARGS, app_type='qt', emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) def clear_cache(self): cachedir = os.path.join(os.path.expanduser("~"), ".local", "share", "webbrowser-app") shutil.rmtree(cachedir, True) os.makedirs(cachedir) @property def main_window(self): return self.app.select_single(Browser) def assert_osk_eventually_shown(self): if model() != 'Desktop': keyboardRectangle = self.main_window.get_keyboard_rectangle() self.assertThat(keyboardRectangle.state, Eventually(Equals("shown"))) def assert_osk_eventually_hidden(self): if model() != 'Desktop': keyboardRectangle = self.main_window.get_keyboard_rectangle() self.assertThat(keyboardRectangle.state, Eventually(Equals("hidden"))) def assert_chrome_eventually_shown(self): toolbar = self.main_window.get_toolbar() self.assertThat(toolbar.opened, Eventually(Equals(True))) self.assertThat(toolbar.animating, Eventually(Equals(False))) def assert_chrome_eventually_hidden(self): toolbar = self.main_window.get_toolbar() self.assertThat(toolbar.opened, Eventually(Equals(False))) self.assertThat(toolbar.animating, Eventually(Equals(False))) def ensure_chrome_is_hidden(self): webview = self.main_window.get_current_webview() self.pointing_device.click_object(webview) self.assert_chrome_eventually_hidden() self.assert_osk_eventually_hidden() def focus_address_bar(self): address_bar = self.main_window.get_address_bar() self.pointing_device.click_object(address_bar) self.assertThat(address_bar.activeFocus, Eventually(Equals(True))) self.assert_osk_eventually_shown() def clear_address_bar(self): self.focus_address_bar() self.assert_osk_eventually_shown() clear_button = self.main_window.get_address_bar_clear_button() self.pointing_device.click_object(clear_button) text_field = self.main_window.get_address_bar_text_field() self.assertThat(text_field.text, Eventually(Equals(""))) def type_in_address_bar(self, text): address_bar = self.main_window.get_address_bar() self.assertThat(address_bar.activeFocus, Eventually(Equals(True))) self.keyboard.type(text) text_field = self.main_window.get_address_bar_text_field() self.assertThat(text_field.text, Eventually(Contains(text))) def go_to_url(self, url): self.ensure_chrome_is_hidden() self.main_window.open_toolbar() self.clear_address_bar() self.type_in_address_bar(url) self.keyboard.press_and_release("Enter") self.assert_osk_eventually_hidden() def assert_page_eventually_loading(self): webview = self.main_window.get_current_webview() self.assertThat(webview.loading, Eventually(Equals(True))) def assert_page_eventually_loaded(self, url): webview = self.main_window.get_current_webview() self.assertThat(webview.url, Eventually(Equals(url))) # loadProgress == 100 ensures that a page has actually loaded self.assertThat(webview.loadProgress, Eventually(Equals(100), timeout=20)) self.assertThat(webview.loading, Eventually(Equals(False))) def assert_activity_view_eventually_hidden(self): self.assertThat(self.main_window.get_many_activity_view, Eventually(Equals([]))) def ensure_activity_view_visible(self): self.ensure_chrome_is_hidden() self.main_window.open_toolbar().click_button("activityButton") self.main_window.get_activity_view() def ping_server(self): ping = urllib2.urlopen(self.base_url + "/ping") self.assertThat(ping.read(), Equals("pong")) class StartOpenRemotePageTestCaseBase(BrowserTestCaseBase): """ Helper test class that opens the browser at a remote URL instead of defaulting to the homepage. This class should be preferred to the base test case class, as it doesn’t rely on a connection to the outside world (to open the default homepage), and because it ensures the initial page is fully loaded before the tests are executed, thus making them more robust. """ def setUp(self): self.server = http_server.HTTPServerInAThread() self.addCleanup(self.server.cleanup) self.base_url = "http://localhost:%d" % self.server.port self.ping_server() self.url = self.base_url + "/loremipsum" self.ARGS = [self.url] super(StartOpenRemotePageTestCaseBase, self).setUp() self.assert_home_page_eventually_loaded() def assert_home_page_eventually_loaded(self): self.assert_page_eventually_loaded(self.url) webbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/tests/test_progressbar.py0000644000015301777760000001027412327404335032315 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # # Copyright 2013 Canonical # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from __future__ import absolute_import from testtools.matchers import Equals from autopilot.matchers import Eventually import unittest from webbrowser_app.tests import \ http_server, \ BrowserTestCaseBase, \ StartOpenRemotePageTestCaseBase LOREMIPSUM = "

Lorem ipsum dolor sit amet.

" class TestProgressBarAtStartup(BrowserTestCaseBase): """Tests that the progress bar (embedded inside the address bar) is initially visible when loading a page.""" def setUp(self): self.server = http_server.HTTPServerInAThread() self.addCleanup(self.server.cleanup) self.base_url = "http://localhost:%d" % self.server.port self.ping_server() self.url = self.base_url + "/wait/8" self.ARGS = [self.url] super(TestProgressBarAtStartup, self).setUp() @unittest.skip("This test is flaky on slow configurations where the " "autopilot machinery takes longer to initialize than the " "hardcoded page load delay.") def test_chrome_initially_shown_then_hides_when_loaded(self): self.assert_chrome_eventually_shown() self.assert_page_eventually_loaded(self.url) self.assert_chrome_eventually_hidden() class TestProgressBar(StartOpenRemotePageTestCaseBase): """Tests that the progress bar (embedded inside the address bar) is visible when a page is loading and hidden by default otherwise.""" def test_chrome_hides_when_loaded(self): self.assert_chrome_eventually_hidden() url = self.base_url + "/wait/3" self.go_to_url(url) self.assert_chrome_eventually_shown() self.assert_page_eventually_loaded(url) self.assert_chrome_eventually_hidden() def test_load_page_from_link_reveals_chrome(self): url = self.base_url + "/clickanywherethenwait/3" self.go_to_url(url) self.assert_page_eventually_loaded(url) self.assert_chrome_eventually_hidden() webview = self.main_window.get_current_webview() self.pointing_device.click_object(webview) self.assert_chrome_eventually_shown() def test_hide_chrome_while_loading(self): # simulate user interaction to hide the chrome while loading, # and ensure it doesn’t re-appear when loaded self.assert_chrome_eventually_hidden() url = self.base_url + "/wait/3" self.go_to_url(url) self.assert_chrome_eventually_shown() webview = self.main_window.get_current_webview() self.pointing_device.click_object(webview) self.assert_chrome_eventually_hidden() self.assert_page_eventually_loaded(url) self.assert_chrome_eventually_hidden() def test_stop_loading(self): # ensure that the chrome is not automatically hidden # when the user interrupts a page that was loading self.assert_chrome_eventually_hidden() url = self.base_url + "/wait/5" self.go_to_url(url) self.assert_page_eventually_loading() self.assert_chrome_eventually_shown() address_bar = self.main_window.get_address_bar() self.assertThat(address_bar.state, Eventually(Equals("loading"))) action_button = self.main_window.get_address_bar_action_button() self.pointing_device.click_object(action_button) self.assertThat(address_bar.state, Eventually(Equals(""))) self.assert_chrome_eventually_shown() webview = self.main_window.get_current_webview() self.pointing_device.click_object(webview) self.assert_chrome_eventually_hidden() webbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/tests/test_content_pick.py0000644000015301777760000001476312327404335032453 0ustar pbusernogroup00000000000000# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- # # Copyright 2014 Canonical # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from __future__ import absolute_import from autopilot.introspection import get_proxy_object_for_existing_process from autopilot.matchers import Eventually from testtools.matchers import Equals, NotEquals from testtools import skip from webbrowser_app.tests import StartOpenRemotePageTestCaseBase from unity8 import process_helpers as helpers from ubuntuuitoolkit import emulators as toolkit_emulators import os import subprocess @skip("Will not work until bug #1218971 is solved") class TestContentPick(StartOpenRemotePageTestCaseBase): """Tests that content picking dialog show up.""" def test_pick_image(self): url = self.base_url + "/uploadform" self.go_to_url(url) self.assert_page_eventually_loaded(url) webview = self.main_window.get_current_webview() self.pointing_device.click_object(webview) dialog = self.app.wait_select_single("ContentPickerDialog") self.assertThat(dialog.visible, Equals(True)) #@skipIf(model() == 'Desktop', "Phablet only") @skip("Currently unable to fetch dynamically created dialogs (bug #1218971)") class TestContentPickerIntegration(StartOpenRemotePageTestCaseBase): """Tests that the gallery app is brought up to choose image content""" def tearDown(self): os.system("pkill gallery-app") os.system("pkill webbrowser-app") super(StartOpenRemotePageTestCaseBase, self).tearDown() def get_unity8_proxy_object(self): pid = helpers._get_unity_pid() return get_proxy_object_for_existing_process(pid) def get_current_focused_appid(self, unity8): return unity8.select_single("Shell").currentFocusedAppId def set_testability_environment_variable(self): """Makes sure every app opened in the environment loads the testability driver.""" subprocess.check_call([ "/sbin/initctl", "set-env", "QT_LOAD_TESTABILITY=1" ]) def get_app_pid(self, app): """Return the PID of the named app, or -1 if it's not running""" try: return int(subprocess.check_output(["pidof", app]).strip()) except subprocess.CalledProcessError: return -1 def wait_app_focused(self, name): """Wait until the app with the specified name is the currently focused one""" unity8 = self.get_unity8_proxy_object() self.assertThat( lambda: self.get_current_focused_appid(unity8), Eventually(Equals(name)) ) def test_image_picker_is_gallery(self): """ Tests that the gallery shows up when we are picking images """ # Go to a page where clicking anywhere equals clicking on the # file selection button of an upload form url = self.base_url + "/uploadform" self.go_to_url(url) self.assert_page_eventually_loaded(url) webview = self.main_window.get_current_webview() self.pointing_device.click_object(webview) # Verify that such a click brings up the gallery to select images self.wait_app_focused("gallery-app") def test_image_picker_pick_image(self): """ Tests that the we can select an image in the gallery and control will return to the browser with the choosen image picked.""" # First run the previous test to bring up the content picker self.set_testability_environment_variable() self.test_image_picker_is_gallery() # Now wait until the gallery-app process is up. # NOTE: this will not work unless run on a device where unity8 runs in # testability mode. To manually restart unity8 in this mode run from a # python shell: # from unity8 import process_helpers as p # p.restart_unity_with_testability() self.assertThat(lambda: self.get_app_pid("gallery-app"), Eventually(NotEquals(-1))) gallery = get_proxy_object_for_existing_process( self.get_app_pid("gallery-app"), emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase ) # Wait for the gallery UI to completely display view = gallery.wait_select_single("QQuickView") self.assertThat(view.visible, Eventually(Equals(True))) # Select the first picture on the picker by clicking on it # NOTE: this is currently failing if there is anything except two # pictures in the gallery (at least on a Maguro device), so I'm # putting a temporary stop to the test here so that it won't break # in Jenkins return grid = gallery.wait_select_single("MediaGrid") photo = grid.select_many("OrganicItemInteraction")[0] self.pointing_device.click_object(photo) self.assertThat(photo.isSelected, Eventually(Equals(True))) # Now the "Pick" button will be enabled and we click on it button = gallery.select_single("Button", objectName="pickButton") self.assertThat(button.enabled, Eventually(Equals(True))) self.pointing_device.click_object(button) # The gallery should close and focus returned to the browser self.wait_app_focused("webbrowser-app") # Verify that an image has actually been selected dialog = self.app.wait_select_single("ContentPickerDialog") self.assertThat(dialog.visible, Equals(True)) preview = dialog.wait_select_single("QQuickImage", objectName="mediaPreview") self.assertThat(preview.source, Eventually(NotEquals(""))) # Verify that now we can click the "OK" button and it closes the dialog button = dialog.wait_select_single("Button", objectName="ok") self.assertThat(button.enabled, Eventually(Equals(True))) self.pointing_device.click_object(button) self.assertThat(dialog.visible, Eventually(Equals(False))) webbrowser-app-0.23+14.04.20140428/tests/autopilot/webbrowser_app/tests/http_server.py0000644000015301777760000001177112327404335031275 0ustar pbusernogroup00000000000000# -*- coding: utf-8 -*- # # Copyright 2013 Canonical # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. import BaseHTTPServer import logging import threading import time logger = logging.getLogger(__name__) class HTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """ A custom HTTP request handler that serves GET resources. """ def make_html(self, title, body): return "%s%s" % (title, body) def send_html(self, html): self.send_header("Content-Type", "text/html") self.end_headers() self.wfile.write(html) def do_GET(self): if self.path == "/ping": self.send_response(200) self.send_header("Content-Type", "text/plain") self.end_headers() self.wfile.write("pong") elif self.path == "/loremipsum": self.send_response(200) title = "Lorem Ipsum" body = "

Lorem ipsum dolor sit amet.

" html = self.make_html(title, body) self.send_html(html) elif self.path == "/aleaiactaest": self.send_response(200) title = "Alea Iacta Est" body = "

De vita Caesarum libri VIII

" html = self.make_html(title, body) self.send_html(html) elif self.path.startswith("/wait/"): delay = int(self.path[6:]) self.send_response(200) title = "waiting %d seconds" % delay body = "

this page took %d seconds to load

" % delay html = self.make_html(title, body) time.sleep(delay) self.send_html(html) elif self.path.startswith("/clickanywherethenwait/"): # craft a page that accepts clicks anywhere inside its window # and that redirects to a page that takes some time to load delay = int(self.path[23:]) self.send_response(200) html = '' html += '' % delay html += '
' html += '' self.send_html(html) elif self.path == "/blanktargetlink": # craft a page that accepts clicks anywhere inside its window # and that requests opening another page in a new tab self.send_response(200) html = '' html += '' html += '
' html += '' self.send_html(html) elif self.path == "/fulliframewithblanktargetlink": # iframe that takes up the whole page and that contains # the page above self.send_response(200) html = '' html += '