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

Commit

Permalink
Merge pull request #32614 from mwargers/1216564
Browse files Browse the repository at this point in the history
Bug 1216564 - Fix launch{_packaged}_app.py tests in order to support the new homescreen
  • Loading branch information
mwargers committed Oct 21, 2015
2 parents b5acf3a + 2f50295 commit 40339f9
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 68 deletions.
71 changes: 28 additions & 43 deletions tests/python/gaia-ui-tests/gaiatest/apps/homescreen/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,27 @@ class Homescreen(Base):
_divider_separator_locator = (By.CSS_SELECTOR, 'section.divider .separator > span')
_exit_edit_mode_locator = (By.ID, 'exit-edit-mode')

def launch(self):
Base.launch(self)

def tap_search_bar(self):
search_bar = self.marionette.find_element(*self._search_bar_icon_locator)
search_bar.tap()

# TODO These lines are a workaround for bug 1020974
import time
time.sleep(1)
self.marionette.switch_to_frame()
Wait(self.marionette).until(lambda m: not self.keyboard.is_keyboard_displayed)
self.marionette.find_element('id', 'rocketbar-form').tap()
Wait(self.marionette).until(lambda m: self.keyboard.is_keyboard_displayed)
_body_dragging_locator = (By.CSS_SELECTOR, 'body.dragging')
_apps_locator = (By.ID, 'apps')
_app_icon_locator = (By.CSS_SELECTOR, 'gaia-app-icon[data-identifier="%s"]')
_remove_locator = (By.ID, 'remove')

from gaiatest.apps.homescreen.regions.search_panel import SearchPanel
return SearchPanel(self.marionette)
def launch(self):
Base.launch(self)

def wait_for_app_icon_present(self, app_name):
Wait(self.marionette, timeout=30).until(lambda m: self.installed_app(app_name))
def wait_for_app_icon_present(self, app_manifest):
Wait(self.marionette, timeout=30).until(lambda m: self.installed_app(app_manifest))

def wait_for_app_icon_not_present(self, app_name):
Wait(self.marionette).until(lambda m: self.installed_app(app_name) is None)
def wait_for_app_icon_not_present(self, app_manifest):
Wait(self.marionette).until(lambda m: self.installed_app(app_manifest) is None)

def wait_for_bookmark_icon_not_present(self, bookmark_title):
Wait(self.marionette).until(lambda m: self.bookmark(bookmark_title) is None)

def is_app_installed(self, app_name):
def is_app_installed(self, app_manifest):
"""Checks whether app is installed"""
return self.installed_app(app_name) is not None
return self.installed_app(app_manifest) is not None

def activate_edit_mode(self):
app = self.marionette.find_element(*self._homescreen_all_icons_locator)
Expand Down Expand Up @@ -158,11 +149,17 @@ def visible_apps(self):
def wait_for_number_of_apps(self, number_of_apps=1):
Wait(self.marionette).until(lambda m: len(self.app_elements) >= number_of_apps)

def installed_app(self, app_name):
for root_el in self.marionette.find_elements(*self._homescreen_all_icons_locator):
if root_el.text == app_name and (root_el.get_attribute('data-app-state') == 'ready' or
'bookmark' in root_el.get_attribute('class') or 'collection' in root_el.get_attribute('class')):
return self.InstalledApp(self.marionette, root_el)
def installed_app(self, app_manifest):
apps_container = self.marionette.find_elements(*self._apps_locator)
self.marionette.switch_to_shadow_root(apps_container)
icon_locator = (
self._app_icon_locator[0],
self._app_icon_locator[1] % app_manifest
)
_test_locator = (By.CSS_SELECTOR, 'gaia-app-icon')
element = self.marionette.find_element(*_test_locator)
app_icon = self.marionette.find_element(*icon_locator)
return self.InstalledApp(self.marionette, app_icon)

def bookmark(self, bookmark_title):
for root_el in self.marionette.find_elements(*self._bookmark_icons_locator):
Expand All @@ -177,24 +174,12 @@ def number_of_columns(self):

class InstalledApp(PageRegion):

_delete_app_locator = (By.CSS_SELECTOR, 'span.remove')

@property
def name(self):
return self.root_element.text
def manifest_url(self):
return self.root_element.get_attribute('data-identifier')

def tap_icon(self):
expected_name = self.name

