Bug 759529: add test case for SMS loopback, r=hsinyi
authorVicamo Yang <vyang@mozilla.com>
Thu, 17 Jan 2013 16:18:59 +0800
changeset 119139 0b076541046058893743dbebe3a6336e0a2550e7
parent 119138 02613b832b7c395c87e91caa7bfed513f29a4888
child 119140 08f1385d7f0fa7bd0e74e24823a047a280ea0ab6
push id24195
push userMs2ger@gmail.com
push dateSat, 19 Jan 2013 16:10:11 +0000
treeherderautoland@02e12a80aef9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs759529
milestone21.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 759529: add test case for SMS loopback, r=hsinyi
dom/sms/tests/marionette/manifest.ini
dom/sms/tests/marionette/test_emulator_loopback.js
--- a/dom/sms/tests/marionette/manifest.ini
+++ b/dom/sms/tests/marionette/manifest.ini
@@ -1,16 +1,17 @@
 [DEFAULT]
 b2g = true
 browser = false
 qemu = true
 
 ;[test_between_emulators.py]
 [test_incoming.js]
 [test_outgoing.js]
+[test_emulator_loopback.js]
 [test_message_classes.js]
 [test_incoming_delete.js]
 [test_outgoing_delete.js]
 [test_getmessage.js]
 [test_getmessage_notfound.js]
 [test_incoming_multipart.js]
 [test_getmessages.js]
 [test_filter_date.js]
new file mode 100644
--- /dev/null
+++ b/dom/sms/tests/marionette/test_emulator_loopback.js
@@ -0,0 +1,77 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 10000;
+
+const SELF = "5554";
+
+SpecialPowers.setBoolPref("dom.sms.enabled", true);
+SpecialPowers.addPermission("sms", true, document);
+
+function cleanUp() {
+  SpecialPowers.removePermission("sms", document);
+  SpecialPowers.clearUserPref("dom.sms.enabled");
+  finish();
+}
+
+let sms = window.navigator.mozSms;
+ok(sms instanceof MozSmsManager);
+
+function randomString16() {
+  return Math.random().toString(36).substr(2, 16);
+}
+
+function times(str, n) {
+  return (new Array(n + 1)).join(str);
+}
+
+function repeat(func, array, oncomplete) {
+  (function do_call(index) {
+    let next = index < (array.length - 1) ? do_call.bind(null, index + 1) : oncomplete;
+    func.apply(null, [array[index], next]);
+  })(0);
+}
+
+function doTest(body, callback) {
+  sms.addEventListener("received", function onReceived(event) {
+    event.target.removeEventListener(event.type, arguments.callee);
+
+    let message = event.message;
+    is(message.body, body, "message.body");
+
+    window.setTimeout(callback, 0);
+  });
+
+  let request = sms.send(SELF, body);
+  request.onerror = function onerror() {
+    ok(false, "failed to send message '" + body + "' to '" + SELF + "'");
+  };
+}
+
+repeat(doTest, [
+  // Random alphanumeric string of 16 characters.
+  randomString16(),
+  // Long long text message for multipart messages.
+  times(randomString16(), 100),
+
+  // UCS2 string for the first sentence of "The Cooing", Classic of Poetry.
+  "\u95dc\u95dc\u96ce\u9ce9\uff0c\u5728\u6cb3\u4e4b\u6d32\u3002",
+  // Long long UCS2 text message for multipart messages.
+  times("\u95dc\u95dc\u96ce\u9ce9\uff0c\u5728\u6cb3\u4e4b\u6d32\u3002", 100),
+
+  // Test case from Bug 809553
+  "zertuuuppzuzyeueieieyeieoeiejeheejrueufjfjfjjfjfkxifjfjfufjjfjfufujdjduxxjdu"
+  + "djdjdjdudhdjdhdjdbddhbfjfjxbuwjdjdudjddjdhdhdvdyudusjdudhdjjfjdvdudbddjdbd"
+  + "usjfbjdfudjdhdjbzuuzyzehdjjdjwybwudjvwywuxjdbfudsbwuwbwjdjdbwywhdbddudbdjd"
+  + "uejdhdudbdduwjdbjddudjdjdjdudjdbdjdhdhdjjdjbxudjdbxufjudbdjhdjdisjsjzusbzh"
+  + "xbdudksksuqjgdjdb jeudi jeudis duhebevzcevevsvs DVD suscite eh du d des jv"
+  + " y b Dj. Du  wh. Hu Deb wh. Du web h w show d DVD h w v.  Th\u00e9 \u00e9c"
+  + "hec d whdvdj. Wh d'h\u00f4tel DVD. IMAX eusjw ii ce",
+
+  // Android Emulator specific problems:
+  // 1) wrong default 7Bit alphabet character for "Ň"(U+0147).
+  "\u0147",
+  // 2) problem in decoding strings encoded with GSM 7Bit Alphabets and
+  // containing characters on extension tables.
+  "\u20ac****",
+], cleanUp);