Bug 1184186 - Convert robocop testVideoDiscovery to mochitest-chrome; r=mfinkle
authorGeoff Brown <gbrown@mozilla.com>
Thu, 06 Aug 2015 07:27:48 -0600
changeset 288192 514b2733ac8fe25ff933ca53f7abed755911f719
parent 288191 75953f632ffca76e4e30ab336985170159e1704c
child 288193 dd0af7b479aedb59abe176dd4b460e4c5040a77b
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)
reviewersmfinkle
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 testVideoDiscovery to mochitest-chrome; r=mfinkle
mobile/android/tests/browser/chrome/chrome.ini
mobile/android/tests/browser/chrome/test_video_discovery.html
mobile/android/tests/browser/chrome/video_discovery.html
mobile/android/tests/browser/robocop/robocop.ini
mobile/android/tests/browser/robocop/testVideoDiscovery.java
mobile/android/tests/browser/robocop/testVideoDiscovery.js
mobile/android/tests/browser/robocop/video_discovery.html
--- a/mobile/android/tests/browser/chrome/chrome.ini
+++ b/mobile/android/tests/browser/chrome/chrome.ini
@@ -2,16 +2,17 @@
 skip-if = os != 'android'
 support-files =
   basic_article.html
   desktopmode_user_agent.sjs
   devicesearch.xml
   session_formdata_sample.html
   simpleservice.xml
   video_controls.html
+  video_discovery.html
 
 [test_about_logins.html]
 [test_accounts.html]
 [test_android_log.html]
 [test_app_constants.html]
 [test_debugger_server.html]
 [test_desktop_useragent.html]
 [test_device_search_engine.html]
@@ -22,8 +23,9 @@ support-files =
 [test_network_manager.html]
 [test_offline_page.html]
 [test_reader_view.html]
 [test_resource_substitutions.html]
 [test_restricted_profiles.html]
 [test_session_form_data.html]
 [test_shared_preferences.html]
 [test_simple_discovery.html]
