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 #20158 from yzen/bug-1018214
Browse files Browse the repository at this point in the history
Bug 1018214, Bug 1021710 - utility tray gaia-ui tests with some tweaks to hopefully avoid intermittents.
  • Loading branch information
yzen committed Jun 13, 2014
2 parents ac161f0 + 024e1f5 commit fe4842a
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 16 deletions.
43 changes: 27 additions & 16 deletions tests/atoms/accessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
'use strict';

var Accessibility = {
_getAccessible: function Accessibility__getAccessible(element, callback) {
let gAccRetrieval = SpecialPowers.Cc[
"@mozilla.org/accessibleRetrieval;1"].getService(
SpecialPowers.Ci.nsIAccessibleRetrieval);
let attempts = 0;
let intervalId = setInterval(function() {
let acc = gAccRetrieval.getAccessibleFor(element);
if (acc || ++attempts > 10) {
clearInterval(intervalId);

_accRetrieval: SpecialPowers.Cc[
"@mozilla.org/accessibleRetrieval;1"].getService(
SpecialPowers.Ci.nsIAccessibleRetrieval),

_getAccessible:
function Accessibility__getAccessible(element, callback, once) {
let acc = this._accRetrieval.getAccessibleFor(element);
if (acc || once) {
callback(acc);
} else {
setTimeout(this._getAccessible.bind(this), 10, element, callback);
}
}, 10);
},
},

_matchState: function Accessibility__matchState(acc, stateName) {
let stateToMatch = SpecialPowers.wrap(
Expand All @@ -35,6 +36,19 @@ var Accessibility = {
});
},

wheel: function Accessibility_wheel(element, direction) {
let horizontal = direction === "left" || direction === "right";
let page = (direction === "left" || direction === "up") ? 1 : -1;
let event = new window.wrappedJSObject.WheelEvent('wheel', {
bubbles: true,
cancelable: true,
deltaX: horizontal ? page : 0,
deltaY: horizontal ? 0 : page,
deltaMode: window.wrappedJSObject.WheelEvent.DOM_DELTA_PAGE,
});
element.wrappedJSObject.dispatchEvent(event);
},

isDisabled: function Accessibility_isDisabled(element) {
this._getAccessible(element.wrappedJSObject, (acc) => {
this._matchState(acc, 'STATE_UNAVAILABLE');
Expand All @@ -58,7 +72,7 @@ var Accessibility = {
return;
}
this._matchState(acc, 'STATE_INVISIBLE');
});
}, true);
},

getName: function Accessibility_getName(element) {
Expand All @@ -69,10 +83,7 @@ var Accessibility = {

getRole: function Accessibility_getRole(element) {
this._getAccessible(element.wrappedJSObject, (acc) => {
let gAccRetrieval = SpecialPowers.Cc[
"@mozilla.org/accessibleRetrieval;1"].getService(
SpecialPowers.Ci.nsIAccessibleRetrieval);
marionetteScriptFinished(gAccRetrieval.getStringRole(acc.role));
marionetteScriptFinished(this._accRetrieval.getStringRole(acc.role));
});
},
};
1 change: 1 addition & 0 deletions tests/python/gaia-ui-tests/gaiatest/apps/system/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class System(Base):
_status_bar_notification_locator = (By.ID, 'statusbar-notification')
_geoloc_statusbar_locator = (By.ID, 'statusbar-geolocation')
_airplane_mode_statusbar_locator = (By.ID, 'statusbar-flight-mode')
_utility_tray_locator = (By.ID, 'utility-tray')

_notification_toaster_locator = (By.ID, 'notification-toaster')
_update_manager_toaster_locator = (By.ID, 'update-manager-toaster')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 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 marionette.by import By
from gaiatest.apps.base import Base


class StatusBar(Base):
_status_bar_time_locator = (By.ID, 'statusbar-time')

def a11y_wheel_status_bar_time(self):
self.accessibility.wheel(self.marionette.find_element(
*self._status_bar_time_locator), 'down')
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
from marionette.by import By
from gaiatest.apps.base import Base
from gaiatest.apps.base import PageRegion
from gaiatest.apps.settings.app import Settings
from gaiatest.apps.system.app import System


class UtilityTray(Base):
_notification_container_locator = (By.ID, 'notifications-container')
_desktop_notifications_locator = (By.CSS_SELECTOR, '#desktop-notifications-container .notification')
_notification_clear_locator = (By.ID, 'notification-clear')
_quicksettings_app_locator = (By.ID, 'quick-settings-full-app')
_grippy_locator = (By.ID, 'utility-tray-grippy')
_quick_settings_full_app_locator = (By.ID, 'quick-settings-full-app')

def wait_for_notification_container_displayed(self):
# Marionette cannot read the displayed state of the notification container so we wait for its location
Expand All @@ -25,9 +29,23 @@ def notifications(self):
def clear_all_notifications(self):
self.marionette.find_element(*self._notification_clear_locator).tap()

def a11y_clear_all_notifications(self):
self.accessibility.click(self.marionette.find_element(*self._notification_clear_locator))

def tap_settings_button(self):
self.marionette.find_element(*self._quicksettings_app_locator).tap()

def a11y_wheel_utility_tray_grippy(self):
self.accessibility.wheel(self.marionette.find_element(
*self._grippy_locator), 'up')
self.wait_for_element_not_displayed(*System(self.marionette)._utility_tray_locator)

def a11y_click_quick_settings_full_app(self):
self.accessibility.click(self.marionette.find_element(
*self._quick_settings_full_app_locator))
return Settings(self.marionette)


class Notification(PageRegion):
_body_locator = (By.CSS_SELECTOR, 'div.detail')
_title_locator = (By.CSS_SELECTOR, 'div.title')
Expand Down
4 changes: 4 additions & 0 deletions tests/python/gaia-ui-tests/gaiatest/gaia_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ def click(self, element):
'Accessibility.click.apply(Accessibility, arguments)',
[element], special_powers=True)

