Bug 1184186 - Convert robocop testAndroidLog to mochitest-chrome; r=myk
authorGeoff Brown <gbrown@mozilla.com>
Mon, 03 Aug 2015 12:00:55 -0600
changeset 287619 f425dbcf5e3236f75d79b662a4cca518c837afb3
parent 287618 2d440acf37fe4fd69d0735fe5cafcfef34c7a62b
child 287620 04a6b52d1128849cac3320aec0abc989e56e0050
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmyk
bugs1184186
milestone42.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 1184186 - Convert robocop testAndroidLog to mochitest-chrome; r=myk
mobile/android/tests/browser/chrome/chrome.ini
mobile/android/tests/browser/chrome/test_android_log.html
mobile/android/tests/browser/robocop/robocop.ini
mobile/android/tests/browser/robocop/testAndroidLog.java
mobile/android/tests/browser/robocop/testAndroidLog.js
--- a/mobile/android/tests/browser/chrome/chrome.ini
+++ b/mobile/android/tests/browser/chrome/chrome.ini
@@ -1,8 +1,9 @@
 [DEFAULT]
 skip-if = os != 'android'
 support-files =
 
 [test_about_logins.html]
 [test_accounts.html]
+[test_android_log.html]
 [test_app_constants.html]
 [test_resource_substitutions.html]
new file mode 100644
--- /dev/null
+++ b/mobile/android/tests/browser/chrome/test_android_log.html
@@ -0,0 +1,95 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1004825
+Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 1004825</title>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <script type="application/javascript;version=1.7">
+
+  /*globals AndroidLog */
+
+  const TAG = "AndroidLogTest";
+
+  const VERBOSE_MESSAGE = "This is a verbose message.";
+  const DEBUG_MESSAGE = "This is a debug message.";
+  const INFO_MESSAGE = "This is an info message.";
+  const WARNING_MESSAGE = "This is a warning message.";
+  const ERROR_MESSAGE = "This is an error message.";
+
+  // Number of bytes we expect to log.  This isn't equivalent to the number
+  // of characters, although the difference is consistent, so we can calculate it
+  // from the lengths of the messages and tag.  We include the length of "Gecko"
+  // because the module prepends it to the tag.
+  const VERBOSE_BYTES = "Gecko".length + TAG.length + VERBOSE_MESSAGE.length + 3;
+  const DEBUG_BYTES = "Gecko".length + TAG.length + DEBUG_MESSAGE.length + 3;
+  const INFO_BYTES = "Gecko".length + TAG.length + INFO_MESSAGE.length + 3;
+  const WARNING_BYTES = "Gecko".length + TAG.length + WARNING_MESSAGE.length + 3;
+  const ERROR_BYTES = "Gecko".length + TAG.length + ERROR_MESSAGE.length + 3;
+
+  Components.utils.import("resource://gre/modules/AndroidLog.jsm");
+
+  ok(!!AndroidLog, "AndroidLog is defined");
+
+  ok("v" in AndroidLog && typeof AndroidLog.v == "function", "v function found");
+  ok("d" in AndroidLog && typeof AndroidLog.d == "function", "d function found");
+  ok("i" in AndroidLog && typeof AndroidLog.i == "function", "i function found");
+  ok("w" in AndroidLog && typeof AndroidLog.w == "function", "w function found");
+  ok("e" in AndroidLog && typeof AndroidLog.e == "function", "e function found");
+
+  // Ensure that the functions don't cause the test process to crash
+  // (because of some change to the native object being accessed via ctypes)
+  // and return the right values (the number of bytes logged).
+  // XXX Ensure that these messages actually make it to the log (bug 1046096).
+  is(VERBOSE_BYTES, AndroidLog.v(TAG, VERBOSE_MESSAGE), "verbose bytes correct");
+  is(DEBUG_BYTES, AndroidLog.d(TAG, DEBUG_MESSAGE), "debug bytes correct");
+  is(INFO_BYTES, AndroidLog.i(TAG, INFO_MESSAGE), "info bytes correct");
+  is(WARNING_BYTES, AndroidLog.w(TAG, WARNING_MESSAGE), "warning bytes correct");
+  is(ERROR_BYTES, AndroidLog.e(TAG, ERROR_MESSAGE), "error bytes correct");
+
+  // Ensure the functions work when bound with null value for thisArg parameter.
+  is(VERBOSE_BYTES, AndroidLog.v.bind(null, TAG)(VERBOSE_MESSAGE), "verbose bytes correct with bind");
+  is(DEBUG_BYTES, AndroidLog.d.bind(null, TAG)(DEBUG_MESSAGE), "debug bytes correct with bind");
+  is(INFO_BYTES, AndroidLog.i.bind(null, TAG)(INFO_MESSAGE), "info bytes correct with bind");
+  is(WARNING_BYTES, AndroidLog.w.bind(null, TAG)(WARNING_MESSAGE), "warning bytes correct with bind");
+  is(ERROR_BYTES, AndroidLog.e.bind(null, TAG)(ERROR_MESSAGE), "error bytes correct with bind");
+
+  // Ensure the functions work when the module object is "bound" to a tag.
+  let Log = AndroidLog.bind(TAG);
+  is(VERBOSE_BYTES, Log.v(VERBOSE_MESSAGE), "verbose bytes correct after bind");
+  is(DEBUG_BYTES, Log.d(DEBUG_MESSAGE), "debug bytes correct after bind");
+  is(INFO_BYTES, Log.i(INFO_MESSAGE), "info bytes correct after bind");
+  is(WARNING_BYTES, Log.w(WARNING_MESSAGE), "warning bytes correct after bind");
+  is(ERROR_BYTES, Log.e(ERROR_MESSAGE), "error bytes correct after bind");
+
+  // Ensure the functions work when the tag length is greater than the maximum
+  // tag length.
+  let tag = "X".repeat(AndroidLog.MAX_TAG_LENGTH + 1);
+  is(AndroidLog.MAX_TAG_LENGTH + 54, AndroidLog.v(tag, "This is a verbose message with a too-long tag."), "verbose message with too-long tag");
+  is(AndroidLog.MAX_TAG_LENGTH + 52, AndroidLog.d(tag, "This is a debug message with a too-long tag."), "debug message with too-long tag");
+  is(AndroidLog.MAX_TAG_LENGTH + 52, AndroidLog.i(tag, "This is an info message with a too-long tag."), "info message with too-long tag");
+  is(AndroidLog.MAX_TAG_LENGTH + 54, AndroidLog.w(tag, "This is a warning message with a too-long tag."), "warning message with too-long tag");
+  is(AndroidLog.MAX_TAG_LENGTH + 53, AndroidLog.e(tag, "This is an error message with a too-long tag."), "error message with too-long tag");
+
+  // We should also ensure that the module is accessible from a ChromeWorker,
+  // but there doesn't seem to be a way to load a ChromeWorker from this test.
+
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1004825">Mozilla Bug 1004825</a>
+<br>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1184186">Migrated from Robocop testAndroidLog</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
--- a/mobile/android/tests/browser/robocop/robocop.ini
+++ b/mobile/android/tests/browser/robocop/robocop.ini
@@ -105,17 +105,16 @@ skip-if = android_version == "10" || and
 skip-if = android_version == "10" || android_version == "18"
 # [testThumbnails.java] # see bug 813107
 [testTitleBar.java]
 # disabled on Android 2.3, bug 979552; on 4.3, bug 1145881
 skip-if = android_version == "10" || android_version == "18"
 # [testVkbOverlap.java] # see bug 907274
 
 # Using JavascriptTest
