Bug 795544 - Test updates. r=bz
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Mon, 01 Oct 2012 21:49:12 +0900
changeset 109069 3afaf5133beca682a9e9700f150776ddbd4aeff0
parent 109068 1d4bafc6c4817a3e76d65219b6752fa02c8df247
child 109070 531b6090f45e0788a2ed2434e53aa9bb71234c82
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersbz
bugs795544
milestone18.0a1
Bug 795544 - Test updates. r=bz
dom/encoding/test/Makefile.in
dom/encoding/test/file_stringencoding.jsm
dom/encoding/test/stringencoding-license.txt
dom/encoding/test/test-big5.js
dom/encoding/test/test-euc-jp.js
dom/encoding/test/test-euc-kr.js
dom/encoding/test/test-gbk.js
dom/encoding/test/test-hz-gb-2312.js
dom/encoding/test/test-iso-2022-jp.js
dom/encoding/test/test-iso-2022-kr.js
dom/encoding/test/test-shift_jis.js
dom/encoding/test/test_stringencoding.html
dom/encoding/test/test_stringencoding.xul
dom/encoding/test/tests.js
dom/encoding/test/unit/Makefile.in
dom/encoding/test/unit/head.js
dom/encoding/test/unit/test_big5.js
dom/encoding/test/unit/test_euc-jp.js
dom/encoding/test/unit/test_euc-kr.js
dom/encoding/test/unit/test_gbk.js
dom/encoding/test/unit/test_hz-gb-2312.js
dom/encoding/test/unit/test_iso-2022-jp.js
dom/encoding/test/unit/test_iso-2022-kr.js
dom/encoding/test/unit/test_shift_jis.js
dom/encoding/test/unit/test_singlebytes.js
dom/encoding/test/unit/xpcshell.ini
testing/xpcshell/xpcshell.ini
--- a/dom/encoding/test/Makefile.in
+++ b/dom/encoding/test/Makefile.in
@@ -5,28 +5,28 @@
 DEPTH = @DEPTH@
 topsrcdir = @top_srcdir@
 srcdir = @srcdir@
 VPATH = @srcdir@
 relativesrcdir = @relativesrcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
+TEST_DIRS = unit
+
+XPCSHELL_TESTS = unit
+
 MOCHITEST_FILES = \
   test_BOMEncoding.js \
   test_TextDecoder.html \
   test_TextDecoder.js \
   test_TextEncoder.html \
   test_TextEncoder.js \
-  test-big5.js \
-  test-euc-jp.js \
-  test-euc-kr.js \
-  test-gbk.js \
-  test-hz-gb-2312.js \
-  test-iso-2022-jp.js \
-  test-iso-2022-kr.js \
-  test-shift_jis.js \
   test_stringencoding.html \
-  tests.js \
+  $(NULL)
+
+MOCHITEST_CHROME_FILES = \
+  file_stringencoding.jsm \
+  test_stringencoding.xul \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
new file mode 100644
--- /dev/null
+++ b/dom/encoding/test/file_stringencoding.jsm
@@ -0,0 +1,6 @@
+var EXPORTED_SYMBOLS = ['checkFromJSM'];
+
+function checkFromJSM(is_op) {
+  is_op(new TextDecoder().encoding, "utf-8", "JSM should have TextDecoder");
+  is_op(new TextEncoder().encoding, "utf-8", "JSM should have TextEncoder");
+}
--- a/dom/encoding/test/stringencoding-license.txt
+++ b/dom/encoding/test/stringencoding-license.txt
@@ -1,12 +1,12 @@
 The following files are licensed under Apache License 2.0 <https://www.apache.org/licenses/LICENSE-2.0
 >:
-test-big5.js
-test-euc-jp.js
-test-euc-kr.js
-test-gbk.js
-test-hz-gb-2312.js
-test-iso-2022-jp.js
-test-iso-2022-kr.js
-test-shift_jis.js
 test_stringencoding.html
