From 524c0612fb872f49753123aa5a8684fa7cc6a246 Mon Sep 17 00:00:00 2001 From: Ben Hsu Date: Sun, 31 May 2015 22:42:00 -0400 Subject: [PATCH] Bug 979169 - A new testcase. r=aknow --- dom/telephony/test/marionette/head.js | 13 +++++ .../test/marionette/test_modem_switch_tech.js | 54 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 dom/telephony/test/marionette/test_modem_switch_tech.js diff --git a/dom/telephony/test/marionette/head.js b/dom/telephony/test/marionette/head.js index cea0bfb063a..d9c657fa9f9 100644 --- a/dom/telephony/test/marionette/head.js +++ b/dom/telephony/test/marionette/head.js @@ -276,6 +276,18 @@ let emulator = (function() { }); } + /** + * @return Promise + */ + function changeModemTech(aTech, aPreferredMask) { + return Promise.resolve() + .then(() => emulator.runCmd("modem tech " + aTech + " " + aPreferredMask)) + .then(() => emulator.runCmd("modem tech")) + .then(result => is(result[0], + aTech + " " + aPreferredMask, + "Check modem 'tech/preferred mask'")); + } + /** * @return Promise */ @@ -1152,6 +1164,7 @@ let emulator = (function() { this.gWaitForNamedStateEvent = waitForNamedStateEvent; this.gWaitForStateChangeEvent = waitForStateChangeEvent; this.gCheckInitialState = checkInitialState; + this.gChangeModemTech = changeModemTech; this.gClearCalls = clearCalls; this.gOutCallStrPool = outCallStrPool; this.gInCallStrPool = inCallStrPool; diff --git a/dom/telephony/test/marionette/test_modem_switch_tech.js b/dom/telephony/test/marionette/test_modem_switch_tech.js new file mode 100644 index 00000000000..a53008c2926 --- /dev/null +++ b/dom/telephony/test/marionette/test_modem_switch_tech.js @@ -0,0 +1,54 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +MARIONETTE_TIMEOUT = 60000; +MARIONETTE_HEAD_JS = "head.js"; + +let settings = [ + // "gsm/wcdma" + {tech: "gsm", mask: "gsm/wcdma"}, + {tech: "wcdma", mask: "gsm/wcdma"}, + + // "gsm" + {tech: "gsm", mask: "gsm"}, + + // "wcdma" + {tech: "wcdma", mask: "wcdma"}, + + // "gsm/wcdma-auto" + {tech: "gsm", mask: "gsm/wcdma-auto"}, + {tech: "wcdma", mask: "gsm/wcdma-auto"}, + + // "cdma/evdo" + {tech: "cdma", mask: "cdma/evdo"}, + {tech: "evdo", mask: "cdma/evdo"}, + + // "cdma" + {tech: "cdma", mask: "cdma"}, + + // "evdo" + {tech: "evdo", mask: "evdo"}, + + // "gsm/wcdma/cdma/evdo" + {tech: "gsm", mask: "gsm/wcdma/cdma/evdo"}, + {tech: "wcdma", mask: "gsm/wcdma/cdma/evdo"}, + {tech: "cdma", mask: "gsm/wcdma/cdma/evdo"}, + {tech: "evdo", mask: "gsm/wcdma/cdma/evdo"} +]; + +startTest(function() { + + let promise = settings.reduce((aPromise, aSetting) => { + return aPromise.then(() => gChangeModemTech(aSetting.tech, aSetting.mask)); + }, Promise.resolve()); + + return promise + // Exception Catching + .catch(error => ok(false, "Promise reject: " + error)) + + // Switch to the default modem tech + .then(() => gChangeModemTech("wcdma", "gsm/wcdma")) + .catch(error => ok(false, "Fetal Error: Promise reject: " + error)) + + .then(finish); +});