Permalink
Browse files

Merge pull request #7397 from jonallengriffin/bug826901

Bug 826901 - Mirror gaia-ui-tests to gaia, r=lightsofapollo, a=test-only
  • Loading branch information...
2 parents b7294d6 + f9a9699 commit 002baadd80cff97f098539676aa3dfa764b9ef23 @lightsofapollo lightsofapollo committed Jan 10, 2013
Showing with 1,313 additions and 255 deletions.
  1. +16 −15 tests/atoms/gaia_apps.js
  2. +14 −22 tests/atoms/gaia_data_layer.js
  3. +2 −0 tests/atoms/gaia_lock_screen.js
  4. +10 −9 tests/python/README.md
  5. +44 −10 tests/python/gaiatest/gaia_test.py
  6. +1 −1 tests/python/gaiatest/mocks/mock_contact.py
  7. +3 −0 tests/python/gaiatest/tests/__init__.py
  8. +3 −0 tests/python/gaiatest/tests/clock/__init__.py
  9. +50 −0 tests/python/gaiatest/tests/clock/clock_object.py
  10. +9 −0 tests/python/gaiatest/tests/clock/manifest.ini
  11. +39 −0 tests/python/gaiatest/tests/clock/test_clock_all_items_present_new_alarm.py
  12. +78 −0 tests/python/gaiatest/tests/clock/test_clock_create_new_alarm.py
  13. +46 −0 tests/python/gaiatest/tests/clock/test_clock_delete_alarm.py
  14. +59 −0 tests/python/gaiatest/tests/clock/test_clock_switch_clock_type.py
  15. +51 −0 tests/python/gaiatest/tests/clock/test_clock_turn_on_off_alarm.py
  16. +1 −4 tests/python/gaiatest/tests/contacts/manifest.ini
  17. +0 −6 tests/python/gaiatest/tests/contacts/test_add_new_contact.py
  18. +1 −2 tests/python/gaiatest/tests/contacts/test_call_contact.py
  19. +1 −2 tests/python/gaiatest/tests/contacts/test_edit_contact.py
  20. +4 −3 tests/python/gaiatest/tests/contacts/test_sms_contact.py
  21. +3 −0 tests/python/gaiatest/tests/fmradio/__init__.py
  22. +11 −0 tests/python/gaiatest/tests/fmradio/manifest.ini
  23. +63 −0 tests/python/gaiatest/tests/fmradio/test_fmradio_add_to_favorite.py
  24. +85 −0 tests/python/gaiatest/tests/fmradio/test_fmradio_find_stations.py
  25. +57 −0 tests/python/gaiatest/tests/fmradio/test_fmradio_remove_from_favorite.py
  26. +55 −0 tests/python/gaiatest/tests/fmradio/test_fmradio_turn_on_off.py
  27. +13 −4 tests/python/gaiatest/tests/manifest.ini
  28. +77 −18 tests/python/gaiatest/tests/marketplace/test_marketplace_login.py
  29. +0 −6 tests/python/gaiatest/tests/marketplace/test_search_marketplace_and_install_app.py
  30. +0 −6 tests/python/gaiatest/tests/test_browser_cell_data.py
  31. +5 −8 tests/python/gaiatest/tests/test_browser_lan.py
  32. +0 −8 tests/python/gaiatest/tests/test_calculator.py
  33. +8 −21 tests/python/gaiatest/tests/test_calendar.py
  34. +0 −8 tests/python/gaiatest/tests/test_call_log.py
  35. +9 −11 tests/python/gaiatest/tests/test_camera.py
  36. +11 −25 tests/python/gaiatest/tests/test_cards_view.py
  37. +0 −5 tests/python/gaiatest/tests/test_dialer.py
  38. +107 −0 tests/python/gaiatest/tests/test_dialer_verify.py
  39. +196 −0 tests/python/gaiatest/tests/test_ftu.py
  40. +0 −8 tests/python/gaiatest/tests/test_gallery.py
  41. +7 −1 tests/python/gaiatest/tests/test_launch_app.py
  42. +33 −2 tests/python/gaiatest/tests/test_lockscreen.py
  43. +0 −7 tests/python/gaiatest/tests/test_music.py
  44. +18 −10 tests/python/gaiatest/tests/test_radio.py
  45. +3 −12 tests/python/gaiatest/tests/test_sms.py
  46. +0 −8 tests/python/gaiatest/tests/test_updater.py
  47. +0 −8 tests/python/gaiatest/tests/test_video_player.py
  48. +77 −0 tests/python/gaiatest/tests/test_wallpaper.py
  49. +1 −0 tests/python/gaiatest/tests/unit/manifest.ini
  50. +33 −0 tests/python/gaiatest/tests/unit/test_debug.py
  51. +1 −1 tests/python/gaiatest/tests/unit/test_kill.py
  52. +2 −2 tests/python/gaiatest/tests/unit/test_killall.py
  53. +6 −2 tests/python/gaiatest/testvars_template.json