# TODO bug 1043293 introduced a timing/tap race issue here
time.sleep(0.5)
self.root_element.tap(y=1)
Wait(self.marionette).until(lambda m: self.apps.displayed_app.name.lower() == expected_name.lower())
expected_manifest_url = self.manifest_url
self.root_element.tap()
Wait(self.marionette).until(lambda m: self.apps.displayed_app.manifest_url == expected_manifest_url)
self.apps.switch_to_displayed_app()

def tap_delete_app(self):
"""Tap on (x) to delete app"""
self.root_element.find_element(*self._delete_app_locator).tap()

from gaiatest.apps.homescreen.regions.confirm_dialog import ConfirmDialog
return ConfirmDialog(self.marionette)
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ disabled = Bug 1216084 - Fix the Gaia UI tests that are failing because of the n
[test_homescreen_launch_app.py]
smoketest = true
online = true
disabled = Bug 1216084 - Fix the Gaia UI tests that are failing because of the new Homescreen

[test_homescreen_launch_app_packaged.py]
smoketest = true
online = true
disabled = Bug 1216084 - Fix the Gaia UI tests that are failing because of the new Homescreen

[test_homescreen_move_app.py]
smoketest = true
Expand All @@ -48,4 +46,3 @@ disabled = Bug 1216084 - Fix the Gaia UI tests that are failing because of the n

[test_spark_apps_present.py]
spark = true
disabled = Bug 1216084 - Fix the Gaia UI tests that are failing because of the new Homescreen
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def setUp(self):

self.test_data = {
'name': 'Mozilla QA WebRT Tester',
'url': self.marionette.absolute_url('webapps/mozqa.com/manifest.webapp')}
'manifest': self.marionette.absolute_url('webapps/mozqa.com/manifest.webapp')}
self.logger.info('Test data: %s' % self.test_data)

# Install app
self.marionette.execute_script(
'navigator.mozApps.install("%s")' % self.test_data['url'])
'navigator.mozApps.install("%s")' % self.test_data['manifest'])

# Confirm the installation and wait for the app icon to be present
confirm_install = ConfirmInstall(self.marionette)
Expand All @@ -38,16 +38,16 @@ def setUp(self):
system.wait_for_system_banner_not_displayed()

self.apps.switch_to_displayed_app()
self.homescreen.wait_for_app_icon_present(self.test_data['name'])
self.homescreen.wait_for_app_icon_present(self.test_data['manifest'])

def test_launch_app(self):
# Verify that the app icon is visible on one of the homescreen pages
self.assertTrue(
self.homescreen.is_app_installed(self.test_data['name']),
'App %s not found on homescreen' % self.test_data['name'])
self.homescreen.is_app_installed(self.test_data['manifest']),
'App %s not found on homescreen' % self.test_data['manifest'])

# Click icon and wait for h1 element displayed
self.homescreen.installed_app(self.test_data['name']).tap_icon()
self.homescreen.installed_app(self.test_data['manifest']).tap_icon()
Wait(self.marionette).until(
lambda m: m.title == self.test_data['name'])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def setUp(self):

self.test_data = {
'name': 'packagedapp1',
'url': self.marionette.absolute_url('webapps/packaged1/manifest.webapp'),
'manifest': self.marionette.absolute_url('webapps/packaged1/manifest.webapp'),
'title': 'Packaged app1'}

# Install app
self.marionette.execute_script(
'navigator.mozApps.installPackage("%s")' % self.test_data['url'])
'navigator.mozApps.installPackage("%s")' % self.test_data['manifest'])

# Confirm the installation and wait for the app icon to be present
confirm_install = ConfirmInstall(self.marionette)
Expand All @@ -38,17 +38,17 @@ def setUp(self):
system.wait_for_system_banner_not_displayed()

self.apps.switch_to_displayed_app()
self.homescreen.wait_for_app_icon_present(self.test_data['name'])
self.homescreen.wait_for_app_icon_present(self.test_data['manifest'])

def test_launch_app(self):
"""https://moztrap.mozilla.org/manage/case/6116/"""
# Verify that the app icon is visible on one of the homescreen pages
self.assertTrue(
self.homescreen.is_app_installed(self.test_data['name']),
'App %s not found on homescreen' % self.test_data['name'])
self.homescreen.is_app_installed(self.test_data['manifest']),
'App %s not found on homescreen' % self.test_data['manifest'])

