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 #12920 from bebef1987/lock_notif
Browse files Browse the repository at this point in the history
Bug 927808 - Test notification when the screen is locked
  • Loading branch information
Zac committed Oct 18, 2013
2 parents f1edc5a + 034868b commit 9f50305
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/python/gaia-ui-tests/gaiatest/apps/lockscreen/app.py
Expand Up @@ -5,6 +5,7 @@
from marionette.by import By
from marionette.marionette import Actions
from gaiatest.apps.base import Base
from gaiatest.apps.base import PageRegion
from gaiatest.apps.homescreen.app import Homescreen
from gaiatest.apps.camera.app import Camera

Expand All @@ -16,6 +17,7 @@ class LockScreen(Base):

_lockscreen_handle_locator = (By.ID, 'lockscreen-slide-handle')
_passcode_pad_locator = (By.ID, 'lockscreen-passcode-pad')
_notification_locator = (By.CSS_SELECTOR, '#notifications-lockscreen-container > div.notification')

def unlock(self):

Expand Down Expand Up @@ -54,3 +56,25 @@ def passcode_pad(self):
passcode_pad = self.marionette.find_element(*self._passcode_pad_locator)
from gaiatest.apps.lockscreen.regions.passcode_pad import PasscodePad
return PasscodePad(self.marionette, passcode_pad)

@property
def notifications(self):
return [Notification(self.marionette, element)
for element in self.marionette.find_elements(*self._notification_locator)]


class Notification(PageRegion):
_body_locator = (By.CSS_SELECTOR, 'div.detail')
_title_locator = (By.CSS_SELECTOR, 'div')

@property
def is_visible(self):
return self.root_element.is_displayed()

@property
def content(self):
return self.root_element.find_element(*self._body_locator).text

@property
def title(self):
return self.root_element.find_element(*self._title_locator).text
Expand Up @@ -5,13 +5,20 @@ b2g = true
# Bug 891882 Cannot unlock lockscreen on desktop
# TODO switch to fail-if when bug 884528 is fixed
skip-if = device == "desktop"

[test_lockscreen_unlock_to_camera.py]
skip-if = device == "desktop"
camera = true

[test_lockscreen_unlock_to_camera_with_passcode.py]
skip-if = device == "desktop"
camera = true

[test_lockscreen_unlock_to_homescreen_with_passcode.py]
skip-if = device == "desktop"

[test_lockscreen_unlock_to_emergency_call_screen.py]
skip-if = device == "desktop"

[test_lockscreen_notification.py]
skip-if = device == "desktop"
@@ -0,0 +1,29 @@
# 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.lockscreen.app import LockScreen


class TestLockScreen(GaiaTestCase):

_notification_title = 'TestNotificationBar_TITLE'
_notification_body = 'TestNotificationBar_BODY'

def setUp(self):
GaiaTestCase.setUp(self)

# this time we need it locked!
self.lockscreen.lock()
self.lock_screen = LockScreen(self.marionette)

def test_lock_screen_notification(self):

self.marionette.execute_script('navigator.mozNotification.createNotification("%s", "%s").show();'
% (self._notification_title, self._notification_body))

self.assertEqual(len(self.lock_screen.notifications), 1)
self.assertTrue(self.lock_screen.notifications[0].is_visible)
self.assertEqual(self.lock_screen.notifications[0].content, self._notification_body)
self.assertEqual(self.lock_screen.notifications[0].title, self._notification_title)

0 comments on commit 9f50305

Please sign in to comment.