Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1059245 - Update tests and framework to use the new Browser app
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Chira authored and Robert Chira committed Sep 3, 2014
1 parent f5e8465 commit 25bb142
Show file tree
Hide file tree
Showing 21 changed files with 163 additions and 246 deletions.
4 changes: 2 additions & 2 deletions tests/python/gaia-ui-tests/gaiatest/apps/base.py
Expand Up @@ -20,8 +20,8 @@ def __init__(self, marionette):
self.apps = GaiaApps(self.marionette)
self.accessibility = Accessibility(self.marionette)
self.frame = None
self.manifest_url = None
self.entry_point = None
self.manifest_url = hasattr(self, 'manifest_url') and self.manifest_url or None
self.entry_point = hasattr(self, 'entry_point') and self.entry_point or None

def launch(self, launch_timeout=None):
self.app = self.apps.launch(self.name, self.manifest_url, self.entry_point, launch_timeout=launch_timeout)
Expand Down
148 changes: 0 additions & 148 deletions tests/python/gaia-ui-tests/gaiatest/apps/browser/app.py

This file was deleted.

Expand Up @@ -30,6 +30,10 @@ def tap_add_bookmark_to_home_screen_dialog_button(self):

def type_bookmark_title(self, value):
element = self.marionette.find_element(*self._bookmark_title_input_locator)

# Wait for the default value to load into the input field
self.wait_for_condition(lambda m: element.get_attribute('value') != "")
element.clear()

self.keyboard.send(value)
self.keyboard.dismiss()
Expand Up @@ -26,6 +26,9 @@ def type_into_search_box(self, search_term):
# The search results frame is not findable with AppWindowManager
self._switch_to_search_results_frame()

def go_to_url(self, url):
self.keyboard.send(url, self.keyboard._enter_key)

def wait_for_everything_me_results_to_load(self, minimum_expected_results=1):
self.wait_for_condition(lambda m: len(m.find_elements(*self._search_results_locator))
> minimum_expected_results)
Expand Down
5 changes: 4 additions & 1 deletion tests/python/gaia-ui-tests/gaiatest/apps/keyboard/app.py
Expand Up @@ -215,7 +215,7 @@ def enable_caps_lock(self):
self.apps.switch_to_displayed_app()

# this would go through fastest way to tap/click through a string
def send(self, string):
def send(self, string, tap_key_at_end=None):
self.switch_to_keyboard()
for val in string:
if ord(val) > 127:
Expand All @@ -237,6 +237,9 @@ def send(self, string):
self._switch_to_correct_layout(val)
self._tap(val)

if tap_key_at_end:
self._tap(tap_key_at_end)

self.apps.switch_to_displayed_app()

# Switch keyboard language
Expand Down
30 changes: 30 additions & 0 deletions tests/python/gaia-ui-tests/gaiatest/apps/search/app.py
@@ -0,0 +1,30 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from gaiatest.apps.base import Base
from marionette.by import By


class Search(Base):

name = 'Browser'
manifest_url = "app://search.gaiamobile.org/manifest.webapp"

_url_bar_locator = (By.CSS_SELECTOR, 'div.search-app .urlbar .title')

def launch(self):
Base.launch(self)
self.wait_for_condition(lambda m: self.apps.displayed_app.name == self.name)
self.wait_for_element_displayed(*self._url_bar_locator)

def go_to_url(self, url):
self.marionette.find_element(*self._url_bar_locator).tap()

from gaiatest.apps.homescreen.regions.search_panel import SearchPanel
search_panel = SearchPanel(self.marionette)
search_panel.go_to_url(url)
self.wait_for_condition(lambda m: url in self.apps.displayed_app.name)

from regions.browser import Browser
return Browser(self.marionette)
67 changes: 67 additions & 0 deletions tests/python/gaia-ui-tests/gaiatest/apps/search/regions/browser.py
@@ -0,0 +1,67 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from gaiatest.apps.base import Base
from marionette.by import By


class Browser(Base):

_browser_app_locator = (By.CSS_SELECTOR, 'div.browser[transition-state="opened"]')
_browser_frame_locator = (By.CSS_SELECTOR, 'iframe.browser')

_menu_button_locator = (By.CSS_SELECTOR, '.menu-button')
_add_to_home_button_locator = (By.ID, 'add-to-home')
_browser_menu_locator = (By.CSS_SELECTOR, '.overflow-menu')