-tests.js
+unit/test_big5.js
+unit/test_euc-jp.js
+unit/test_euc-kr.js
+unit/test_gbk.js
+unit/test_hz-gb-2312.js
+unit/test_iso-2022-jp.js
+unit/test_iso-2022-kr.js
+unit/test_shift_jis.js
+unit/test_singlebytes.js
--- a/dom/encoding/test/test_stringencoding.html
+++ b/dom/encoding/test/test_stringencoding.html
@@ -8,23 +8,23 @@ test = function(msg, no, func) { _test(f
 equal = assert_equals;
 ok = assert_true;
 raises = function(func) { assert_throws(null, func); };
 expect = function() {};
 </script>
 
 <div id="log"></div>
 
-<script type="text/javascript" src="tests.js"></script>
+<script type="text/javascript" src="unit/test_singlebytes.js"></script>
 <!-- TODO: test for all single-byte encoding indexes -->
 
-<script type="text/javascript" src="test-gbk.js"></script>
+<script type="text/javascript" src="unit/test_gbk.js"></script>
 <!-- TODO: gb18030 -->
-<script type="text/javascript" src="test-hz-gb-2312.js"></script>
+<script type="text/javascript" src="unit/test_hz-gb-2312.js"></script>
 
-<script type="text/javascript" src="test-big5.js"></script>
+<script type="text/javascript" src="unit/test_big5.js"></script>
 
-<script type="text/javascript" src="test-euc-jp.js"></script>
-<script type="text/javascript" src="test-iso-2022-jp.js"></script>
-<script type="text/javascript" src="test-shift_jis.js"></script>
+<script type="text/javascript" src="unit/test_euc-jp.js"></script>
+<script type="text/javascript" src="unit/test_iso-2022-jp.js"></script>
+<script type="text/javascript" src="unit/test_shift_jis.js"></script>
 
-<script type="text/javascript" src="test-euc-kr.js"></script>
-<script type="text/javascript" src="test-iso-2022-kr.js"></script>
+<script type="text/javascript" src="unit/test_euc-kr.js"></script>
+<script type="text/javascript" src="unit/test_iso-2022-kr.js"></script>
new file mode 100644
--- /dev/null
+++ b/dom/encoding/test/test_stringencoding.xul
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<window title="Test for StringEncoding API"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+  <!-- test results are displayed in the html:body -->
+  <body xmlns="http://www.w3.org/1999/xhtml">
+  </body>
+
+  <!-- test code goes here -->
+  <script type="application/javascript"><![CDATA[
+
+  /** Test for StringEncoding API. **/
+  const Cu = Components.utils;
+
+  // Import our test JSM. We first strip the filename off
+  // the chrome url, then append the jsm filename.
+  var base = /.*\//.exec(window.location.href)[0];
+  Cu.import(base + "file_stringencoding.jsm");
+
+  checkFromJSM(is);
+
+  ]]></script>
+</window>
new file mode 100644
--- /dev/null
+++ b/dom/encoding/test/unit/Makefile.in
@@ -0,0 +1,26 @@
+# 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/.
+
+DEPTH = @DEPTH@
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+relativesrcdir = @relativesrcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MOCHITEST_FILES = \
+  test_big5.js \
+  test_euc-jp.js \
+  test_euc-kr.js \
+  test_gbk.js \
+  test_hz-gb-2312.js \
+  test_iso-2022-jp.js \
+  test_iso-2022-kr.js \
+  test_shift_jis.js \
+  test_singlebytes.js \
+  $(NULL)
+
+include $(topsrcdir)/config/rules.mk
+
new file mode 100644
--- /dev/null
+++ b/dom/encoding/test/unit/head.js
@@ -0,0 +1,43 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+const { 'classes': Cc, 'interfaces': Ci } = Components;
+
+function equal(a, b, msg) {
+  dump("equal(" + a + ", " + b + ", \"" + msg + "\")");
+  do_check_eq(a, b, Components.stack.caller);
+}
+
+function ok(cond, msg) {
+  dump("ok(" + cond + ", \"" + msg + "\")");
+  do_check_true(!!cond, Components.stack.caller); 
+}
+
+function raises(func) {
+  dump("raises(" + func + ")");
+  try {
+    func();
+    do_check_true(false, Components.stack.caller); 
+  } catch (e) {
+    do_check_true(true, Components.stack.caller); 
+  }
+}
+
+var tests = [];
+
+function test(msg, no, func) {
+  tests.push({msg: msg, func: func || no});
+}
+
+function expect(count) {
+  dump("expect(", count, ")");
+}
+
+function run_test() {
+  tests.forEach(function(t) {
+    dump("test(\"" + t.msg + "\")");
+    t.func();
+  });
+};
rename from dom/encoding/test/test-big5.js
rename to dom/encoding/test/unit/test_big5.js
rename from dom/encoding/test/test-euc-jp.js
rename to dom/encoding/test/unit/test_euc-jp.js
rename from dom/encoding/test/test-euc-kr.js
rename to dom/encoding/test/unit/test_euc-kr.js
rename from dom/encoding/test/test-gbk.js
rename to dom/encoding/test/unit/test_gbk.js
rename from dom/encoding/test/test-hz-gb-2312.js
rename to dom/encoding/test/unit/test_hz-gb-2312.js
rename from dom/encoding/test/test-iso-2022-jp.js
rename to dom/encoding/test/unit/test_iso-2022-jp.js
rename from dom/encoding/test/test-iso-2022-kr.js
rename to dom/encoding/test/unit/test_iso-2022-kr.js
rename from dom/encoding/test/test-shift_jis.js
rename to dom/encoding/test/unit/test_shift_jis.js
rename from dom/encoding/test/tests.js
rename to dom/encoding/test/unit/test_singlebytes.js
new file mode 100644
--- /dev/null
+++ b/dom/encoding/test/unit/xpcshell.ini
@@ -0,0 +1,13 @@
+[DEFAULT]
+head = head.js
+tail =
+
+[test_big5.js]
+[test_euc-jp.js]
+[test_euc-kr.js]
+[test_gbk.js]
+[test_hz-gb-2312.js]
+[test_iso-2022-jp.js]
+[test_iso-2022-kr.js]
+[test_shift_jis.js]
+[test_singlebytes.js]
--- a/testing/xpcshell/xpcshell.ini
+++ b/testing/xpcshell/xpcshell.ini
@@ -4,16 +4,17 @@
 
 [include:chrome/test/unit/xpcshell.ini]
 [include:intl/locale/tests/unit/xpcshell.ini]
 [include:netwerk/cookie/test/unit/xpcshell.ini]
 [include:modules/libjar/zipwriter/test/unit/xpcshell.ini]
 [include:uriloader/exthandler/tests/unit/xpcshell.ini]
 [include:parser/xml/test/unit/xpcshell.ini]
 [include:image/test/unit/xpcshell.ini]
+[include:dom/encoding/test/unit/xpcshell.ini]
 [include:dom/plugins/test/unit/xpcshell.ini]
 [include:dom/sms/tests/xpcshell.ini]
 [include:dom/mms/tests/xpcshell.ini]
 [include:dom/network/tests/unit/xpcshell.ini]
 [include:dom/network/tests/unit_ipc/xpcshell.ini]
 [include:dom/src/json/test/unit/xpcshell.ini]
 [include:dom/system/gonk/tests/xpcshell.ini]
 [include:dom/tests/unit/xpcshell.ini]