Skip to content
Browse files

Bug 817039 - Merge latest gaia-ui-tests to gaia, r=lightsofapollo, a=…

…test-only
  • Loading branch information...
1 parent a903f72 commit 0e30af2957d2c00173995c3a2e9d6b971d38924f @jonallengriffin jonallengriffin committed
Showing with 2,228 additions and 126 deletions.
  1. +37 −20 tests/atoms/gaia_apps.js
  2. +161 −0 tests/atoms/gaia_data_layer.js
  3. +58 −0 tests/atoms/gaia_lock_screen.js
  4. +0 −21 tests/atoms/gaia_unlock.js
  5. +7 −4 tests/js/app_integration.js
  6. +184 −26 tests/python/gaiatest/gaia_test.py
  7. 0 tests/python/gaiatest/mocks/__init__.py
  8. +40 −0 tests/python/gaiatest/mocks/mock_contact.py
  9. +8 −0 tests/python/gaiatest/tests/contacts/manifest.ini
  10. +84 −0 tests/python/gaiatest/tests/contacts/test_add_new_contact.py
  11. +83 −0 tests/python/gaiatest/tests/contacts/test_call_contact.py
  12. +115 −0 tests/python/gaiatest/tests/contacts/test_edit_contact.py
  13. +76 −0 tests/python/gaiatest/tests/contacts/test_sms_contact.py
  14. +38 −0 tests/python/gaiatest/tests/manifest.ini
  15. +5 −0 tests/python/gaiatest/tests/marketplace/manifest.ini
  16. +55 −0 tests/python/gaiatest/tests/marketplace/test_marketplace_login.py
  17. +96 −0 tests/python/gaiatest/tests/marketplace/test_search_marketplace_and_install_app.py
  18. +58 −0 tests/python/gaiatest/tests/test_browser_cell_data.py
  19. +58 −0 tests/python/gaiatest/tests/test_browser_wifi.py
  20. +30 −20 tests/python/gaiatest/tests/test_calculator.py
  21. +64 −0 tests/python/gaiatest/tests/test_calendar.py
  22. +90 −0 tests/python/gaiatest/tests/test_call_log.py
  23. +85 −0 tests/python/gaiatest/tests/test_camera.py
  24. +65 −0 tests/python/gaiatest/tests/test_cards_view.py
  25. +92 −0 tests/python/gaiatest/tests/test_clock.py
  26. +96 −0 tests/python/gaiatest/tests/test_dialer.py
  27. +49 −0 tests/python/gaiatest/tests/test_gallery.py
  28. +0 −29 tests/python/gaiatest/tests/test_killall.py
  29. +57 −0 tests/python/gaiatest/tests/test_lockscreen.py
  30. +68 −0 tests/python/gaiatest/tests/test_music.py
  31. +101 −0 tests/python/gaiatest/tests/test_sms.py
  32. +41 −0 tests/python/gaiatest/tests/test_updater.py
  33. +70 −0 tests/python/gaiatest/tests/test_video_player.py
  34. +8 −0 tests/python/gaiatest/tests/unit/manifest.ini
  35. +44 −0 tests/python/gaiatest/tests/unit/test_killall.py
  36. +5 −5 tests/python/gaiatest/tests/{ → unit}/test_launch_entrypoint.py
  37. +13 −0 tests/python/gaiatest/tests/unit/test_lock_screen.py
  38. +59 −0 tests/python/gaiatest/tests/unit/test_settings.py
  39. +18 −0 tests/python/gaiatest/tests/unit/test_wifi.py
  40. +9 −0 tests/python/gaiatest/testvars_template.json
  41. +1 −1 tests/python/setup.py