View
@@ -2,6 +2,8 @@
* 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/. */
+'use strict';
+
var GaiaApps = {
normalizeName: function(name) {
@@ -21,7 +23,8 @@ var GaiaApps = {
return origin;
},
- locateWithName: function(name, callback=marionetteScriptFinished) {
+ locateWithName: function(name, aCallback) {
+ var callback = aCallback || marionetteScriptFinished;
function sendResponse(app, appName, entryPoint) {
if (callback === marionetteScriptFinished) {
if (typeof(app) === 'object') {
@@ -149,33 +152,31 @@ var GaiaApps = {
app.launch(entryPoint || null);
- function sendResponse(origin) {
- let app = runningApps[origin];
- marionetteScriptFinished({frame: app.frame.id,
- src: app.frame.src,
- name: app.name,
- origin: origin});
- }
-
waitFor(
function() {
+ let app = runningApps[origin];
+ let result = {frame: app.frame.id,
+ src: app.frame.src,
+ name: app.name,
+ origin: origin};
+
if (alreadyRunning) {
// return the app's frame id
- sendResponse(origin);
+ marionetteScriptFinished(result);
}
else {
// wait until the new iframe sends the mozbrowserfirstpaint event
let frame = runningApps[origin].frame;
if (frame.dataset.unpainted) {
window.addEventListener('mozbrowserfirstpaint',
- function firstpaint() {
- window.removeEventListener('mozbrowserfirstpaint',
- firstpaint);
- sendResponse(origin);
+ function firstpaint() {
+ window.removeEventListener('mozbrowserfirstpaint',
+ firstpaint);
+ marionetteScriptFinished(result);
});
}
else {
- sendResponse(origin);
+ marionetteScriptFinished(result);
}
}
},
@@ -4,7 +4,7 @@
'use strict';
- var GaiaDataLayer = {
+var GaiaDataLayer = {
insertContact: function(cdata) {
contact = new mozContact();
@@ -46,7 +46,7 @@
var req = window.navigator.mozSettings.createLock().get(aName);
req.onsuccess = function() {
console.log('setting retrieved');
- result = aName === '*' ? req.result : req.result[aName];
+ let result = aName === '*' ? req.result : req.result[aName];
marionetteScriptFinished(result);
};
req.onerror = function() {
@@ -186,7 +186,8 @@
console.log("success forgetting network with ssid '" +
aNetwork.ssid + "'");
if (waitForStatus !== false) {
- console.log("waiting for connection status '" + waitForStatus + "'");
+ console.log("waiting for connection status '" +
+ waitForStatus + "'");
waitFor(
function() { callback(true); },
function() {
@@ -221,13 +222,13 @@
var manager = window.navigator.mozMobileConnection;
if (!manager.data.connected) {
- manager.ondatachange = function() {
- if (manager.data.connected) {
+ waitFor(
+ function() {
console.log('cell data enabled');
- manager.ondatachange = null;
marionetteScriptFinished(true);
- }
- };
+ },
+ function() { return manager.data.connected; }
+ );
this.setSetting('ril.data.enabled', true, false);
}
else {
@@ -240,27 +241,18 @@
var manager = window.navigator.mozMobileConnection;
if (manager.data.connected) {
- manager.ondatachange = function() {
- if (!manager.data.connected) {
+ waitFor(
+ function() {
console.log('cell data disabled');
- manager.ondatachange = null;
marionetteScriptFinished(true);
- }
- };
+ },
+ function() { return !manager.data.connected; }
+ );
this.setSetting('ril.data.enabled', false, false);
}
else {
console.log('cell data already disabled');
marionetteScriptFinished(true);
}
- },
-
- getFMHardwareState: function() {
- return window.navigator.mozFMRadio.enabled;
- },
-
- getFMHardwareFrequency: function() {
- return this.getFMHardwareState() &&
- window.navigator.mozFMRadio.frequency;
}
};
@@ -2,6 +2,8 @@
* 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/. */
+'use strict';
+
var GaiaLockScreen = {
unlock: function() {
View
@@ -1,4 +1,3 @@
-
Introduction
============
@@ -85,14 +84,16 @@ Variables:
}
`
-` WPA-EAP:
-"wifi": {
- "ssid": "MyNetwork",
- "keyManagement": "WPA-EAP",
- "password": "MyPassword",
- "identity": "MyIdentity"
-}
-`
+__Note__: Due to [Bug 775499](http://bugzil.la/775499), WiFi connections via WPA-EAP are not capable at this time.
+
+Test data Prerequisites
+=======================
+
+Occasionally a test will need data on the hardware that cannot be set during the test setUp.
+The following tests need data set up before they can be run successfully:
+
+`test_ftu` Requires a single record/contact saved onto the SIM card to test the SIM contact import
+
Writing Tests
=============
@@ -2,8 +2,10 @@
# 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 base64
import json
import os
+import sys
import time
from marionette import MarionetteTestCase
@@ -65,6 +67,7 @@ def launch(self, name, switch_to_frame=True, url=None):
return app
def uninstall(self, name):
+ self.marionette.switch_to_frame()
self.marionette.execute_async_script("GaiaApps.uninstallWithName('%s')" % name)
def kill(self, app):
@@ -116,27 +119,31 @@ def insert_contact(self, contact):
def remove_contact(self, contact):
self.marionette.execute_script("GaiaDataLayer.findAndRemoveContact(%s)" % contact.json())
- @property
- def all_settings(self):
- return self.marionette.execute_async_script('return GaiaDataLayer.getSetting("*")')
-
def get_setting(self, name):
+ self.marionette.switch_to_frame()
return self.marionette.execute_async_script('return GaiaDataLayer.getSetting("%s")' % name)
+ @property
+ def all_settings(self):
+ return self.get_setting('*')
+
def set_setting(self, name, value):
import json
value = json.dumps(value)
+ self.marionette.switch_to_frame()
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.marionette.switch_to_frame()
result = self.marionette.execute_async_script("return GaiaDataLayer.enableCellData()")
assert result, 'Unable to enable cell data'
def disable_cell_data(self):
+ self.marionette.switch_to_frame()
result = self.marionette.execute_async_script("return GaiaDataLayer.disableCellData()")
assert result, 'Unable to disable cell data'
@@ -147,10 +154,12 @@ def disable_cell_roaming(self):
self.set_setting('ril.data.roaming_enabled', False)
def enable_wifi(self):
+ self.marionette.switch_to_frame()
result = self.marionette.execute_async_script("return GaiaDataLayer.enableWiFi()")
assert result, 'Unable to enable WiFi'
def disable_wifi(self):
+ self.marionette.switch_to_frame()
result = self.marionette.execute_async_script("return GaiaDataLayer.disableWiFi()")
assert result, 'Unable to disable WiFi'
@@ -174,12 +183,17 @@ def active_telephony_state(self):
return self.marionette.execute_script("return GaiaDataLayer.getMozTelephonyState()")
@property
- def fm_state(self):
- return self.marionette.execute_script("return GaiaDataLayer.getFMHardwareState()")
+ def is_antenna_available(self):
+ return self.marionette.execute_script('return window.navigator.mozFMRadio.antennaAvailable')
@property
- def fm_frequency(self):
- return self.marionette.execute_script("return GaiaDataLayer.getFMHardwareFrequency()")
+ def is_fm_radio_enabled(self):
+ return self.marionette.execute_script('return window.navigator.mozFMRadio.enabled')
+
+ @property
+ def fm_radio_frequency(self):
+ return self.marionette.execute_script('return window.navigator.mozFMRadio.frequency')
+
class GaiaTestCase(MarionetteTestCase):
@@ -196,8 +210,8 @@ def setUp(self):
# wifi is true if testvars includes wifi details and wifi manager is defined
self.wifi = self.testvars and \
- 'wifi' in self.testvars and \
- self.marionette.execute_script('return window.navigator.mozWifiManager !== undefined')
+ 'wifi' in self.testvars and \
+ self.marionette.execute_script('return window.navigator.mozWifiManager !== undefined')
self.cleanUp()
@@ -290,7 +304,27 @@ def wait_for_condition(self, method, timeout=10,
else:
raise TimeoutException(message)
+ def is_element_present(self, by, locator):
+ try:
+ self.marionette.find_element(by, locator)
+ return True
+ except:
+ return False
+
def tearDown(self):
+ if any(sys.exc_info()):
+ # test has failed, gather debug
+ test_name = self.marionette.test_name.split()[-1]
+ debug_path = os.path.join('debug', *test_name.split('.'))
+ if not os.path.exists(debug_path):
+ os.makedirs(debug_path)
+
+ # screenshot
+ with open(os.path.join(debug_path, 'screenshot.png'), 'w') as f:
+ # TODO: Bug 818287 - Screenshots include data URL prefix
+ screenshot = self.marionette.screenshot()[22:]
+ f.write(base64.decodestring(screenshot))
+
self.lockscreen = None
self.apps = None
self.data_layer = None
@@ -22,7 +22,7 @@ def __init__(self, **kwargs):
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['tel'] = {'type':'Mobile','value':"555%s" % curr_time[8:]}
self['street'] = "101 Testing street"
self['zip'] = "90210"
self['city'] = "London"
@@ -0,0 +1,3 @@
+# 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/.
@@ -0,0 +1,3 @@
+# 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/.
@@ -0,0 +1,50 @@
+# 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 import MarionetteTestCase
+from marionette import Marionette
+import time
+
+_alarm_create_new_locator = ('id', 'alarm-new')
+
+_clock_day_date = ('id', 'clock-day-date')
+_analog_clock_display = ('id', 'analog-clock-svg')
+_digital_clock_display = ('id', 'digital-clock-display')
+_digital_clock_hour24_state = ('id', 'clock-hour24-state')
+
+_all_alarms = ('css selector', '#alarms li')
+_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')
+_new_alarm_label = ('name', 'alarm.label')
+_alarm_label = ('css selector', "div.alarmList-detail div.label")
+_alarm_checked_status = ('css selector', 'li label.alarmList #input-enable')
+_alarm_checked_status_button = ('css selector', 'li label.alarmList')
+_alarm_item = ('id', 'alarm-item')
+_alarm_delete_button = ('id', 'alarm-delete')
+
+def create_alarm(self):
+ """ create a new alarm for test """
+ self.wait_for_element_displayed(*_alarm_create_new_locator)
+ # find the origin alarms' number
+ initial_alarms_count = len(self.marionette.find_elements(*_all_alarms))
+ self.marionette.find_element(*_alarm_create_new_locator).click()
+ self.marionette.find_element(*_alarm_save_locator).click()
+ self.wait_for_element_displayed(*_alarm_create_new_locator)
+ self.wait_for_condition(lambda m: len(m.find_elements(*_all_alarms)) > initial_alarms_count)
+
+def delete_alarm(self):
+ """ delete the new alarm """
+ self.wait_for_element_displayed(*_alarm_create_new_locator)
+ # find the origin alarms' number
+ initial_alarms_count = len(self.marionette.find_elements(*_all_alarms))
+ self.marionette.find_element(*_alarm_item).click()
+ self.marionette.find_element(*_alarm_delete_button).click()
+ self.wait_for_element_displayed(*_alarm_create_new_locator)
+ self.wait_for_condition(lambda m: len(m.find_elements(*_all_alarms)) < initial_alarms_count)
+
@@ -0,0 +1,9 @@
+[DEFAULT]
+# Test requires B2G
+b2g = true
+
+[test_clock_all_items_present_new_alarm.py]
+[test_clock_create_new_alarm.py]
+[test_clock_delete_alarm.py]
+[test_clock_switch_clock_type.py]
+[test_clock_turn_on_off_alarm.py]
Oops, something went wrong.

0 comments on commit 002baad

Please sign in to comment.