Bug 938571 - Add discovery support for second-screen devices (test) r=rnewman

This commit is contained in:
Mark Finkle 2013-12-27 17:25:45 -05:00
parent 9f53edc8dc
commit 05f13e7e4d
4 changed files with 72 additions and 0 deletions

View File

@ -72,6 +72,7 @@ skip-if = processor == "x86"
# [testMozPay] # see bug 945675
[testOrderedBroadcast]
[testSharedPreferences]
[testSimpleDiscovery]
[testUITelemetry]
# Used for Talos, please don't use in mochitest

View File

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<URLBase>http://example.com</URLBase>
<device>
<deviceType>urn:dial-multiscreen-org:device:dial:1</deviceType>
<friendlyName>Pretend Device</friendlyName>
<manufacturer>Copy Cat Inc.</manufacturer>
<modelName>Eureka Dongle</modelName>
<UDN>uuid:5ec9ff92-e8b2-4a94-a72c-76b34e6dabb1</UDN>
</device>
</root>

View File

@ -0,0 +1,10 @@
package org.mozilla.gecko.tests;
import org.mozilla.gecko.*;
public class testSimpleDiscovery extends JavascriptTest {
public testSimpleDiscovery() {
super("testSimpleDiscovery.js");
}
}

View File

@ -0,0 +1,46 @@
// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
/* 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";
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/SimpleServiceDiscovery.jsm");
function discovery_observer(subject, topic, data) {
do_print("Observer: " + data);
let service = SimpleServiceDiscovery.findServiceForLocation(data);
if (!service)
return;
do_check_eq(service.friendlyName, "Pretend Device");
do_check_eq(service.uuid, "uuid:5ec9ff92-e8b2-4a94-a72c-76b34e6dabb1");
do_check_eq(service.manufacturer, "Copy Cat Inc.");
do_check_eq(service.modelName, "Eureka Dongle");
run_next_test();
};
add_test(function test_default() {
do_register_cleanup(function cleanup() {
Services.obs.removeObserver(discovery_observer, "ssdp-service-found");
});
Services.obs.addObserver(discovery_observer, "ssdp-service-found", false);
// 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._found(service);
});
run_next_test();