mobile/android/base/tests/testSimpleDiscovery.js

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5 "use strict";
michael@0 6
michael@0 7 const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
michael@0 8
michael@0 9 Cu.import("resource://gre/modules/Services.jsm");
michael@0 10 Cu.import("resource://gre/modules/SimpleServiceDiscovery.jsm");
michael@0 11
michael@0 12 function discovery_observer(subject, topic, data) {
michael@0 13 do_print("Observer: " + data);
michael@0 14
michael@0 15 let service = SimpleServiceDiscovery.findServiceForLocation(data);
michael@0 16 if (!service)
michael@0 17 return;
michael@0 18
michael@0 19 do_check_eq(service.friendlyName, "Pretend Device");
michael@0 20 do_check_eq(service.uuid, "uuid:5ec9ff92-e8b2-4a94-a72c-76b34e6dabb1");
michael@0 21 do_check_eq(service.manufacturer, "Copy Cat Inc.");
michael@0 22 do_check_eq(service.modelName, "Eureka Dongle");
michael@0 23
michael@0 24 run_next_test();
michael@0 25 };
michael@0 26
michael@0 27 add_test(function test_default() {
michael@0 28 do_register_cleanup(function cleanup() {
michael@0 29 Services.obs.removeObserver(discovery_observer, "ssdp-service-found");
michael@0 30 });
michael@0 31
michael@0 32 Services.obs.addObserver(discovery_observer, "ssdp-service-found", false);
michael@0 33
michael@0 34 // Create a pretend service
michael@0 35 let service = {
michael@0 36 location: "http://mochi.test:8888/tests/robocop/simpleservice.xml",
michael@0 37 target: "test:service"
michael@0 38 };
michael@0 39
michael@0 40 do_print("Force a detailed ping from a pretend service");
michael@0 41
michael@0 42 // Poke the service directly to get the discovery to happen
michael@0 43 SimpleServiceDiscovery._processService(service);
michael@0 44 });
michael@0 45
michael@0 46 run_next_test();

mercurial