_back_button_locator = (By.CSS_SELECTOR, '.back-button')
_forward_button_locator = (By.CSS_SELECTOR, '.forward-button')

def __init__(self, marionette):
Base.__init__(self, marionette)
self.marionette.switch_to_frame()
self._root_element = self.marionette.find_element(*self._browser_app_locator)

def switch_to_content(self):
web_frame = self._root_element.find_element(*self._browser_frame_locator)
self.marionette.switch_to_frame(web_frame)

def switch_to_chrome(self):
self.marionette.switch_to_frame()

@property
def is_page_loading(self):
return "loading" in self._root_element.value_of_css_property('class')

def wait_for_page_to_load(self, timeout=30):
self.wait_for_condition(lambda m: not self.is_page_loading, timeout=timeout)

def tap_menu_button(self):
self._root_element.find_element(*self._menu_button_locator).tap()
self.wait_for_element_displayed(*self._browser_menu_locator)

def tap_add_to_home(self):
self.wait_for_element_displayed(*self._add_to_home_button_locator)
self._root_element.find_element(*self._add_to_home_button_locator).tap()
from gaiatest.apps.homescreen.regions.bookmark_menu import BookmarkMenu

return BookmarkMenu(self.marionette)

@property
def url(self):
return self._root_element.find_element(*self._browser_frame_locator).get_attribute('data-url')

@property
def data_origin(self):
return self._root_element.find_element(*self._browser_frame_locator).get_attribute('data-frame-origin')

def tap_back_button(self):
current_url = self.url
self._root_element.find_element(*self._back_button_locator).tap()
self.wait_for_condition(lambda m: self.url != current_url)

def tap_forward_button(self):
current_url = self.url
self._root_element.find_element(*self._forward_button_locator).tap()
self.wait_for_condition(lambda m: self.url != current_url)
Expand Up @@ -18,8 +18,6 @@ skip-if = device == "desktop"
lan = true
smoketest = true

[test_browser_tabs.py]

[test_browser_search.py]

[test_browser_navigation.py]
Expand Down
Expand Up @@ -5,8 +5,8 @@
import time

from gaiatest import GaiaTestCase
from gaiatest.apps.browser.app import Browser
from gaiatest.apps.homescreen.app import Homescreen
from gaiatest.apps.search.app import Search


class TestBrowserBookmark(GaiaTestCase):
Expand All @@ -16,6 +16,7 @@ class TestBrowserBookmark(GaiaTestCase):
def setUp(self):
GaiaTestCase.setUp(self)
self.connect_to_network()
self.apps.set_permission_by_url(Search.manifest_url, 'geolocation', 'deny')

if self.device.is_desktop_b2g or self.data_layer.is_wifi_connected():
self.test_url = self.marionette.absolute_url('mozilla.html')
Expand All @@ -26,13 +27,13 @@ def setUp(self):
self.bookmark_title = 'gaia%s' % curr_time[10:]

def test_browser_bookmark(self):
browser = Browser(self.marionette)
browser.launch()
search = Search(self.marionette)
search.launch()

browser.go_to_url(self.test_url)
browser.tap_bookmark_button()
browser = search.go_to_url(self.test_url)
browser.tap_menu_button()
bookmark = browser.tap_add_to_home()

bookmark = browser.tap_add_bookmark_to_home_screen_choice_button()
bookmark.type_bookmark_title(self.bookmark_title)
bookmark.tap_add_bookmark_to_home_screen_dialog_button()

Expand Down
Expand Up @@ -5,7 +5,7 @@
from marionette.by import By

from gaiatest import GaiaTestCase
from gaiatest.apps.browser.app import Browser
from gaiatest.apps.search.app import Search


class TestBrowserCellData(GaiaTestCase):
Expand All @@ -14,15 +14,18 @@ class TestBrowserCellData(GaiaTestCase):

def setUp(self):
GaiaTestCase.setUp(self)
self.apps.set_permission_by_url(Search.manifest_url, 'geolocation', 'deny')

self.data_layer.connect_to_cell_data()

def test_browser_cell_data(self):
"""https://moztrap.mozilla.org/manage/case/1328/"""

browser = Browser(self.marionette)
browser.launch()
search = Search(self.marionette)
search.launch()

browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html', timeout=120)
browser = search.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html')
browser.wait_for_page_to_load(120)

browser.switch_to_content()

Expand Down

0 comments on commit 25bb142

Please sign in to comment.