def wheel(self, element, direction):
self.marionette.execute_script('Accessibility.wheel.apply(Accessibility, arguments)', [
element, direction])

def get_name(self, element):
return self.marionette.execute_async_script(
'return Accessibility.getName.apply(Accessibility, arguments)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
b2g = true

[test_a11y_notification_visibility.py]
[test_a11y_utility_tray_notifications.py]
[test_a11y_utility_tray_settings.py]
[test_a11y_utility_tray_visibility.py]
[test_a11y_volume_buttons.py]
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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 marionette.by import By
from gaiatest import GaiaTestCase
from gaiatest.apps.system.app import System


class TestUtilityTrayNotificationsAccessibility(GaiaTestCase):

def setUp(self):
GaiaTestCase.setUp(self)
self.system = System(self.marionette)

def test_a11y_utility_tray_notifications(self):
self.system.wait_for_status_bar_displayed()

utility_tray = self.system.open_utility_tray()
utility_tray.wait_for_notification_container_displayed()

self.marionette.execute_script('new Notification("Title", {body: "Body"});')
# Assert there is one notification is listed in notifications-container
notifications = utility_tray.notifications
self.assertEqual(1, len(notifications), 'Expected one notification.')

# Clear the notification by "Clear all"
utility_tray.a11y_clear_all_notifications()

# wait for the notifications to be cleared
self.wait_for_condition(lambda m: len(utility_tray.notifications) == 0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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 import GaiaTestCase
from gaiatest.apps.system.app import System


class TestUtilityTraySettingsAccessibility(GaiaTestCase):

def setUp(self):
GaiaTestCase.setUp(self)
self.system = System(self.marionette)

def test_a11y_utility_tray_settings(self):
self.system.wait_for_status_bar_displayed()

utility_tray = self.system.open_utility_tray()
utility_tray.wait_for_notification_container_displayed()

settings = utility_tray.a11y_click_quick_settings_full_app()

# Make sure that Settings is the currently displayed app.
self.assertEquals(self.apps.displayed_app.name, settings.name)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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 import GaiaTestCase
from gaiatest.apps.system.app import System
from gaiatest.apps.system.regions.status_bar import StatusBar
from gaiatest.apps.system.regions.utility_tray import UtilityTray


class TestUtilityTrayVisibilityAccessibility(GaiaTestCase):

def setUp(self):
GaiaTestCase.setUp(self)
self.system = System(self.marionette)
self.status_bar = StatusBar(self.marionette)
self.utility_tray = UtilityTray(self.marionette)

def test_a11y_utility_tray_visibility(self):
self.system.wait_for_status_bar_displayed()

utility_tray_container = self.marionette.find_element(*self.system._utility_tray_locator)

# Utility tray is hidden by default.
self.assertTrue(self.accessibility.is_hidden(utility_tray_container))

self.status_bar.a11y_wheel_status_bar_time()

# Utility tray should now be visible.
self.assertFalse(self.accessibility.is_hidden(utility_tray_container))

self.utility_tray.a11y_wheel_utility_tray_grippy()

# Utility tray should now be hidden.
self.assertTrue(self.accessibility.is_hidden(utility_tray_container))
3 changes: 3 additions & 0 deletions tests/python/gaia-ui-tests/gaiatest/tests/tbpl-manifest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ disabled = Bug 1022132 Intermittent Failure on TBPL
[accessibility/phone/test_a11y_phone_keypad.py]
[accessibility/phone/test_a11y_phone_select_toolbars.py]
[accessibility/system/test_a11y_notification_visibility.py]
[accessibility/system/test_a11y_utility_tray_notifications.py]
[accessibility/system/test_a11y_utility_tray_settings.py]
[accessibility/system/test_a11y_utility_tray_visibility.py]
[accessibility/system/test_a11y_volume_buttons.py]

[functional/calendar/test_calendar_flick_through_months.py]
Expand Down

0 comments on commit fe4842a

Please sign in to comment.