Bug 899484 - Part 2: Add marionette tests for roaming preference. r=hsinyi
authorEdgar Chen <echen@mozilla.com>
Tue, 30 Jul 2013 17:18:24 +0800
changeset 152807 64a7109de1bad80cf5900611478cdf6c4918f8b9
parent 152806 f3536cea7d3f03f96f407a897088d22c28b25838
child 152808 972a3554cf57ebfb2392f17a1f576010cf6f11d3
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs899484
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 899484 - Part 2: Add marionette tests for roaming preference. r=hsinyi
dom/network/tests/marionette/manifest.ini
dom/network/tests/marionette/test_mobile_roaming_preference.js
--- a/dom/network/tests/marionette/manifest.ini
+++ b/dom/network/tests/marionette/manifest.ini
@@ -8,10 +8,11 @@ disabled = Bug 808783
 [test_mobile_voice_state.js]
 [test_mobile_iccinfo.js]
 [test_mobile_operator_names.js]
 [test_mobile_preferred_network_type.js]
 disabled = Bug 808783
 [test_mobile_data_location.js]
 [test_mobile_data_state.js]
 [test_mobile_mmi.js]
+[test_mobile_roaming_preference.js]
 [test_call_barring_get_option.js]
 [test_call_barring_set_error.js]
new file mode 100644
--- /dev/null
+++ b/dom/network/tests/marionette/test_mobile_roaming_preference.js
@@ -0,0 +1,98 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+
+SpecialPowers.addPermission("mobileconnection", true, document);
+
+let connection = navigator.mozMobileConnection;
+ok(connection instanceof MozMobileConnection,
+   "connection is instanceof " + connection.constructor);
+
+function failedToSetRoamingPreference(mode, expectedErrorMessage, callback) {
+  let request = connection.setRoamingPreference(mode);
+
+  ok(request instanceof DOMRequest,
+     "request instanceof " + request.constructor);
+
+  request.onsuccess = function onsuccess() {
+    ok(false, "Should not be here !!");
+
+    callback();
+  }
+
+  request.onerror = function onerror() {
+    is(request.error.name, expectedErrorMessage);
+
+    callback();
+  }
+}
+
+function testSetRoamingPreferenceWithNullValue() {
+  log("test setRoamingPreference(null)");
+
+  failedToSetRoamingPreference(null, "InvalidParameter", runNextTest);
+}
+
+function testSetRoamingPreferenceWithInvalidValue() {
+  log("test setRoamingPreference(\"InvalidValue\")");
+
+  failedToSetRoamingPreference("InvalidValue", "InvalidParameter", runNextTest);
+}
+
+function testSetRoamingPreferenceToHome() {
+  log("test setRoamingPreference(\"home\")");
+
+  // TODO: Bug 896394.
+  // Currently emulator run as GSM mode by default. So we expect to get a
+  // 'RequestNotSupported' error here.
+  failedToSetRoamingPreference("home", "RequestNotSupported", runNextTest);
+}
+
+function testGetRoamingPreference() {
+  log("test getRoamingPreference()");
+
+  // TODO: Bug 896394.
+  // Currently emulator run as GSM mode by default. So we expect to get a
+  // 'RequestNotSupported' error here.
+  let request = connection.getRoamingPreference();
+
+  ok(request instanceof DOMRequest,
+     "request instanceof " + request.constructor);
+
+  request.onsuccess = function onsuccess() {
+    ok(false, "Should not be here !!");
+
+    runNextTest();
+  }
+
+  request.onerror = function onerror() {
+    is(request.error.name, "RequestNotSupported");
+
+    runNextTest();
+  }
+}
+
+let tests = [
+  testSetRoamingPreferenceWithNullValue,
+  testSetRoamingPreferenceWithInvalidValue,
+  testSetRoamingPreferenceToHome,
+  testGetRoamingPreference
+];
+
+function runNextTest() {
+  let test = tests.shift();
+  if (!test) {
+    cleanUp();
+    return;
+  }
+
+  test();
+}
+
+function cleanUp() {
+  SpecialPowers.removePermission("mobileconnection", document);
+  finish();
+}
+
+runNextTest();
\ No newline at end of file