-[testAndroidLog.java]
 [testBrowserDiscovery.java]
 # disabled on 4.3, bug 1158384
 skip-if = android_version == "18"
 [testDebuggerServer.java]
 [testDesktopUserAgent.java]
 [testDeviceSearchEngine.java]
 [testFilePicker.java]
 [testHistoryService.java]
deleted file mode 100644
--- a/mobile/android/tests/browser/robocop/testAndroidLog.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/* 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/. */
-
-package org.mozilla.gecko.tests;
-
-
-public class testAndroidLog extends JavascriptTest {
-    public testAndroidLog() {
-        super("testAndroidLog.js");
-    }
-
-    @Override
-    public void testJavascript() throws Exception {
-        super.testJavascript();
-    }
-}
deleted file mode 100644
--- a/mobile/android/tests/browser/robocop/testAndroidLog.js
+++ /dev/null
@@ -1,75 +0,0 @@
-// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
-/* 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/. */
-
-/*globals AndroidLog */
-
-const TAG = "AndroidLogTest";
-
-const VERBOSE_MESSAGE = "This is a verbose message.";
-const DEBUG_MESSAGE = "This is a debug message.";
-const INFO_MESSAGE = "This is an info message.";
-const WARNING_MESSAGE = "This is a warning message.";
-const ERROR_MESSAGE = "This is an error message.";
-
-// Number of bytes we expect to log.  This isn't equivalent to the number
-// of characters, although the difference is consistent, so we can calculate it
-// from the lengths of the messages and tag.  We include the length of "Gecko"
-// because the module prepends it to the tag.
-const VERBOSE_BYTES = "Gecko".length + TAG.length + VERBOSE_MESSAGE.length + 3;
-const DEBUG_BYTES = "Gecko".length + TAG.length + DEBUG_MESSAGE.length + 3;
-const INFO_BYTES = "Gecko".length + TAG.length + INFO_MESSAGE.length + 3;
-const WARNING_BYTES = "Gecko".length + TAG.length + WARNING_MESSAGE.length + 3;
-const ERROR_BYTES = "Gecko".length + TAG.length + ERROR_MESSAGE.length + 3;
-
-add_task(function test_AndroidLog() {
-  Components.utils.import("resource://gre/modules/AndroidLog.jsm");
-
-  do_check_true(!!AndroidLog);
-
-  do_check_true("v" in AndroidLog && typeof AndroidLog.v == "function");
-  do_check_true("d" in AndroidLog && typeof AndroidLog.d == "function");
-  do_check_true("i" in AndroidLog && typeof AndroidLog.i == "function");
-  do_check_true("w" in AndroidLog && typeof AndroidLog.w == "function");
-  do_check_true("e" in AndroidLog && typeof AndroidLog.e == "function");
-
-  // Ensure that the functions don't cause the test process to crash
-  // (because of some change to the native object being accessed via ctypes)
-  // and return the right values (the number of bytes logged).
-  // XXX Ensure that these messages actually make it to the log (bug 1046096).
-  do_check_eq(VERBOSE_BYTES, AndroidLog.v(TAG, VERBOSE_MESSAGE));
-  do_check_eq(DEBUG_BYTES, AndroidLog.d(TAG, DEBUG_MESSAGE));
-  do_check_eq(INFO_BYTES, AndroidLog.i(TAG, INFO_MESSAGE));
-  do_check_eq(WARNING_BYTES, AndroidLog.w(TAG, WARNING_MESSAGE));
-  do_check_eq(ERROR_BYTES, AndroidLog.e(TAG, ERROR_MESSAGE));
-
-  // Ensure the functions work when bound with null value for thisArg parameter.
-  do_check_eq(VERBOSE_BYTES, AndroidLog.v.bind(null, TAG)(VERBOSE_MESSAGE));
-  do_check_eq(DEBUG_BYTES, AndroidLog.d.bind(null, TAG)(DEBUG_MESSAGE));
-  do_check_eq(INFO_BYTES, AndroidLog.i.bind(null, TAG)(INFO_MESSAGE));
-  do_check_eq(WARNING_BYTES, AndroidLog.w.bind(null, TAG)(WARNING_MESSAGE));
-  do_check_eq(ERROR_BYTES, AndroidLog.e.bind(null, TAG)(ERROR_MESSAGE));
-
-  // Ensure the functions work when the module object is "bound" to a tag.
-  let Log = AndroidLog.bind(TAG);
-  do_check_eq(VERBOSE_BYTES, Log.v(VERBOSE_MESSAGE));
-  do_check_eq(DEBUG_BYTES, Log.d(DEBUG_MESSAGE));
-  do_check_eq(INFO_BYTES, Log.i(INFO_MESSAGE));
-  do_check_eq(WARNING_BYTES, Log.w(WARNING_MESSAGE));
-  do_check_eq(ERROR_BYTES, Log.e(ERROR_MESSAGE));
-
-  // Ensure the functions work when the tag length is greater than the maximum
-  // tag length.
-  let tag = "X".repeat(AndroidLog.MAX_TAG_LENGTH + 1);
-  do_check_eq(AndroidLog.MAX_TAG_LENGTH + 54, AndroidLog.v(tag, "This is a verbose message with a too-long tag."));
-  do_check_eq(AndroidLog.MAX_TAG_LENGTH + 52, AndroidLog.d(tag, "This is a debug message with a too-long tag."));
-  do_check_eq(AndroidLog.MAX_TAG_LENGTH + 52, AndroidLog.i(tag, "This is an info message with a too-long tag."));
-  do_check_eq(AndroidLog.MAX_TAG_LENGTH + 54, AndroidLog.w(tag, "This is a warning message with a too-long tag."));
-  do_check_eq(AndroidLog.MAX_TAG_LENGTH + 53, AndroidLog.e(tag, "This is an error message with a too-long tag."));
-
-  // We should also ensure that the module is accessible from a ChromeWorker,
-  // but there doesn't seem to be a way to load a ChromeWorker from this test.
-});
-
-run_next_test();