View
57 tests/atoms/gaia_apps.js
@@ -69,9 +69,7 @@ var GaiaApps = {
}
},
- /**
- * Returns the number of running apps.
- */
+ // Returns the number of running apps.
numRunningApps: function() {
let count = 0;
let runningApps = window.wrappedJSObject.WindowManager.getRunningApps();
@@ -81,12 +79,23 @@ var GaiaApps = {
return count;
},
- /**
- * Kills all running apps, except the homescreen.
- */
+ // Kills all running apps, except the homescreen.
killAll: function() {
let originsToClose = [];
let that = this;
+
+ let runningApps = window.wrappedJSObject.WindowManager.getRunningApps();
+ for (let origin in runningApps) {
+ if (origin.indexOf('homescreen') == -1) {
+ originsToClose.push(origin);
+ }
+ }
+
+ if (!originsToClose.length) {
+ marionetteScriptFinished(true);
+ return;
+ }
+
window.addEventListener('appterminated', function gt_onAppTerminated(evt) {
let index = originsToClose.indexOf(evt.detail.origin);
if (index > -1) {
@@ -103,20 +112,15 @@ var GaiaApps = {
);
}
});
- let runningApps = window.wrappedJSObject.WindowManager.getRunningApps();
- for (let origin in runningApps) {
- if (origin.indexOf('homescreen') == -1) {
- originsToClose.push(origin);
- window.wrappedJSObject.WindowManager.kill(origin);
- }
- }
+
+ originsToClose.slice(0).forEach(function(origin) {
+ window.wrappedJSObject.WindowManager.kill(origin);
+ });
},
- /**
- * Launches app with the specified name (e.g., 'Calculator'); returns the
- * app frame's id if successful, false if the app can't be found, or times
- * out if the app frame can't be found after launching the app.
- */
+ // Launches app with the specified name (e.g., 'Calculator'); returns the
+ // app frame's id if successful, false if the app can't be found, or times
+ // out if the app frame can't be found after launching the app.
launchWithName: function(name) {
GaiaApps.locateWithName(name, function(app, appName, entryPoint) {
if (app) {
@@ -144,8 +148,10 @@ var GaiaApps = {
// wait until the new iframe sends the mozbrowserfirstpaint event
let frame = runningApps[origin].frame;
if (frame.dataset.unpainted) {
- window.addEventListener('appopen', function firstpaint() {
- window.removeEventListener('appopen', firstpaint);
+ window.addEventListener('mozbrowserfirstpaint',
+ function firstpaint() {
+ window.removeEventListener('mozbrowserfirstpaint',
+ firstpaint);
sendResponse(origin);
});
}
@@ -164,5 +170,16 @@ var GaiaApps = {
marionetteScriptFinished(false);
}
});
+ },
+
+ /**
+ * Uninstalls the app with the speciifed name.
+ */
+ uninstallWithName: function(name) {
+ GaiaApps.locateWithName(name, function uninstall(app) {
+ app.uninstall();
+ marionetteScriptFinished(false);
+ });
}
+
};
View
161 tests/atoms/gaia_data_layer.js
@@ -0,0 +1,161 @@
+/* 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/. */
+
+ var GaiaDataLayer = {
+
+ insertContact: function(cdata) {
+ contact = new mozContact();
+ contact.init(cdata);
+ var request = window.navigator.mozContacts.save(contact);
+
+ request.onerror = function onerror() {
+ console.log('Error saving contact', request.error.name);
+ }
+
+ request.onsuccess = function onsuccess() {
+ console.log('Success saving contact', request);
+ }
+ return request;
+ },
+
+ findAndRemoveContact: function(cdata) {
+ var options = {
+ filterBy: ['familyName'],
+ filterOp: 'contains',
+ filterValue: cdata['familyName']
+ };
+
+ contact = window.navigator.mozContacts.find(options);
+
+ contact.onerror = function onerror() {
+ console.log('Could not find contact', contact.error.name);
+ }
+
+ contact.onsuccess = function onsuccess() {
+ console.log('Success finding contact', contact);
+ if (contact.result.length > 0) {
+ return window.navigator.mozContacts.remove(contact.result[0]);
+ }
+ }
+ },
+
+ getSetting: function(aName) {
+ req = window.navigator.mozSettings.createLock().get(aName);
+ req.onsuccess = function() {
+ console.log('setting retrieved');
+ marionetteScriptFinished(req.result[aName]);
+ };
+ req.onerror = function() {
+ console.log('error getting setting', req.error.name);
+ }
+ },
+
+ setSetting: function(aName, aValue, aReturnOnSuccess) {
+ var returnOnSuccess = aReturnOnSuccess || aReturnOnSuccess === undefined;
+ var setting = {};
+ setting[aName] = aValue;
+ console.log('setting ' + aName + ' to ' + aValue);
+ req = window.navigator.mozSettings.createLock().set(setting);
+ req.onsuccess = function() {
+ console.log('setting changed');
+ if (returnOnSuccess) {
+ marionetteScriptFinished(true);
+ }
+ };
+ req.onerror = function() {
+ console.log('error changing setting', req.error.name);
+ marionetteScriptFinished(false);
+ }
+ },
+
+ connectToWiFi: function(aNetwork) {
+ var manager = window.navigator.mozWifiManager;
+
+ if (this.isWiFiConnected(aNetwork)) {
+ console.log('already connected to network');
+ marionetteScriptFinished(true);
+ }
+ else {
+ var req = manager.associate(aNetwork);
+
+ req.onsuccess = function() {
+ manager.onstatuschange = function(event) {
+ console.log('status: ' + manager.connection.status);
+ if (manager.connection.status === 'connected') {
+ manager.onstatuschange = null;
+ marionetteScriptFinished(true);
+ }
+ }
+ };
+
+ req.onerror = function() {
+ console.log('error connecting to network', req.error.name);
+ marionetteScriptFinished(false);
+ }
+ }
+ },
+
+ disableWiFi: function() {
+ var manager = window.navigator.mozWifiManager;
+ if (manager.enabled) {
+ manager.ondisabled = function() {
+ manager.ondisabled = null;
+ console.log('wifi disabled');
+ marionetteScriptFinished(true);
+ };
+ this.setSetting('wifi.enabled', false, false);
+ }
+ else {
+ console.log('wifi already disabled');
+ marionetteScriptFinished(true);
+ }
+ },
+
+ enableWiFi: function() {
+ var manager = window.navigator.mozWifiManager;
+ if (!manager.enabled) {
+ manager.onenabled = function() {
+ manager.onenabled = null;
+ console.log('wifi enabled');
+ marionetteScriptFinished(true);
+ };
+ this.setSetting('wifi.enabled', true, false);
+ }
+ else {
+ console.log('wifi already enabled');
+ marionetteScriptFinished(true);
+ }
+ },
+
+ forgetWiFi: function(aNetwork) {
+ var manager = window.navigator.mozWifiManager;
+ var req = manager.forget(aNetwork);
+
+ req.onsuccess = function() {
+ console.log('success forgetting network');
+ manager.onstatuschange = function(event) {
+ console.log('status: ' + manager.connection.status);
+ if (manager.connection.status === 'disconnected') {
+ manager.onstatuschange = null;
+ marionetteScriptFinished(true);
+ }
+ };
+ };
+
+ req.onerror = function() {
+ console.log('error forgetting network', req.error.name);
+ marionetteScriptFinished(false);
+ }
+ },
+
+ isWiFiConnected: function(aNetwork) {
+ var manager = window.navigator.mozWifiManager;
+ return manager.connection.status === 'connected' &&
+ manager.connection.network.ssid === aNetwork.ssid;
+ },
+
+ getMozTelephonyState: function() {
+ return window.navigator.mozTelephony.active.state;
+ }
+};
View
58 tests/atoms/gaia_lock_screen.js
@@ -0,0 +1,58 @@
+/* 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/. */
+
+var GaiaLockScreen = {
+
+ unlock: function() {
+
+ let setlock = window.wrappedJSObject.SettingsListener.getSettingsLock();
+ let obj = {'screen.timeout': 0};
+ setlock.set(obj);
+
+ window.wrappedJSObject.ScreenManager.turnScreenOn();
+
+ waitFor(
+ function() {
+ window.wrappedJSObject.LockScreen.unlock();
+ waitFor(
+ function() {
+ finish(window.wrappedJSObject.LockScreen.locked);
+ },
+ function() {
+ return !window.wrappedJSObject.LockScreen.locked;
+ }
+ );
+ },
+ function() {
+ return !!window.wrappedJSObject.LockScreen;
+ }
+ );
+ },
+
+ lock: function() {
+
+ let setlock = window.wrappedJSObject.SettingsListener.getSettingsLock();
+ let obj = {'screen.timeout': 0};
+ setlock.set(obj);
+
+ window.wrappedJSObject.ScreenManager.turnScreenOn();
+
+ waitFor(
+ function() {
+ window.wrappedJSObject.LockScreen.lock();
+ waitFor(
+ function() {
+ finish(!window.wrappedJSObject.LockScreen.locked);
+ },
+ function() {
+ return window.wrappedJSObject.LockScreen.locked;
+ }
+ );
+ },
+ function() {
+ return !!window.wrappedJSObject.LockScreen;
+ }
+ );
+ }
+};
View
21 tests/atoms/gaia_unlock.js
@@ -1,21 +0,0 @@
-let setlock = window.wrappedJSObject.SettingsListener.getSettingsLock();
-let obj = {'screen.timeout': 0};
-setlock.set(obj);
-
-waitFor(
- function() {
- window.wrappedJSObject.LockScreen.unlock();
- waitFor(
- function() {
- finish(window.wrappedJSObject.LockScreen.locked);
- },
- function() {
- return !window.wrappedJSObject.LockScreen.locked;
- }
- );
- },
- function() {
- return !!window.wrappedJSObject.LockScreen;
- }
-);
-
View
11 tests/js/app_integration.js
@@ -188,13 +188,16 @@ var AppIntegration = (function() {
var device = app.device;
yield device.setScriptTimeout(15000);
- yield IntegrationHelper.sendAtom(
+
+ yield IntegrationHelper.importScript(
device,
- '/tests/atoms/gaia_unlock',
- true,
- next
+ '/tests/atoms/gaia_lock_screen.js',
+ MochaTask.nodeNext
);
+ yield device.executeAsyncScript(
+ 'GaiaLockScreen.unlock();'
+ );
yield IntegrationHelper.importScript(
device,
View
210 tests/python/gaiatest/gaia_test.py
@@ -2,38 +2,32 @@
# 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 import MarionetteTestCase
+import json
import os
+import time
+
+from marionette import MarionetteTestCase
+from marionette import Marionette
+from marionette import MarionetteTouchMixin
+from marionette.errors import NoSuchElementException
+from marionette.errors import ElementNotVisibleException
+from marionette.errors import TimeoutException
class LockScreen(object):
def __init__(self, marionette):
self.marionette = marionette
+ js = os.path.abspath(os.path.join(__file__, os.path.pardir, 'atoms', "gaia_lock_screen.js"))
+ self.marionette.import_script(js)
+
+ def lock(self):
+ result = self.marionette.execute_async_script('GaiaLockScreen.lock()')
+ assert result, 'Unable to lock screen'
def unlock(self):
- success = self.marionette.execute_async_script("""
-let setlock = window.wrappedJSObject.SettingsListener.getSettingsLock();
-let obj = {'screen.timeout': 0};
-setlock.set(obj);
-waitFor(
- function() {
- window.wrappedJSObject.LockScreen.unlock();
- waitFor(
- function() {
- finish(window.wrappedJSObject.LockScreen.locked);
- },
- function() {
- return !window.wrappedJSObject.LockScreen.locked;
- }
- );
- },
- function() {
- return !!window.wrappedJSObject.LockScreen;
- }
-);
-""")
- return success
+ result = self.marionette.execute_async_script('GaiaLockScreen.unlock()')
+ assert result, 'Unable to unlock screen'
class GaiaApp(object):
@@ -52,22 +46,30 @@ def __init__(self, marionette):
js = os.path.abspath(os.path.join(__file__, os.path.pardir, 'atoms', "gaia_apps.js"))
self.marionette.import_script(js)
- def launch(self, name):
+ def launch(self, name, switch_to_frame=True, url=None):
+ self.marionette.switch_to_frame()
result = self.marionette.execute_async_script("GaiaApps.launchWithName('%s')" % name)
app = GaiaApp(frame_id=result.get('frame'),
src=result.get('src'),
name=result.get('name'),
origin=result.get('origin'))
+ if app.frame_id is None:
+ raise Exception("App failed to launch; there is no app frame")
+ if switch_to_frame:
+ self.switch_to_frame(app.frame_id, url)
return app
+ def uninstall(self, name):
+ self.marionette.execute_async_script("GaiaApps.uninstallWithName('%s')" % name)
+
def kill(self, app):
self.marionette.switch_to_frame()
js = os.path.abspath(os.path.join(__file__, os.path.pardir, 'atoms', "gaia_apps.js"))
self.marionette.import_script(js)
self.marionette.execute_script("window.wrappedJSObject.WindowManager.kill('%s');"
- % app.origin)
+ % app.origin)
- def killAll(self):
+ def kill_all(self):
self.marionette.switch_to_frame()
js = os.path.abspath(os.path.join(__file__, os.path.pardir, 'atoms', "gaia_apps.js"))
self.marionette.import_script(js)
@@ -79,16 +81,172 @@ def runningApps(self):
""")
return apps
+ def switch_to_frame(self, app_frame, url=None, timeout=30):
+ self.marionette.switch_to_frame(app_frame)
+ start = time.time()
+ if not url:
+ def check(now):
+ return "about:blank" not in now
+ else:
+ def check(now):
+ return url in now
+ while (time.time() - start < timeout):
+ if check(self.marionette.get_url()):
+ return
+ time.sleep(2)
+ raise TimeoutException('Could not switch to app frame %s in time' % app_frame)
+
+
+class GaiaData(object):
+
+ def __init__(self, marionette):
+ self.marionette = marionette
+ js = os.path.abspath(os.path.join(__file__, os.path.pardir, 'atoms', "gaia_data_layer.js"))
+ self.marionette.import_script(js)
+ self.marionette.set_search_timeout(10000)
+
+ def insert_contact(self, contact):
+ self.marionette.execute_script("GaiaDataLayer.insertContact(%s)" % contact.json())
+
+ def remove_contact(self, contact):
+ self.marionette.execute_script("GaiaDataLayer.findAndRemoveContact(%s)" % contact.json())
+
+ def get_setting(self, name):
+ return self.marionette.execute_async_script('return GaiaDataLayer.getSetting("%s")' % name)
+
+ def set_setting(self, name, value):
+ import json
+ value = json.dumps(value)
+ result = self.marionette.execute_async_script('return GaiaDataLayer.setSetting("%s", %s)' % (name, value))
+ assert result, "Unable to change setting with name '%s' to '%s'" % (name, value)
+
+ def set_volume(self, value):
+ self.set_setting('audio.volume.master', value)
+
+ def enable_cell_data(self):
+ self.set_setting('ril.data.enabled', True)
+
+ def disable_cell_data(self):
+ self.set_setting('ril.data.enabled', False)
+
+ def enable_cell_roaming(self):
+ self.set_setting('ril.data.roaming_enabled', True)
+
+ def disable_cell_roaming(self):
+ self.set_setting('ril.data.roaming_enabled', False)
+
+ def enable_wifi(self):
+ result = self.marionette.execute_async_script("return GaiaDataLayer.enableWiFi()")
+ assert result, 'Unable to enable WiFi'
+
+ def disable_wifi(self):
+ result = self.marionette.execute_async_script("return GaiaDataLayer.disableWiFi()")
+ assert result, 'Unable to disable WiFi'
+
+ def connect_to_wifi(self, network):
+ result = self.marionette.execute_async_script("return GaiaDataLayer.connectToWiFi(%s)" % json.dumps(network))
+ assert result, 'Unable to connect to WiFi network'
+
+ def forget_wifi(self, network):
+ result = self.marionette.execute_async_script("return GaiaDataLayer.forgetWiFi(%s)" % json.dumps(network))
+ assert result, 'Unable to forget WiFi network'
+
+ def is_wifi_connected(self, network):
+ return self.marionette.execute_script("return GaiaDataLayer.isWiFiConnected(%s)" % json.dumps(network))
+
+ @property
+ def active_telephony_state(self):
+ # Returns the state of only the currently active call or None if no active call
+ return self.marionette.execute_script("return GaiaDataLayer.getMozTelephonyState()")
+
+
class GaiaTestCase(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
+ self.marionette.__class__ = type('Marionette', (Marionette, MarionetteTouchMixin), {})
+ self.marionette.setup_touch()
+
# the emulator can be really slow!
self.marionette.set_script_timeout(60000)
self.lockscreen = LockScreen(self.marionette)
self.apps = GaiaApps(self.marionette)
+ self.data_layer = GaiaData(self.marionette)
+
+ self.apps.kill_all()
+
+ def wait_for_element_present(self, by, locator, timeout=10):
+ timeout = float(timeout) + time.time()
+
+ while time.time() < timeout:
+ time.sleep(0.5)
+ try:
+ return self.marionette.find_element(by, locator)
+ except NoSuchElementException:
+ pass
+ else:
+ raise TimeoutException(
+ 'Element %s not found before timeout' % locator)
+
+ def wait_for_element_not_present(self, by, locator, timeout=10):
+ timeout = float(timeout) + time.time()
+
+ while time.time() < timeout:
+ time.sleep(0.5)
+ try:
+ self.marionette.find_element(by, locator)
+ except NoSuchElementException:
+ break
+ else:
+ raise TimeoutException(
+ 'Element %s still present after timeout' % locator)
+
+ def wait_for_element_displayed(self, by, locator, timeout=10):
+ timeout = float(timeout) + time.time()
+
+ while time.time() < timeout:
+ time.sleep(0.5)
+ try:
+ if self.marionette.find_element(by, locator).is_displayed():
+ break
+ except NoSuchElementException:
+ pass
+ else:
+ raise TimeoutException(
+ 'Element %s not visible before timeout' % locator)
+
+ def wait_for_element_not_displayed(self, by, locator, timeout=10):
+ timeout = float(timeout) + time.time()
+
+ while time.time() < timeout:
+ time.sleep(0.5)
+ try:
+ if not self.marionette.find_element(by, locator).is_displayed():
+ break
+ except NoSuchElementException:
+ break
+ else:
+ raise TimeoutException(
+ 'Element %s still visible after timeout' % locator)
+
+ def wait_for_condition(self, method, timeout=10,
+ message="Condition timed out"):
+ """Calls the method provided with the driver as an argument until the \
+ return value is not False."""
+ end_time = time.time() + timeout
+ while time.time() < end_time:
+ try:
+ value = method(self.marionette)
+ if value:
+ return value
+ except NoSuchElementException:
+ pass
+ time.sleep(0.5)
+ else:
+ raise TimeoutException(message)
def tearDown(self):
self.lockscreen = None
self.apps = None
+ self.data_layer = None
MarionetteTestCase.tearDown(self)
View
0 tests/python/gaiatest/mocks/__init__.py
No changes.
View
40 tests/python/gaiatest/mocks/mock_contact.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+
+# 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/.
+
+import json
+
+
+class MockContact(dict):
+ '''
+ The key values here match the data structure in the contacts db
+ so that the json output of this mock can be inserted directly into db
+ '''
+
+ def __init__(self, **kwargs):
+ # set your default values
+ import time
+ curr_time = repr(time.time()).replace('.', '')
+ self['givenName'] = 'gaia%s' % curr_time[10:]
+ self['familyName'] = "test"
+ self['name'] = self['givenName'] + " " + self['familyName']
+ self['email'] = '%s@restmail.net' % self['givenName']
+ # TODO this will only support one phone number
+ self['tel'] = {'type':'Mobile','value':"555%s" % curr_time[:8]}
+ self['street'] = "101 Testing street"
+ self['zip'] = "90210"
+ self['city'] = "London"
+ self['country'] = "UK"
+ self['comment'] = "Gaia automated test"
+
+ # update with any keyword arguments passed
+ self.update(**kwargs)
+
+ # allow getting items as if they were attributes
+ def __getattr__(self, attr):
+ return self[attr]
+
+ def json(self):
+ return json.dumps(self)
View
8 tests/python/gaiatest/tests/contacts/manifest.ini
@@ -0,0 +1,8 @@
+[test_add_new_contact.py]
+[test_call_contact.py]
+disabled = "Call app crashes after 2nd run"
+carrier = true
+[test_edit_contact.py]
+[test_sms_contact.py]
+disabled = "Bug 816057 - Marionette does not click button correctly"
+carrier = true
View
84 tests/python/gaiatest/tests/contacts/test_add_new_contact.py
@@ -0,0 +1,84 @@
+# 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.mocks.mock_contact import MockContact
+
+
+class TestContacts(GaiaTestCase):
+
+ _loading_overlay = ('id', 'loading-overlay')
+
+ # Header buttons
+ _add_new_contact_button_locator = ('id', 'add-contact-button')
+ _done_button_locator = ('id', 'save-button')
+
+ # New/Edit contact fields
+ _given_name_field_locator = ('id', 'givenName')
+ _family_name_field_locator = ('id', 'familyName')
+ _email_field_locator = ('id', "email_0")
+ _phone_field_locator = ('id', "number_0")
+ _street_field_locator = ('id', "streetAddress_0")
+ _zip_code_field_locator = ('id', "postalCode_0")
+ _city_field_locator = ('id', 'locality_0')
+ _country_field_locator = ('id', 'countryName_0')
+ _comment_field_locator = ('id', 'note_0')
+
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ self.lockscreen.unlock()
+
+ # launch the Contacts app
+ self.app = self.apps.launch('Contacts')
+ self.wait_for_element_not_displayed(*self._loading_overlay)
+
+ self.contact = MockContact()
+
+ def create_contact_locator(self, contact):
+ return ('xpath', "//a[descendant::strong[text()='%s']]" % contact)
+
+ def test_add_new_contact(self):
+ # https://moztrap.mozilla.org/manage/case/1309/
+ #click Create new contact
+
+ self.wait_for_element_displayed(*self._add_new_contact_button_locator)
+ self.marionette.find_element(
+ *self._add_new_contact_button_locator).click()
+ self.wait_for_element_displayed(*self._given_name_field_locator)
+
+ # Enter data into fields
+ self.marionette.find_element(*self._given_name_field_locator).send_keys(self.contact['givenName'])
+ self.marionette.find_element(*self._family_name_field_locator).send_keys(self.contact['familyName'])
+
+ self.marionette.find_element(
+ *self._phone_field_locator).send_keys(self.contact['tel']['value'])
+ self.marionette.find_element(
+ *self._email_field_locator).send_keys(self.contact['email'])
+
+ self.marionette.find_element(
+ *self._street_field_locator).send_keys(self.contact['street'])
+ self.marionette.find_element(
+ *self._zip_code_field_locator).send_keys(self.contact['zip'])
+ self.marionette.find_element(
+ *self._city_field_locator).send_keys(self.contact['city'])
+ self.marionette.find_element(
+ *self._country_field_locator).send_keys(self.contact['country'])
+
+ self.marionette.find_element(
+ *self._comment_field_locator).send_keys(self.contact['comment'])
+
+ done_button = self.marionette.find_element(*self._done_button_locator)
+ done_button.click()
+
+ contact_locator = self.create_contact_locator(self.contact['givenName'])
+ self.wait_for_element_displayed(*contact_locator)
+
+
+ def tearDown(self):
+
+ # close all apps
+ self.apps.kill_all()
View
83 tests/python/gaiatest/tests/contacts/test_call_contact.py
@@ -0,0 +1,83 @@
+# 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.mocks.mock_contact import MockContact
+
+from marionette.errors import NoSuchElementException
+
+
+class TestContacts(GaiaTestCase):
+
+ _loading_overlay = ('id', 'loading-overlay')
+
+ # Contact details panel
+ _contact_name_title = ('id', 'contact-name-title')
+ _call_phone_number_button_locator = ('id', 'call-or-pick-0')
+
+ # Call Screen app
+ _calling_number_locator = ('xpath', "//section[1]//div[@class='number']")
+ _outgoing_call_locator = ('css selector', 'div.direction.outgoing')
+ _hangup_bar_locator = ('id', 'callbar-hang-up-action')
+ _call_app_locator = ('css selector', "iframe[name='call_screen']")
+
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ self.lockscreen.unlock()
+
+ # launch the Contacts app
+ self.app = self.apps.launch('Contacts')
+ self.wait_for_element_not_displayed(*self._loading_overlay)
+
+ # Seed the contact with the remote phone number so we don't call random people
+ self.contact = MockContact(tel={'type':'Mobile','value':"%s" % self.testvars['remote_phone_number']})
+ self.data_layer.insert_contact(self.contact)
+ self.marionette.refresh()
+
+ def create_contact_locator(self, contact):
+ return ('xpath', "//a[descendant::strong[text()='%s']]" % contact)
+
+ def test_call_contact(self):
+ # NB This is not a listed smoke test
+ # Call phone from a contact
+
+ contact_locator = self.create_contact_locator(self.contact['givenName'])
+ self.wait_for_element_displayed(*contact_locator)
+
+ self.marionette.find_element(*contact_locator).click()
+
+ self.wait_for_element_displayed(*self._call_phone_number_button_locator)
+ self.marionette.find_element(*self._call_phone_number_button_locator).click()
+
+ # Switch to top level frame
+ self.marionette.switch_to_frame()
+
+ # Wait for call screen then switch to it
+ self.wait_for_element_present(*self._call_app_locator)
+ call_screen = self.marionette.find_element(*self._call_app_locator)
+ self.marionette.switch_to_frame(call_screen)
+
+ # Wait for call screen to be dialing
+ self.wait_for_element_displayed(*self._outgoing_call_locator)
+
+ # Check the number displayed is the one we dialed
+ self.assertEqual(self.contact['tel']['value'],
+ self.marionette.find_element(*self._calling_number_locator).text)
+
+ # hang up before the person answers ;)
+ self.marionette.find_element(*self._hangup_bar_locator).click()
+
+
+ def tearDown(self):
+
+ if hasattr(self, 'contact'):
+ # Have to switch back to Contacts frame to remove the contact
+ self.marionette.switch_to_frame()
+ self.marionette.switch_to_frame(self.app.frame_id)
+ self.data_layer.remove_contact(self.contact)
+
+ # close all apps
+ self.apps.kill_all()
View
115 tests/python/gaiatest/tests/contacts/test_edit_contact.py
@@ -0,0 +1,115 @@
+# 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/.
+
+import time
+
+from gaiatest import GaiaTestCase
+from gaiatest.mocks.mock_contact import MockContact
+
+from marionette.errors import NoSuchElementException
+
+
+class TestContacts(GaiaTestCase):
+
+ _loading_overlay = ('id', 'loading-overlay')
+
+ # Header buttons
+ _done_button_locator = ('id', 'save-button')
+ _edit_contact_button_locator = ('id', 'edit-contact-button')
+ _details_back_button_locator = ('id', 'details-back')
+
+ # Contact details panel
+ _contact_name_title = ('id', 'contact-name-title')
+ _call_phone_number_button_locator = ('id', 'call-or-pick-0')
+
+ # New/Edit contact fields
+ _given_name_field_locator = ('id', 'givenName')
+ _family_name_field_locator = ('id', 'familyName')
+ _phone_field_locator = ('id', "number_0")
+
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ self.lockscreen.unlock()
+
+ # launch the Contacts app
+ self.app = self.apps.launch('Contacts')
+ self.wait_for_element_not_displayed(*self._loading_overlay)
+
+ self.contact = MockContact()
+ self.data_layer.insert_contact(self.contact)
+ self.marionette.refresh()
+
+ def create_contact_locator(self, contact):
+ return ('xpath', "//a[descendant::strong[text()='%s']]" % contact)
+
+ def test_edit_contact(self):
+ # https://moztrap.mozilla.org/manage/case/1310/
+ # First insert a new contact to edit
+
+ contact_locator = self.create_contact_locator(self.contact['givenName'])
+ self.wait_for_element_displayed(*contact_locator)
+
+ self.marionette.find_element(*contact_locator).click()
+
+ self.wait_for_element_displayed(*self._edit_contact_button_locator)
+ self.marionette.find_element(*self._edit_contact_button_locator).click()
+
+ # Now we'll update the mock contact and then insert the new values into the UI
+ self.contact['givenName'] = 'gaia%s' % repr(time.time()).replace('.', '')[10:]
+ self.contact['familyName'] = "testedit"
+ self.contact['tel']['value'] = "02011111111"
+
+ given_name_field = self.marionette.find_element(*self._given_name_field_locator)
+ given_name_field.clear()
+ given_name_field.send_keys(self.contact['givenName'])
+
+ family_name_field = self.marionette.find_element(*self._family_name_field_locator)
+ family_name_field.clear()
+ family_name_field.send_keys(self.contact['familyName'])
+
+ tel_field = self.marionette.find_element(*self._phone_field_locator)
+ tel_field.clear()
+ tel_field.send_keys(self.contact['tel']['value'])
+
+ self.marionette.find_element(*self._done_button_locator).click()
+
+ # Construct a new locator using the edited givenName
+ edited_contact_locator = self.create_contact_locator(self.contact['givenName'])
+
+ self.marionette.find_element(*self._details_back_button_locator).click()
+
+ # click back into the contact
+ self.wait_for_element_displayed(*edited_contact_locator)
+
+ edited_contact = self.marionette.find_element(*edited_contact_locator)
+
+ # Due to a previous issue this will check that the original contact is no longer present
+ self.assertRaises(NoSuchElementException,
+ self.marionette.find_element, contact_locator[0], contact_locator[1])
+
+ self.assertTrue(edited_contact.is_displayed(),
+ "Expected the edited contact to be present")
+
+ edited_contact.click()
+
+ # Now assert that the values have updated
+ full_name = self.contact['givenName'] + " " + self.contact['familyName']
+
+ self.assertEqual(self.marionette.find_element(*self._contact_name_title).text,
+ full_name)
+ self.assertEqual(self.marionette.find_element(*self._call_phone_number_button_locator).text,
+ self.contact['tel']['value'])
+
+ def tearDown(self):
+
+ if hasattr(self, 'contact'):
+ # Have to switch back to Contacts frame to remove the contact
+ self.marionette.switch_to_frame()
+ self.marionette.switch_to_frame(self.app.frame_id)
+ self.data_layer.remove_contact(self.contact)
+
+ # close all apps
+ self.apps.kill_all()
View
76 tests/python/gaiatest/tests/contacts/test_sms_contact.py
@@ -0,0 +1,76 @@
+# 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.mocks.mock_contact import MockContact
+
+from marionette.errors import NoSuchElementException
+
+
+class TestContacts(GaiaTestCase):
+
+ _loading_overlay = ('id', 'loading-overlay')
+
+ _sms_app_iframe_locator = ('css selector', 'iframe[src="app://sms.gaiamobile.org/index.html"]')
+
+ # Contact details panel
+ _send_sms_button_locator = ('id', 'send-sms-button-0')
+
+ #SMS app locators
+ _sms_app_header_locator = ('id', 'header-text')
+
+ def setUp(self):
+
+ GaiaTestCase.setUp(self)
+
+ self.lockscreen.unlock()
+
+ # launch the Contacts app
+ self.app = self.apps.launch('Contacts')
+ self.wait_for_element_not_displayed(*self._loading_overlay)
+
+ self.contact = MockContact()
+ self.data_layer.insert_contact(self.contact)
+ self.marionette.refresh()
+
+ def create_contact_locator(self, contact):
+ return ('xpath', "//a[descendant::strong[text()='%s']]" % contact)
+
+ def test_sms_contact(self):
+ # https://moztrap.mozilla.org/manage/case/1314/
+ # Setup a text message from a contact
+
+ contact_locator = self.create_contact_locator(self.contact['givenName'])
+ self.wait_for_element_displayed(*contact_locator)
+
+ self.marionette.find_element(*contact_locator).click()
+
+ self.wait_for_element_present(*self._send_sms_button_locator)
+ self.marionette.find_element(*self._send_sms_button_locator).click()
+
+ self.marionette.switch_to_frame()
+
+ sms_iframe = self.marionette.find_element(*self._sms_app_iframe_locator)
+ self.marionette.switch_to_frame(sms_iframe)
+
+ self.wait_for_element_displayed(*self._sms_app_header_locator)
+
+ header_element = self.marionette.find_element(*self._sms_app_header_locator)
+ expected_name = self.contact['givenName'] + " " + self.contact['familyName']
+ expected_tel = self.contact['tel']['value']
+
+ self.assertEqual(header_element.text, expected_name)
+ self.assertEqual(header_element.get_attribute('data-phone-number'),
+ expected_tel)
+
+ def tearDown(self):
+
+ if hasattr(self, 'contact'):
+ # Have to switch back to Contacts frame to remove the contact
+ self.marionette.switch_to_frame()
+ self.marionette.switch_to_frame(self.app.frame_id)
+ self.data_layer.remove_contact(self.contact)
+
+ # close all apps
+ self.apps.kill_all()
View
38 tests/python/gaiatest/tests/manifest.ini
@@ -0,0 +1,38 @@
+[DEFAULT]
+b2g = true
+browser = false
+carrier = false
+sdcard = false
+qemu = false
+wifi = false
+
+[include:unit/manifest.ini]
+[include:marketplace/manifest.ini]
+[include:contacts/manifest.ini]
+
+
+[test_browser_cell_data.py]
+carrier = true
+[test_browser_wifi.py]
+wifi = true
+[test_calculator.py]
+[test_calendar.py]
+[test_call_log.py]
+disabled = "Need to populate missed calls automatically - Git issue #45"
+[test_camera.py]
+sdcard = true
+[test_cards_view.py]
+[test_clock.py]
+[test_dialer.py]
+carrier=true
+[test_gallery.py]
+sdcard = true
+[test_lockscreen.py]
+[test_music.py]
+sdcard = true
+[test_sms.py]
+carrier = true
+[test_updater.py]
+disabled = "TODO"
+[test_video_player.py]
+sdcard = true
View
5 tests/python/gaiatest/tests/marketplace/manifest.ini
@@ -0,0 +1,5 @@
+[DEFAULT]
+wifi = true
+
+[test_marketplace_login.py]
+[test_search_marketplace_and_install_app.py]
View
55 tests/python/gaiatest/tests/marketplace/test_marketplace_login.py
@@ -0,0 +1,55 @@
+# 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
+
+
+class TestMarketplaceLogin(GaiaTestCase):
+
+ _login_button = ('css selector', 'a.button.browserid')
+ _persona_frame = ('css selector', "iframe[name='__persona_dialog']")
+ _search_result = ('css selector', '#search-results li.item')
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ # unlock the lockscreen if it's locked
+ self.lockscreen.unlock()
+
+ self.data_layer.enable_wifi()
+ self.data_layer.connect_to_wifi(self.testvars['wifi'])
+
+ # launch the app
+ self.app = self.apps.launch('Marketplace')
+
+ def test_login_marketplace(self):
+ # https://moztrap.mozilla.org/manage/case/4134/
+
+ self.wait_for_element_displayed(*self._login_button)
+ self.marionette.find_element(*self._login_button).click()
+
+ # switch to top level frame
+ self.marionette.switch_to_frame()
+
+ #switch to persona frame
+
+ self.wait_for_element_present(*self._persona_frame)
+ #persona_frame = self.marionette.find_element(*self._persona_frame)
+ #self.marionette.switch_to_frame(persona_frame)
+
+ #TODO switch to Persona frame and wait for throbber to clear
+
+ #TODO complete Persona login
+ #self.testvars['marketplace_username']
+ #self.testvars['marketplace_password']
+ #TODO Switch back to marketplace and verify that user is logged in
+
+ def tearDown(self):
+
+ # close the app
+ if self.app:
+ self.apps.kill(self.app)
+
+ self.data_layer.disable_wifi()
+ GaiaTestCase.tearDown(self)
View
96 tests/python/gaiatest/tests/marketplace/test_search_marketplace_and_install_app.py
@@ -0,0 +1,96 @@
+# 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 marionette.keys import Keys
+
+
+APP_NAME = 'Lanyrd Mobile'
+APP_DEVELOPER = 'Lanyrd'
+
+
+class TestSearchMarketplaceAndInstallApp(GaiaTestCase):
+
+ # Marketplace search on home page
+ _search_button = ('css selector', '.header-button.icon.search.right')
+ _search = ('id', 'search-q')
+
+ # Marketplace search results area and a specific result item
+ _search_results_area = ('id', 'search-results')
+ _search_result = ('css selector', '#search-results li.item')
+
+ # Marketplace result app name, author, and install button
+ _app_name_locator = ('xpath', '//h3')
+ _author_locator = ('css selector', '.author.lineclamp.vital')
+ _install_button = ('css selector', '.button.product.install')
+
+ # System app confirmation button to confirm installing an app
+ _yes_button_locator = ('id', 'app-install-install-button')
+
+ # Label identifier for all homescreen apps
+ _icons_locator = ('css selector', '.labelWrapper')
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ # unlock the lockscreen if it's locked
+ self.lockscreen.unlock()
+
+ self.data_layer.enable_wifi()
+ self.data_layer.connect_to_wifi(self.testvars['wifi'])
+
+ # launch the app
+ self.app = self.apps.launch('Marketplace')
+
+ def test_search_and_install_app(self):
+ # select to search for an app
+ self.wait_for_element_displayed(*self._search_button)
+ self.marionette.find_element(*self._search_button).click()
+
+ # search for the lanyrd mobile app
+ self.wait_for_element_displayed(*self._search)
+ search_box = self.marionette.find_element(*self._search)
+ search_box.send_keys(APP_NAME)
+ search_box.send_keys(Keys.RETURN)
+
+ # validate the first result is the official lanyrd mobile app
+ self.wait_for_element_displayed(*self._search_results_area)
+ results = self.marionette.find_elements(*self._search_result)
+ self.assertGreater(len(results), 0, 'no results found')
+ app_name = results[0].find_element(*self._app_name_locator)
+ author = results[0].find_element(*self._author_locator)
+ self.assertEquals(app_name.text, APP_NAME, 'First app has wrong name')
+ self.assertEquals(author.text, APP_DEVELOPER,
+ 'First app wrong developer')
+
+ # Find and click the install button to the install the web app
+ install_button = results[0].find_element(*self._install_button)
+ self.assertEquals(install_button.text, 'Free', 'incorrect button label')
+ install_button.click()
+
+ # Confirm the installation of the web app
+ self.marionette.switch_to_frame()
+ self.wait_for_element_displayed(*self._yes_button_locator)
+ self.marionette.find_element(*self._yes_button_locator).click()
+
+ self.marionette.switch_to_frame()
+
+ # Wait for app install to complete in the homescreen
+ def wait_for_install_to_complete(marionette):
+ labels = marionette.find_elements(*self._icons_locator)
+ matches = [lb for lb in labels if lb.text == APP_NAME[:12]]
+ return len(matches) == 1
+
+ self.wait_for_condition(wait_for_install_to_complete)
+
+ def tearDown(self):
+
+ # close the app
+ if self.app:
+ self.apps.kill(self.app)
+
+ self.data_layer.disable_wifi()
+ self.apps.uninstall(APP_NAME)
+ GaiaTestCase.tearDown(self)
+
View
58 tests/python/gaiatest/tests/test_browser_cell_data.py
@@ -0,0 +1,58 @@
+# 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
+
+
+class TestBrowserCellData(GaiaTestCase):
+
+ # Firefox/chrome locators
+ _awesome_bar_locator = ("id", "url-input")
+ _url_button_locator = ("id", "url-button")
+ _throbber_locator = ("id", "throbber")
+ _browser_frame_locator = ('css selector', 'iframe[mozbrowser]')
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ # unlock the lockscreen if it's locked
+ self.lockscreen.unlock()
+
+ self.data_layer.disable_wifi()
+ self.data_layer.enable_cell_data()
+
+ # launch the app
+ self.app = self.apps.launch('Browser')
+
+ def test_browser_cell_data(self):
+ # https://moztrap.mozilla.org/manage/case/1328/
+
+ awesome_bar = self.marionette.find_element(*self._awesome_bar_locator)
+ awesome_bar.click()
+ awesome_bar.send_keys('http://mozqa.com/data/firefox/layout/mozilla.html')
+
+ self.marionette.find_element(*self._url_button_locator).click()
+
+ self.wait_for_condition(lambda m: not self.is_throbber_visible())
+
+ browser_frame = self.marionette.find_element(
+ *self._browser_frame_locator)
+
+ self.marionette.switch_to_frame(browser_frame)
+
+ heading = self.marionette.find_element('id', 'page-title')
+ self.assertEqual(heading.text, 'We believe that the internet should be public, open and accessible.')
+
+ def tearDown(self):
+
+ # close the app
+ if hasattr(self, 'app'):
+ self.apps.kill(self.app)
+
+ self.data_layer.disable_cell_data()
+
+ GaiaTestCase.tearDown(self)
+
+ def is_throbber_visible(self):
+ return self.marionette.find_element(*self._throbber_locator).size['height'] == 4
View
58 tests/python/gaiatest/tests/test_browser_wifi.py
@@ -0,0 +1,58 @@
+# 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
+
+
+class TestBrowserWifi(GaiaTestCase):
+
+ # Firefox/chrome locators
+ _awesome_bar_locator = ("id", "url-input")
+ _url_button_locator = ("id", "url-button")
+ _throbber_locator = ("id", "throbber")
+ _browser_frame_locator = ('css selector', 'iframe[mozbrowser]')
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ # unlock the lockscreen if it's locked
+ self.lockscreen.unlock()
+
+ self.data_layer.enable_wifi()
+ self.data_layer.connect_to_wifi(self.testvars['wifi'])
+
+ # launch the app
+ self.app = self.apps.launch('Browser')
+
+ def test_browser_wifi(self):
+ # https://moztrap.mozilla.org/manage/case/1327/
+
+ awesome_bar = self.marionette.find_element(*self._awesome_bar_locator)
+ awesome_bar.click()
+ awesome_bar.send_keys('http://mozqa.com/data/firefox/layout/mozilla.html')
+
+ self.marionette.find_element(*self._url_button_locator).click()
+
+ self.wait_for_condition(lambda m: not self.is_throbber_visible())
+
+ browser_frame = self.marionette.find_element(
+ *self._browser_frame_locator)
+
+ self.marionette.switch_to_frame(browser_frame)
+
+ heading = self.marionette.find_element('id', 'page-title')
+ self.assertEqual(heading.text, 'We believe that the internet should be public, open and accessible.')
+
+ def tearDown(self):
+
+ # close the app
+ if hasattr(self, 'app'):
+ self.apps.kill(self.app)
+
+ self.data_layer.disable_wifi()
+
+ GaiaTestCase.tearDown(self)
+
+ def is_throbber_visible(self):
+ return self.marionette.find_element(*self._throbber_locator).size['height'] == 4
View
50 tests/python/gaiatest/tests/test_calculator.py
@@ -6,36 +6,46 @@
class TestCalculator(GaiaTestCase):
- def test_calculator_basic(self):
+
+ _display_locator = ('id', 'display')
+ _multiply_button_locator = ('id', 'multiply')
+ _clear_button_locator = ('xpath', "//input[@value='C']")
+ _equals_button_locator = ('xpath', "//input[@value='=']")
+ _three_button_locator = ('xpath', "//input[@value='3']")
+ _five_button_locator = ('xpath', "//input[@value='5']")
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
# unlock the lockscreen if it's locked
- self.assertTrue(self.lockscreen.unlock())
+ self.lockscreen.unlock()
# launch the Calculator app
- app = self.apps.launch('Calculator')
- self.assertTrue(app.frame_id is not None)
+ self.app = self.apps.launch('Calculator')
- # switch into the Calculator's frame
- self.marionette.switch_to_frame(app.frame_id)
- url = self.marionette.get_url()
- self.assertTrue('calculator' in url, 'wrong url: %s' % url)
+ def test_calculator_basic(self):
+ # https://moztrap.mozilla.org/manage/case/2844/
+
+ # wait for the elements to show up
+ self.wait_for_element_displayed(*self._clear_button_locator)
# clear the calculator's display
- element = self.marionette.find_element('xpath', '//*[@value="C"]')
- element.click()
+ self.marionette.find_element(*self._clear_button_locator).click()
# perform a 3*5 calculation
- element = self.marionette.find_element('xpath', '//*[@value="3"]')
- element.click()
- element = self.marionette.find_element('id', 'multiply')
- element.click()
- element = self.marionette.find_element('xpath', '//*[@value="5"]')
- element.click()
- element = self.marionette.find_element('xpath', '//*[@value="="]')
- element.click()
+ self.marionette.find_element(*self._three_button_locator).click()
+ self.marionette.find_element(*self._multiply_button_locator).click()
+ self.marionette.find_element(*self._five_button_locator).click()
+ self.marionette.find_element(*self._equals_button_locator).click()
# verify the result
- display = self.marionette.find_element('id', 'display')
+ display = self.marionette.find_element(*self._display_locator)
self.assertEquals(display.text, '15', 'wrong calculated value!')
+ def tearDown(self):
+
# close the app
- self.apps.kill(app)
+ if hasattr(self, 'app'):
+ self.apps.kill(self.app)
+
+ GaiaTestCase.tearDown(self)
View
64 tests/python/gaiatest/tests/test_calendar.py
@@ -0,0 +1,64 @@
+# 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/.
+
+import datetime
+import calendar
+
+from gaiatest import GaiaTestCase
+
+
+DAYS_OF_WEEK = ['MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY',
+ 'SATURDAY', 'SUNDAY']
+
+
+class TestCalendar(GaiaTestCase):
+
+ _current_month_year_locator = ('id', 'current-month-year')
+ _selected_day_title_locator = ('id', 'selected-day-title')
+
+ def setUp(self):
+
+ GaiaTestCase.setUp(self)
+
+ # unlock the lockscreen if it's locked
+ self.lockscreen.unlock()
+
+ # launch the Calendar app
+ self.app = self.apps.launch('calendar')
+
+ def test_check_today_date(self):
+ # https://moztrap.mozilla.org/manage/case/3751/
+
+ # wait for the selected day and month title to render
+ self.wait_for_element_displayed(
+ *self._current_month_year_locator)
+ self.wait_for_element_displayed(
+ *self._selected_day_title_locator)
+
+ # find the default selected day and month title
+ selected_day = self.marionette.find_element(
+ *self._selected_day_title_locator)
+ month_title = self.marionette.find_element(
+ *self._current_month_year_locator)
+
+ # Get today's date - month, year, weekday
+ today = datetime.datetime.today()
+ month = calendar.month_name[today.month]
+ year = today.year
+ weekday = DAYS_OF_WEEK[today.weekday()]
+
+ # validate month title and selected day aligns with today's date
+ self.assertEquals(month_title.text, '%s %s' % (month, year),
+ "wrong month title for today");
+ self.assertEquals(selected_day.text, '%s %s %s' % (weekday,
+ month.upper(), year), "wrong selected day for today")
+
+ def tearDown(self):
+
+ # close the app
+ if hasattr(self, 'app'):
+ self.apps.kill(self.app)
+
+ GaiaTestCase.tearDown(self)
+
View
90 tests/python/gaiatest/tests/test_call_log.py
@@ -0,0 +1,90 @@
+# 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
+import unittest
+
+
+class TestCallLog(GaiaTestCase):
+
+ _recent_calls_toolbar_button_locator = ('id', 'option-recents')
+
+ _all_call_log_tab_locator = ('id', 'allFilter')
+ _missed_call_log_tab_locator = ('id', 'missedFilter')
+
+ _all_calls_list_item = ('css selector', 'li.log-item')
+ _missed_call_list_item = (
+ 'css selector', "li.log-item[data-type='incoming-refused']")
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ # TODO insert call data before the test
+ # This test will fail if no calls have been made
+
+ # unlock the lockscreen if it's locked
+ self.lockscreen.unlock()
+
+ # launch the app
+ self.app = self.apps.launch('Phone')
+
+ def test_call_log_all_calls(self):
+ # https://moztrap.mozilla.org/manage/case/1306/
+
+ self.wait_for_element_displayed(
+ *self._recent_calls_toolbar_button_locator)
+
+ self.marionette.find_element(
+ *self._recent_calls_toolbar_button_locator).click()
+
+ self.wait_for_element_displayed(*self._all_call_log_tab_locator)
+
+ all_calls_tab = self.marionette.find_element(
+ *self._all_call_log_tab_locator)
+ all_calls_tab.click()
+
+ # Check that 'All calls' tab is selected
+ self.assertEqual(all_calls_tab.get_attribute('class'), 'selected')
+
+ # Now check that at least one call is listed.
+ all_calls = self.marionette.find_elements(*self._all_calls_list_item)
+
+ self.assertGreater(len(all_calls), 0)
+
+ # Check that the first one is displayed. this is only a smoke test after all
+ self.assertTrue(all_calls[0].is_displayed())
+
+ def test_call_log_missed_calls(self):
+ # https://moztrap.mozilla.org/manage/case/1306/
+
+ self.wait_for_element_displayed(
+ *self._recent_calls_toolbar_button_locator)
+
+ self.marionette.find_element(
+ *self._recent_calls_toolbar_button_locator).click()
+ self.wait_for_element_displayed(*self._missed_call_log_tab_locator)
+
+ missed_calls_tab = self.marionette.find_element(
+ *self._missed_call_log_tab_locator)
+ missed_calls_tab.click()
+
+ # Check that 'Missed' tab is selected
+ self.assertEqual(missed_calls_tab.get_attribute('class'), 'selected')
+
+ # Now check that at least one call is listed.
+ missed_calls = self.marionette.find_elements(
+ *self._missed_call_list_item)
+
+ self.assertGreater(len(missed_calls), 0)
+
+ # Check that the first one is displayed. this is only a smoke test after all
+ self.assertTrue(missed_calls[0].is_displayed())
+
+ def tearDown(self):
+
+ # close the app
+ if self.app:
+ self.apps.kill(self.app)
+
+ GaiaTestCase.tearDown(self)
View
85 tests/python/gaiatest/tests/test_camera.py
@@ -0,0 +1,85 @@
+# 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
+
+
+class TestCamera(GaiaTestCase):
+
+ _capture_button_locator = ('id', 'capture-button')
+ _focus_ring = ('id','focus-ring')
+ _switch_source_button_locator = ('id', 'switch-button')
+ _film_strip_image_locator = (
+ 'css selector', 'div#film-strip div.image > img')
+ _video_capturing_locator = ('css selector', 'body.capturing')
+ _video_timer_locator = ('id', 'video-timer')
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ self.lockscreen.unlock()
+
+ # launch the Camera app
+ self.app = self.apps.launch('camera')
+
+ def test_capture_a_photo(self):
+ # https://moztrap.mozilla.org/manage/case/1325/
+
+ self.wait_for_capture_ready()
+
+ self.marionette.find_element(*self._capture_button_locator).click()
+
+ # Wait to complete focusing
+ self.wait_for_condition(lambda m: m.find_element(*self._focus_ring).get_attribute('data-state') != 'focusing')
+
+ focus_state = self.marionette.find_element(*self._focus_ring).get_attribute('data-state')
+ # The focus state will be either 'focused' or 'fail'
+ self.assertEqual(focus_state, 'focused', "Camera failed to focus with error: %s" % focus_state)
+
+ self.wait_for_element_present(*self._film_strip_image_locator)
+
+ # Find the new picture in the film strip
+ self.assertTrue(self.marionette.find_element(
+ *self._film_strip_image_locator).is_displayed())
+
+ def test_capture_a_video(self):
+ # https://moztrap.mozilla.org/manage/case/2477/
+
+ self.wait_for_capture_ready()
+ self.marionette.find_element(
+ *self._switch_source_button_locator).click()
+
+ self.wait_for_capture_ready()
+ self.marionette.find_element(*self._capture_button_locator).click()
+
+ self.wait_for_element_present(*self._video_capturing_locator)
+
+ # Wait for 3 seconds of recording
+ self.wait_for_condition(lambda m: m.find_element(
+ *self._video_timer_locator).text == '00:03')
+
+ # Stop recording
+ self.marionette.find_element(*self._capture_button_locator).click()
+
+ self.wait_for_element_not_displayed(*self._video_timer_locator)
+
+ # TODO
+ # Validate the recorded video somehow
+
+ def wait_for_capture_ready(self):
+ self.marionette.set_script_timeout(10000)
+ self.marionette.execute_async_script("""
+ waitFor(
+ function () { marionetteScriptFinished(); },
+ function () { return document.getElementById('viewfinder').readyState > 1; }
+ );
+ """)
+
+ def tearDown(self):
+
+ # close the app
+ if hasattr(self, 'app'):
+ self.apps.kill(self.app)
+
+ GaiaTestCase.tearDown(self)
View
65 tests/python/gaiatest/tests/test_cards_view.py
@@ -0,0 +1,65 @@
+# 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
+
+class TestCardsView(GaiaTestCase):
+
+ # Home/Cards view locators
+ _cards_view_locator = ('id', 'cards-view')
+ _calculator_card_locator = ('xpath', "//li[@class='card']/h1[text()='Calculator']")
+
+ # Calculator locators
+ _clear_button_locator = ('xpath', "//input[@value='C']")
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ # unlock the lockscreen if it's locked
+ self.lockscreen.unlock()
+
+ # launch the Calculator app as a basic, reliable
+ # app to test against in Cards View
+ self.app = self.apps.launch('Calculator')
+
+ # wait for the Calculator to load
+ self.wait_for_element_displayed(*self._clear_button_locator)
+
+ def test_cards_view(self):
+
+ # switch to top level frame before dispatching the event
+ self.marionette.switch_to_frame()
+
+ card_view_element = self.marionette.find_element(*self._cards_view_locator)
+ self.assertFalse(card_view_element.is_displayed(),
+ "Card view not expected to be visible")
+
+ self._hold_home_button()
+ self.wait_for_element_displayed(*self._cards_view_locator)
+
+ self.assertTrue(card_view_element.is_displayed(),
+ "Card view expected to be visible")
+
+ calculator_card = self.marionette.find_element(*self._calculator_card_locator)
+ self.assertTrue(calculator_card.is_displayed())
+
+ self._touch_home_button()
+ self.wait_for_element_not_displayed(*self._cards_view_locator)
+
+ self.assertFalse(card_view_element.is_displayed(),
+ "Card view not expected to be visible")
+
+ def _hold_home_button(self):
+ self.marionette.execute_script("window.wrappedJSObject.dispatchEvent(new Event('holdhome'));")
+
+ def _touch_home_button(self):
+ self.marionette.execute_script("window.wrappedJSObject.dispatchEvent(new Event('home'));")
+
+ def tearDown(self):
+
+ # close the app
+ if hasattr(self, 'app'):
+ self.apps.kill(self.app)
+
+ GaiaTestCase.tearDown(self)
View
92 tests/python/gaiatest/tests/test_clock.py
@@ -0,0 +1,92 @@
+# 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
+
+
+class TestClock(GaiaTestCase):
+
+ _alarm_create_new_locator = ('id', 'alarm-new')
+ _alarm_save_locator = ('id', 'alarm-done')
+ _banner_countdown_notification_locator = ('id', 'banner-countdown')
+ _picker_container = ('id', 'picker-container')
+ _alarm_name = (('xpath', "//input[@placeholder='Alarm']"))
+ _repeat_menu = ('id', 'repeat-menu')
+ _sound_menu = ('id', 'sound-menu')
+ _snooze_menu = ('id', 'snooze-menu')
+ _all_alarms = ('css selector', '#alarms li')
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ # unlock the lockscreen if it's locked
+ self.lockscreen.unlock()
+
+ # launch the Clock app
+ self.app = self.apps.launch('Clock')
+
+ def test_create_new_alarm(self):
+ # https://moztrap.mozilla.org/manage/case/1772/
+
+ self.wait_for_element_displayed(*self._alarm_create_new_locator)
+
+ # Get the number of alarms set, before adding the new alarm
+ initial_alarms_count = len(self.marionette.find_elements(*self._all_alarms))
+
+ # create a new alarm with the default values that are available
+ self.marionette.find_element(*self._alarm_create_new_locator).click()
+ self.marionette.find_element(*self._alarm_save_locator).click()
+
+ # verify the banner-countdown message appears
+ self.wait_for_element_displayed(*self._banner_countdown_notification_locator)
+ alarm_msg = self.marionette.find_element(*self._banner_countdown_notification_locator).text
+ self.assertTrue('The alarm is set for' in alarm_msg, 'Actual banner message was: "' + alarm_msg + '"')
+
+ # Get the number of alarms set after the new alarm was added
+ new_alarms_count = len(self.marionette.find_elements(*self._all_alarms))
+
+ # Ensure the new alarm has been added and is displayed
+ self.assertTrue(initial_alarms_count < new_alarms_count,
+ 'Alarms count did not increment')
+
+ def test_all_items_present_new_alarm(self):
+
+ # Wait for the new alarm screen to load
+ self.wait_for_element_displayed(*self._alarm_create_new_locator)
+
+ picker_container_tagname = self.marionette.find_element(*self._picker_container).tag_name
+ alarm_name_txt = self.marionette.find_element(*self._alarm_name).text
+ repeat_selector_txt = self.marionette.find_element(*self._repeat_menu).text
+ sound_selector_txt = self.marionette.find_element(*self._sound_menu).text
+ snooze_selector_txt = self.marionette.find_element(*self._snooze_menu).text
+
+ # Ensure that the picker container exists and is displayed
+ self.assertEquals(picker_container_tagname, 'div',
+ 'Container was %s' % picker_container_tagname)
+ self.assertTrue(self.marionette.find_element(*self._picker_container)
+ .is_displayed(), 'Picker container not displayed.')
+
+ # Ensure the alarm name input has the default text Alarm
+ self.assertEquals(alarm_name_txt, 'Alarm',
+ 'Alarm name was %s' % alarm_name_txt)
+
+ # If either Never is not the text or it does not exist the below will fail
+ self.assertEquals(repeat_selector_txt, 'Never',
+ 'Actual repeat selector text: %s' % repeat_selector_txt)
+
+ # If either Classic is not the text or it does not exist the below will fail
+ self.assertEquals(sound_selector_txt, 'Classic',
+ 'Actual sound selector text: %s' % sound_selector_txt)
+
+ # If either 5 minutes is not the text or it does not exist the below will fail
+ self.assertEquals(snooze_selector_txt, '5 minutes',
+ 'Actual snooze selector text: %s' % snooze_selector_txt)
+
+ def tearDown(self):
+
+ # close the app
+ if hasattr(self, 'app'):
+ self.apps.kill(self.app)
+
+ GaiaTestCase.tearDown(self)
View
96 tests/python/gaiatest/tests/test_dialer.py
@@ -0,0 +1,96 @@
+# 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
+import time
+
+
+class TestDialer(GaiaTestCase):
+
+ # Dialer app
+ _keyboard_container_locator = ('id', 'keyboard-container')
+ _phone_number_view_locator = ('id', 'phone-number-view')
+ _call_bar_locator = ('id', 'keypad-callbar-call-action')
+
+ # Call Screen app
+ _calling_number_locator = ('css selector', "div.number")
+ _outgoing_call_locator = ('css selector', 'div.direction.outgoing')
+ _hangup_bar_locator = ('id', 'callbar-hang-up-action')
+ _call_screen_locator = ('css selector', "iframe[name='call_screen']")
+
+
+ def setUp(self):
+
+ GaiaTestCase.setUp(self)
+
+ # unlock the lockscreen if it's locked
+ self.lockscreen.unlock()
+
+ # set audio volume to 0
+ self.data_layer.set_volume(0)
+
+ # launch the app
+ self.app = self.apps.launch('Phone')
+
+ self._test_phone_number = self.testvars['remote_phone_number']
+
+ def test_dialer_make_call(self):
+ # https://moztrap.mozilla.org/manage/case/1298/
+
+ self.wait_for_element_displayed(*self._keyboard_container_locator)
+
+ self._dial_number(self._test_phone_number)
+
+ # Assert that the number was entered correctly.
+ phone_view = self.marionette.find_element(
+ *self._phone_number_view_locator)
+
+ self.assertEqual(
+ phone_view.get_attribute('value'), self._test_phone_number)
+
+ # Now press call!
+ self.marionette.find_element(*self._call_bar_locator).click()
+
+ # Switch to top level frame
+ self.marionette.switch_to_frame()
+
+ # Wait for call screen then switch to it
+ self.wait_for_element_present(*self._call_screen_locator)
+ call_screen = self.marionette.find_element(*self._call_screen_locator)
+ self.marionette.switch_to_frame(call_screen)
+
+ # Wait for call screen to be dialing
+ self.wait_for_element_displayed(*self._outgoing_call_locator)
+
+ # Wait for the state to get to 'alerting' which means connection made
+ self.wait_for_condition(lambda m: self.data_layer.active_telephony_state == "alerting", timeout=20)
+
+ # Check the number displayed is the one we dialed
+ self.assertEqual(self._test_phone_number,
+ self.marionette.find_element(*self._calling_number_locator).text)
+
+ # hang up before the person answers ;)
+ self.marionette.find_element(*self._hangup_bar_locator).click()
+
+ def tearDown(self):
+
+ self.apps.kill_all()
+ GaiaTestCase.tearDown(self)
+
+ def _dial_number(self, phone_number):
+ '''
+ Dial a number using the keypad
+ '''
+
+ for i in phone_number:
+ if i == "+":
+ zero_button = self.marionette.find_element('css selector', 'div.keypad-key div[data-value="0"]')
+ self.marionette.long_press(zero_button, 1200)
+ # Wait same time as the long_press to bust the asynchronous
+ # TODO https://bugzilla.mozilla.org/show_bug.cgi?id=815115
+ time.sleep(2)
+
+ else:
+ self.marionette.find_element('css selector', 'div.keypad-key div[data-value="%s"]' % i).click()
+ time.sleep(0.25)
View
49 tests/python/gaiatest/tests/test_gallery.py
@@ -0,0 +1,49 @@
+# 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
+import time
+
+
+class TestGallery(GaiaTestCase):
+
+ _throbber_locator = ('id', 'throbber')
+ _gallery_items_locator = ('css selector', 'li.thumbnail')
+ _current_image_locator = ('css selector', '#frame2 > img')
+ _photos_toolbar_locator = ('id', 'photos-toolbar')
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ # unlock the lockscreen if it's locked
+ self.lockscreen.unlock()
+
+ # launch the Gallery app
+ self.app = self.apps.launch('Gallery')
+
+ def test_gallery_view(self):
+ # https://moztrap.mozilla.org/manage/case/1326/
+
+ # throbber is throbbing forever
+ self.wait_for_element_displayed(*self._gallery_items_locator)
+
+ self.marionette.find_elements(*self._gallery_items_locator)[0].click()
+
+ current_image = self.marionette.find_element(*self._current_image_locator)
+
+ self.wait_for_element_displayed(*self._current_image_locator)
+ self.assertIsNotNone(current_image.get_attribute('src'))
+
+ # TODO
+ # Add steps to view picture full screen
+ # TODO
+ # Repeat test with landscape orientation
+
+ def tearDown(self):
+
+ # close the app
+ if self.app:
+ self.apps.kill(self.app)
+
+ GaiaTestCase.tearDown(self)
View
29 tests/python/gaiatest/tests/test_killall.py
@@ -1,29 +0,0 @@
-# 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
-import time
-
-
-class TestKillAll(GaiaTestCase):
- def test_kill_all(self):
- # unlock the lockscreen if it's locked
- self.assertTrue(self.lockscreen.unlock())
-
- # launch the Calculator app
- app = self.apps.launch('Calculator')
- self.assertTrue(app.frame_id is not None)
-
- # launch the Clock app
- app = self.apps.launch('Clock')
- self.assertTrue(app.frame_id is not None)
-
- # kill all the apps
- self.apps.killAll()
-
- # verify no apps are active
- runningApps = self.apps.runningApps()
- for origin in runningApps.keys():
- if 'homescreen' not in origin:
- self.assertTrue(False, "%s still running" % origin)
View
57 tests/python/gaiatest/tests/test_lockscreen.py
@@ -0,0 +1,57 @@
+# 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
+
+
+class TestLockScreen(GaiaTestCase):
+
+ # Lockscreen area locators
+ _lockscreen_locator = ('id', 'lockscreen')
+ _lockscreen_handle_locator = ('id', 'lockscreen-area-handle')
+ _unlock_button_locator = ('id', 'lockscreen-area-unlock')
+
+ # Homescreen locators
+ _homescreen_frame_locator = ('css selector', 'iframe.homescreen')
+ _homescreen_landing_locator = ('id', 'landing-page')
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ # this time we need it locked!
+ self.lockscreen.lock()
+
+ def test_unlock_swipe_to_homescreen(self):
+ # https://moztrap.mozilla.org/manage/case/1296/
+
+ self._swipe_and_unlock()
+
+ unlock_button = self.marionette.find_element(*self._unlock_button_locator)
+ unlock_button.click()
+
+ lockscreen_element = self.marionette.find_element(*self._lockscreen_locator)
+ self.assertFalse(lockscreen_element.is_displayed(), "Lockscreen still visible after unlock")
+
+ hs_frame = self.marionette.find_element(*self._homescreen_frame_locator)
+ # TODO I would prefer to check visibility of the the frame at this point but bug 813583
+ self.marionette.switch_to_frame(hs_frame)
+
+ # Instead, check the main element of the landing screen
+ landing_element = self.marionette.find_element(*self._homescreen_landing_locator)
+
+ self.assertTrue(landing_element.is_displayed(), "Landing element not displayed after unlocking")
+
+ def _swipe_and_unlock(self):
+
+ unlock_handle = self.marionette.find_element(*self._lockscreen_handle_locator)
+ unlock_handle_x_centre = int(unlock_handle.size['width']/2)
+ unlock_handle_y_centre = int(unlock_handle.size['height']/2)
+
+ # Flick from unlock handle to (0, -100) over 800ms duration
+ self.marionette.flick(unlock_handle, unlock_handle_x_centre,
+ unlock_handle_y_centre, 0, -100, 800)
+
+ # Wait for the svg to animate and handle to disappear
+ # TODO add assertion that unlock buttons are visible after bug 813561 is fixed
+ self.wait_for_condition(lambda m: not unlock_handle.is_displayed())
View
68 tests/python/gaiatest/tests/test_music.py
@@ -0,0 +1,68 @@
+# 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
+import time
+
+class TestMusic(GaiaTestCase):
+
+ _body_list_mode_locator = ('css selector', 'body.list-mode')
+
+ _album_tile_locator = ('css selector', '#views-tiles div.tile-container')
+ _album_list_locator = ('css selector', '#views-list li > a')
+
+ _album_title_locator = ('class name', "list-main-title")
+ _player_seek_elapsed_locator = ('id', 'player-seek-elapsed')
+ _player_controls_play_locator = ('id', 'player-controls-play')
+ _tab_albums_locator = ('id', 'tabs-albums')
+ _views_player_locator = ('id', 'views-player')
+ _views_sublist_controls_play_locator = ('id', 'views-sublist-controls-play')
+
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ self.lockscreen.unlock()
+
+ # launch the Music application
+ self.app = self.apps.launch("music")
+
+ def test_select_album_play(self):
+ # https://moztrap.mozilla.org/manage/case/4031/
+
+ # wait for music tiles to appear as indication of indexing
+ self.wait_for_element_displayed(*self._album_tile_locator, timeout=60)
+
+ # switch to albums view
+ self.marionette.find_element(*self._tab_albums_locator).click()
+
+ # wait for it to switch into list mode
+ self.wait_for_element_present(*self._body_list_mode_locator)
+
+ # check that albums (at least one) are available
+ albums = self.marionette.find_elements(*self._album_list_locator)
+ self.assertGreater(len(albums), 0, 'no albums found')
+
+ # select an album
+ self.marionette.find_element(*self._album_list_locator).click()
+
+ # select play
+ self.marionette.find_element(*self._views_sublist_controls_play_locator).click()
+
+ # play for a short duration
+ self.wait_for_condition(lambda m: m.find_element(
+ *self._player_seek_elapsed_locator).text == '00:05')
+
+ # select stop
+ self.marionette.find_element(*self._player_controls_play_locator).click()
+
+ # TODO
+ # Validate audio playback
+
+ def tearDown(self):
+ # close the app
+ if hasattr(self, 'app'):
+ self.apps.kill(self.app)
+
+ GaiaTestCase.tearDown(self)
View
101 tests/python/gaiatest/tests/test_sms.py
@@ -0,0 +1,101 @@
+# 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
+import time
+
+
+class TestSms(GaiaTestCase):
+
+ # Summary page
+ _summary_header_locator = ('xpath', "//h1[text()='Messages']")
+ _create_new_message_locator = ('id', 'icon-add')
+ _unread_message_locator = ('css selector', 'div.item > a.unread')
+
+ # Message composition
+ _receiver_input_locator = ('id', 'receiver-input')
+ _message_field_locator = ('id', 'message-to-send')
+ _send_message_button_locator = ('id', 'send-message')
+ _back_header_link_locator = ('xpath', '//header/a[1]')
+ _message_sending_spinner_locator = ('css selector',
+ "img[src='style/images/spinningwheel_small_animation.gif']")
+
+ # Conversation view
+ _all_messages_locator = ('css selector', 'div.message-block')
+ _received_message_content_locator = ('xpath',
+ "//div[@class='message-block'][span[@class='bubble-container received']]")
+
+ def setUp(self):
+ GaiaTestCase.setUp(self)
+
+ # unlock the lockscreen if it's locked
+ self.lockscreen.unlock()
+
+ # launch the app
+ self.app = self.apps.launch('Messages')
+
+ def test_sms_send(self):
+ # https://moztrap.mozilla.org/manage/case/1322/
+
+ '''
+ This test sends a text message to itself. It waits for a reply message.
+ It does not yet clean up after itself but it can handle it.
+ '''
+
+ _text_message_content = "Automated Test %s" % str(time.time())
+
+ self.wait_for_element_displayed(*self._summary_header_locator)
+
+ # click new message
+ self.marionette.find_element(*self._create_new_message_locator).click()
+
+ self.wait_for_element_present(*self._receiver_input_locator)
+ # type phone number
+ contact_field = self.marionette.find_element(
+ *self._receiver_input_locator)
+ contact_field.send_keys(self.testvars['this_phone_number'])
+
+ message_field = self.marionette.find_element(
+ *self._message_field_locator)
+ message_field.send_keys(_text_message_content)
+
+ #click send
+ self.marionette.find_element(
+ *self._send_message_button_locator).click()
+