michael@0: // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*- michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: "use strict"; michael@0: michael@0: const { classes: Cc, interfaces: Ci, utils: Cu } = Components; michael@0: michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: Cu.import("resource://gre/modules/SimpleServiceDiscovery.jsm"); michael@0: michael@0: function discovery_observer(subject, topic, data) { michael@0: do_print("Observer: " + data); michael@0: michael@0: let service = SimpleServiceDiscovery.findServiceForLocation(data); michael@0: if (!service) michael@0: return; michael@0: michael@0: do_check_eq(service.friendlyName, "Pretend Device"); michael@0: do_check_eq(service.uuid, "uuid:5ec9ff92-e8b2-4a94-a72c-76b34e6dabb1"); michael@0: do_check_eq(service.manufacturer, "Copy Cat Inc."); michael@0: do_check_eq(service.modelName, "Eureka Dongle"); michael@0: michael@0: run_next_test(); michael@0: }; michael@0: michael@0: add_test(function test_default() { michael@0: do_register_cleanup(function cleanup() { michael@0: Services.obs.removeObserver(discovery_observer, "ssdp-service-found"); michael@0: }); michael@0: michael@0: Services.obs.addObserver(discovery_observer, "ssdp-service-found", false); michael@0: michael@0: // Create a pretend service michael@0: let service = { michael@0: location: "http://mochi.test:8888/tests/robocop/simpleservice.xml", michael@0: target: "test:service" michael@0: }; michael@0: michael@0: do_print("Force a detailed ping from a pretend service"); michael@0: michael@0: // Poke the service directly to get the discovery to happen michael@0: SimpleServiceDiscovery._processService(service); michael@0: }); michael@0: michael@0: run_next_test();