+[test_video_discovery.html]
new file mode 100644
--- /dev/null
+++ b/mobile/android/tests/browser/chrome/test_video_discovery.html
@@ -0,0 +1,143 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=953381
+Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 953381</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">
+
+  "use strict";
+
+  /*globals SimpleServiceDiscovery */
+
+  const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
+
+  Cu.import("resource://gre/modules/Services.jsm");
+  Cu.import("resource://gre/modules/SimpleServiceDiscovery.jsm");
+
+  // The chrome window
+  let chromeWin;
+
+  // Track the <browser> where the tests are happening
+  let browser;
+
+  function middle(element) {
+    let rect = element.getBoundingClientRect();
+    let x = (rect.right - rect.left) / 2 + rect.left;
+    let y = (rect.bottom - rect.top) / 2 + rect.top;
+    return [x, y];
+  }
+
+  // We must register a device and make a "mock" service for the device
+  var testDevice = {
+    id: "test:dummy",
+    target: "test:service",
+    factory: function(service) { /* dummy */  },
+    types: ["video/mp4", "video/webm"],
+    extensions: ["mp4", "webm"]
+  };
+
+  function setup_browser() {
+    chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
+    let BrowserApp = chromeWin.BrowserApp;
+
+    SimpleTest.registerCleanupFunction(function cleanup() {
+      BrowserApp.closeTab(BrowserApp.getTabForBrowser(browser));
+      SimpleServiceDiscovery.unregisterDevice(testDevice);
+    });
+
+    // We need to register a device or processService will ignore us
+    SimpleServiceDiscovery.registerDevice(testDevice);
+
+    // Create a pretend service
+    let service = {
+      location: "http://mochi.test:8888/chrome/mobile/android/tests/browser/chrome/simpleservice.xml",
+      target: "test:service"
+    };
+
+    dump("Force a detailed ping from a pretend service");
+
+    // Poke the service directly to get the discovery to happen
+    SimpleServiceDiscovery._processService(service);
+
+    // Load our test web page with <video> elements
+    let url = "http://mochi.test:8888/chrome/mobile/android/tests/browser/chrome/video_discovery.html";
+    browser = BrowserApp.addTab(url, { selected: true, parentId: BrowserApp.selectedTab.id }).browser;
+    browser.addEventListener("load", function startTests(event) {
+      browser.removeEventListener("load", startTests, true);
+      Services.tm.mainThread.dispatch(test_video, Ci.nsIThread.DISPATCH_NORMAL);
+    }, true);
+  }
+
+  let videoDiscoveryTests = [
+    { id: "simple-mp4", source: "http://mochi.test:8888/simple.mp4", poster: "http://mochi.test:8888/simple.png", text: "simple video with mp4 src" },
+    { id: "simple-fail", pass: false, text: "simple video with no mp4 src" },
+    { id: "with-sources-mp4", source: "http://mochi.test:8888/simple.mp4", text: "video with mp4 extension source child" },
+    { id: "with-sources-webm", source: "http://mochi.test:8888/simple.webm", text: "video with webm extension source child" },
+    { id: "with-sources-fail", pass: false, text: "video with no mp4 extension source child" },
+    { id: "with-sources-mimetype-mp4", source: "http://mochi.test:8888/simple-video-mp4", text: "video with mp4 mimetype source child" },
+    { id: "with-sources-mimetype-webm", source: "http://mochi.test:8888/simple-video-webm", text: "video with webm mimetype source child" },
+    { id: "video-overlay", source: "http://mochi.test:8888/simple.mp4", text: "div overlay covering a simple video with mp4 src" }
+  ];
+
+  function execute_video_test(test) {
+    let element = browser.contentDocument.getElementById(test.id);
+    if (element) {
+      let [x, y] = middle(element);
+      dump("Starting to getVideo");
+      chromeWin.CastingApps.getVideo(element, x, y, (video) => {
+        dump("got a Video");
+        if (video) {
+          let matchPoster = (test.poster == video.poster);
+          let matchSource = (test.source == video.source);
+          ok(matchPoster && matchSource && test.pass, test.text);
+        } else {
+          ok(!test.pass, test.text);
+        }
+      });
+    } else {
+      ok(false, "test element not found: [" + test.id + "]");
+    }
+  }
+
+  function test_video() {
+    let videoTest;
+    while ((videoTest = videoDiscoveryTests.shift())) {
+      if (!("poster" in videoTest)) {
+        videoTest.poster = "";
+      }
+      if (!("pass" in videoTest)) {
+        videoTest.pass = true;
+      }
+      execute_video_test(videoTest);
+    }
+    SimpleTest.finish();
+  }
+
+  SimpleTest.waitForExplicitFinish();
+  // On debug runs, 6 assertions typically observed; 3 each of:
+  //  - ASSERTION: cancel with non-failure status code: 'NS_FAILED(status)'
+  //  - ASSERTION: OnDataAvailable implementation consumed no data: 'Error'
+  SimpleTest.expectAssertions(0,6);
+  setup_browser();
+
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=953381">Mozilla Bug 953381</a>
+<br>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1184186">Migrated from Robocop testVideoDiscovery</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/mobile/android/tests/browser/chrome/video_discovery.html
@@ -0,0 +1,71 @@
+<!DOCTYPE HTML>
+<html>
+  <head>
+    <title>Video Discovery Test</title>
+    <style type="text/css">
+      #video-box {
+        float: left;
+      }
+      #video-overlay, #video-player {
+        width: 640px;
+        min-height: 370px;
+      }
+      #video-overlay {
+        position: absolute;
+        float: left;
+        background-color:#f00;
+        z-index:10;
+      }
+    </style>
+  </head>
+  <body>
+    <!-- PASS: src uses a mp4 extension -->
+    <video id="simple-mp4" poster="/simple.png" src="/simple.mp4"></video>
+
+    <!-- FAIL: src uses a ogg extension -->
+    <video id="simple-fail" src="/simple.ogg"></video>
+
+    <!-- PASS: source list uses a mp4 extension -->
+    <video id="with-sources-mp4">
+      <source src="/simple.ogg">
+      <source src="/simple.mp4">
+    </video>
+
+    <!-- PASS: source list uses a webm extension -->
+    <video id="with-sources-webm">
+      <source src="/simple.ogg">
+      <source src="/simple.webm">
+    </video>
+
+    <!-- FAIL: source list has no mp4 or webm extension -->
+    <video id="with-sources-fail">
+      <source src="/simple.ogg">
+    </video>
+
+    <!-- PASS: source list uses a mp4 mimetype -->
+    <video id="with-sources-mimetype-mp4">
+      <source src="/simple-video-ogg" type="video/ogg">
+      <source src="/simple-video-mp4" type="video/mp4">
+    </video>
+
+    <!-- PASS: source list uses a webm mimetype -->
+    <video id="with-sources-mimetype-webm">
+      <source src="/simple-video-ogg" type="video/ogg">
+      <source src="/simple-video-webm" type="video/webm">
+    </video>
+
+    <!-- PASS: source list uses a mp4 mimetype and extra data -->
+    <video id="with-sources-mimetype-plus">
+      <source src="/simple-video-ogg" type="video/ogg">
+      <source src="/simple-video-mp4" type="video/mp4; codecs='avc1.42E01E, mp4a.40.2'">
+    </video>
+
+    <!-- PASS: div overlay covers a video with mp4 src -->
+    <div id="video-box">
+      <div id="video-overlay"></div>
+      <div>
+        <video id="video-player" src="/simple.mp4"></video>
+      </div>
+    </div>
+  </body>
+</html>
--- a/mobile/android/tests/browser/robocop/robocop.ini
+++ b/mobile/android/tests/browser/robocop/robocop.ini
@@ -125,17 +125,16 @@ skip-if = android_version == "10" || and
 [testRestrictions.java]
 [testTrackingProtection.java]
 # disabled on 4.3, bug 1158363
 skip-if = android_version == "18"
 [testUITelemetry.java]
 [testVideoControls.java]
 # disabled on Android 2.3 due to video playback issues, bug 1088038; on 4.3, bug 1098532
 skip-if = android_version == "10" || android_version == "18"