# Click icon and wait for h1 element displayed
self.homescreen.installed_app(self.test_data['name']).tap_icon()
self.homescreen.installed_app(self.test_data['manifest']).tap_icon()
Wait(self.marionette).until(
lambda m: m.title == self.test_data['title'])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ class TestSparkAppsArePresent(GaiaTestCase):
def test_spark_apps_are_present(self):
homescreen = Homescreen(self.marionette)
self.apps.switch_to_displayed_app()
for expected_app in ('Customizer', 'Hackerplace', 'Studio', 'Sharing', 'Webmaker', 'Bugzilla Lite', 'Facebook',
'Twitter', 'RunWhatsApp (Preview)', 'BuddyUp', 'Notes', 'Calculator', 'SWOOOP',
'Firesea IRC'):
homescreen.wait_for_app_icon_present(expected_app)
for expected_app in ({'name': 'Customizer', 'manifest': 'app://customizer-launcher.gaiamobile.org/manifest.webapp'},
{'name': 'Hackerplace', 'manifest': 'app://directory.gaiamobile.org/manifest.webapp'},
{'name': 'Studio', 'manifest': 'app://studio.gaiamobile.org/manifest.webapp'},
{'name': 'Sharing', 'manifest': 'app://sharing.gaiamobile.org/manifest.webapp'},
{'name': 'Webmaker', 'manifest': 'http://webmaker.fxosapps.org/manifest.webapp'},
{'name': 'Bugzilla Lite', 'manifest': 'https://www.bzlite.com/manifest.webapp'},
{'name': 'Facebook', 'manifest': 'https://m.facebook.com/openwebapp/manifest.webapp'},
{'name': 'Twitter', 'manifest': 'https://mobile.twitter.com/cache/twitter.webapp'},
{'name': 'RunWhatsApp (Preview)', 'manifest': 'https://marketplace.firefox.com/app/f2ed31a0-05ed-416b-ac0d-0f26db063839/manifest.webapp'},
{'name': 'BuddyUp', 'manifest': 'https://marketplace.firefox.com/app/8d979279-a142-4fee-993b-8e7797b221a5/manifest.webapp'},
{'name': 'Notes', 'manifest': 'https://marketplace.firefox.com/app/dcdaeefc-26f4-4af6-ad22-82eb93beadcd/manifest.webapp'},
{'name': 'Calculator', 'manifest': 'https://marketplace.firefox.com/app/9f96ce77-5b2d-42ca-a0d9-10a933dd84c4/manifest.webapp'},
{'name': 'SWOOOP', 'manifest': 'https://marketplace.firefox.com/app/be9138a3-9672-4796-9c27-0f27aaced70a/manifest.webapp'},
{'name': 'Firesea IRC', 'manifest': 'http://operatorvariant.fxosapps.org/manifest.webapp'}):
homescreen.wait_for_app_icon_present(expected_app['manifest'])
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from gaiatest import GaiaTestCase
from gaiatest.apps.homescreen.app import Homescreen
from gaiatest.apps.marketplace.app import Marketplace
from marionette_driver import expected, By, Wait


Expand All @@ -18,14 +19,14 @@ def setUp(self):

def test_marketplace_launch(self):

app_name = 'Marketplace'
marketplace = Marketplace(self.marionette)
homescreen = Homescreen(self.marionette)
self.apps.switch_to_displayed_app()

self.assertTrue(homescreen.is_app_installed(app_name))
self.assertTrue(homescreen.is_app_installed(marketplace.manifest_url))

marketplace = homescreen.installed_app(app_name)
marketplace.tap_icon()
marketplace_icon = homescreen.installed_app(marketplace.manifest_url)
marketplace_icon.tap_icon()

Wait(self.marionette, timeout=60).until(expected.element_present(*self._marketplace_iframe_locator))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class TestSearchMarketplaceAndInstallApp(GaiaTestCase):
app_search = 'test-webapi-permissions :packaged'
app_title = 'Privileged App Test'
app_name = 'premium packaged app'
app_manifest = 'https://marketplace.firefox.com/app/9b628257-c986-47aa-bdb9-a654ec355108/manifest.webapp'

def setUp(self):
GaiaTestCase.setUp(self)
Expand All @@ -40,9 +41,9 @@ def test_search_and_install_app(self):

# Check that the icon of the app is on the homescreen
homescreen = Homescreen(self.marionette)
homescreen.wait_for_app_icon_present(self.app_name)
homescreen.wait_for_app_icon_present(self.app_manifest)

installed_app = homescreen.installed_app(self.app_name)
installed_app = homescreen.installed_app(self.app_manifest)
installed_app.tap_icon()

Wait(self.marionette).until(lambda m: m.title == self.app_title)
Expand Down

0 comments on commit 40339f9

Please sign in to comment.