dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_discovery.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  * vim: sw=2 ts=2 sts=2 et filetype=javascript
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 ///////////////////////////////////////////////////////////////////////////////
     8 // Test Purpose:
     9 //   To verify that discovery process of BluetoothAdapter is correct.
    10 //   Use B2G emulator commands to add/remote remote devices to simulate
    11 //   discovering behavior.
    12 //
    13 // Test Coverage:
    14 //   - BluetoothAdapter.startDiscovery()
    15 //   - BluetoothAdapter.stopDiscovery()
    16 //   - BluetoothAdapter.ondevicefound()
    17 //   - BluetoothAdapter.discovering [Temporarily turned off until BT API update]
    18 //
    19 ///////////////////////////////////////////////////////////////////////////////
    21 MARIONETTE_TIMEOUT = 60000;
    22 MARIONETTE_HEAD_JS = 'head.js';
    24 startBluetoothTest(true, function testCaseMain(aAdapter) {
    25   log("Testing the discovery process of BluetoothAdapter ...");
    27   // The properties of remote device.
    28   let theProperties = {
    29     "name": REMOTE_DEVICE_NAME,
    30     "discoverable": true
    31   };
    33   return Promise.resolve()
    34     .then(() => removeEmulatorRemoteDevice(BDADDR_ALL))
    35     .then(() => addEmulatorRemoteDevice(/*theProperties*/ null))
    36     .then(function(aRemoteAddress) {
    37       let promises = [];
    38       promises.push(waitForAdapterEvent(aAdapter, "devicefound"));
    39       promises.push(startDiscovery(aAdapter));
    40       return Promise.all(promises)
    41         .then(function(aResults) {
    42           is(aResults[0].device.address, aRemoteAddress, "BluetoothDevice.address");
    43         });
    44     })
    45     .then(() => stopDiscovery(aAdapter))
    46     .then(() => removeEmulatorRemoteDevice(BDADDR_ALL));
    47 });

mercurial