-[testVideoDiscovery.java]
 [testWebChannel.java]
 
 # Used for Talos, please don't use in mochitest
 #[testCheck2.java]
 #[testCheck3.java] # and the autophone version
 
 # Using UITest
 #[testAboutHomePageNavigation.java] # see bug 947550, bug 979038 and bug 977952
deleted file mode 100644
--- a/mobile/android/tests/browser/robocop/testVideoDiscovery.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.mozilla.gecko.tests;
-
-
-
-public class testVideoDiscovery extends JavascriptTest {
-    public testVideoDiscovery() {
-        super("testVideoDiscovery.js");
-    }
-}
deleted file mode 100644
--- a/mobile/android/tests/browser/robocop/testVideoDiscovery.js
+++ /dev/null
@@ -1,116 +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/. */
-
-"use strict";
-
-/*globals SimpleServiceDiscovery */
-
-const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
-
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/SimpleServiceDiscovery.jsm");
-
-// The chrome window
-let chromeWin;
-
-// Track the <browser> where the tests are happening
-let browser;
-
-function middle(element) {
-  let rect = element.getBoundingClientRect();
-  let x = (rect.right - rect.left) / 2 + rect.left;
-  let y = (rect.bottom - rect.top) / 2 + rect.top;
-  return [x, y];
-}
-
-// We must register a device and make a "mock" service for the device
-var testDevice = {
-  id: "test:dummy",
-  target: "test:service",
-  factory: function(service) { /* dummy */  },
-  types: ["video/mp4", "video/webm"],
-  extensions: ["mp4", "webm"]
-};
-
-add_test(function setup_browser() {
-  chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
-  let BrowserApp = chromeWin.BrowserApp;
-
-  do_register_cleanup(function cleanup() {
-    BrowserApp.closeTab(BrowserApp.getTabForBrowser(browser));
-    SimpleServiceDiscovery.unregisterDevice(testDevice);
-  });
-
-  // We need to register a device or processService will ignore us
-  SimpleServiceDiscovery.registerDevice(testDevice);
-
-  // Create a pretend service
-  let service = {
-    location: "http://mochi.test:8888/tests/robocop/simpleservice.xml",
-    target: "test:service"
-  };
-
-  do_print("Force a detailed ping from a pretend service");
-
-  // Poke the service directly to get the discovery to happen
-  SimpleServiceDiscovery._processService(service);
-
-  // Load our test web page with <video> elements
-  let url = "http://mochi.test:8888/tests/robocop/video_discovery.html";
-  browser = BrowserApp.addTab(url, { selected: true, parentId: BrowserApp.selectedTab.id }).browser;
-  browser.addEventListener("load", function startTests(event) {
-    browser.removeEventListener("load", startTests, true);
-    Services.tm.mainThread.dispatch(run_next_test, Ci.nsIThread.DISPATCH_NORMAL);
-  }, true);
-});
-
-let videoDiscoveryTests = [
-  { id: "simple-mp4", source: "http://mochi.test:8888/simple.mp4", poster: "http://mochi.test:8888/simple.png", text: "simple video with mp4 src" },
-  { id: "simple-fail", pass: false, text: "simple video with no mp4 src" },
-  { id: "with-sources-mp4", source: "http://mochi.test:8888/simple.mp4", text: "video with mp4 extension source child" },
-  { id: "with-sources-webm", source: "http://mochi.test:8888/simple.webm", text: "video with webm extension source child" },
-  { id: "with-sources-fail", pass: false, text: "video with no mp4 extension source child" },
-  { id: "with-sources-mimetype-mp4", source: "http://mochi.test:8888/simple-video-mp4", text: "video with mp4 mimetype source child" },
-  { id: "with-sources-mimetype-webm", source: "http://mochi.test:8888/simple-video-webm", text: "video with webm mimetype source child" },
-  { id: "video-overlay", source: "http://mochi.test:8888/simple.mp4", text: "div overlay covering a simple video with mp4 src" }
-];
-
-function execute_video_test(test) {
-  let element = browser.contentDocument.getElementById(test.id);
-  if (element) {
-    let [x, y] = middle(element);
-    do_test_pending();
-    do_print("Starting to getVideo");
-    chromeWin.CastingApps.getVideo(element, x, y, (video) => {
-      do_print("got a Video");
-      if (video) {
-        let matchPoster = (test.poster == video.poster);
-        let matchSource = (test.source == video.source);
-        ok(matchPoster && matchSource && test.pass, test.text);
-      } else {
-        ok(!test.pass, test.text);
-      }
-      do_test_finished();
-      run_next_test();
-    });
-  } else {
-    ok(false, "test element not found: [" + test.id + "]");
-    run_next_test();
-  }
-}
-
-let videoTest;
-while ((videoTest = videoDiscoveryTests.shift())) {
-  if (!("poster" in videoTest)) {
-    videoTest.poster = "";
-  }
-  if (!("pass" in videoTest)) {
-    videoTest.pass = true;
-  }
-
-  add_test(execute_video_test.bind(this, videoTest));
-}
-
-run_next_test();
deleted file mode 100644
--- a/mobile/android/tests/browser/robocop/video_discovery.html
+++ /dev/null
@@ -1,71 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-  <head>
-    <title>Video Discovery Test</title>
-    <style type="text/css">
-      #video-box {
-        float: left;
-      }
-      #video-overlay, #video-player {
-        width: 640px;
-        min-height: 370px;
-      }
-      #video-overlay {
-        position: absolute;
-        float: left;
-        background-color:#f00;
-        z-index:10;
-      }
-    </style>
-  </head>
-  <body>
-    <!-- PASS: src uses a mp4 extension -->
-    <video id="simple-mp4" poster="/simple.png" src="/simple.mp4"></video>
-
-    <!-- FAIL: src uses a ogg extension -->
-    <video id="simple-fail" src="/simple.ogg"></video>
-
-    <!-- PASS: source list uses a mp4 extension -->
-    <video id="with-sources-mp4">
-      <source src="/simple.ogg">
-      <source src="/simple.mp4">
-    </video>
-
-    <!-- PASS: source list uses a webm extension -->
-    <video id="with-sources-webm">
-      <source src="/simple.ogg">
-      <source src="/simple.webm">
-    </video>
-
-    <!-- FAIL: source list has no mp4 or webm extension -->
-    <video id="with-sources-fail">
-      <source src="/simple.ogg">
-    </video>
-
-    <!-- PASS: source list uses a mp4 mimetype -->
-    <video id="with-sources-mimetype-mp4">
-      <source src="/simple-video-ogg" type="video/ogg">
-      <source src="/simple-video-mp4" type="video/mp4">
-    </video>
-
-    <!-- PASS: source list uses a webm mimetype -->
-    <video id="with-sources-mimetype-webm">
-      <source src="/simple-video-ogg" type="video/ogg">
-      <source src="/simple-video-webm" type="video/webm">
-    </video>
-
-    <!-- PASS: source list uses a mp4 mimetype and extra data -->
-    <video id="with-sources-mimetype-plus">
-      <source src="/simple-video-ogg" type="video/ogg">
-      <source src="/simple-video-mp4" type="video/mp4; codecs='avc1.42E01E, mp4a.40.2'">
-    </video>
-
-    <!-- PASS: div overlay covers a video with mp4 src -->
-    <div id="video-box">
-      <div id="video-overlay"></div>
-      <div>
-        <video id="video-player" src="/simple.mp4"></video>
-      </div>
-    </div>
-  </body>
-</html>