michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=2 sts=2 et filetype=javascript 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: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: // Test Purpose: michael@0: // To verify that discovery process of BluetoothAdapter is correct. michael@0: // Use B2G emulator commands to add/remote remote devices to simulate michael@0: // discovering behavior. michael@0: // michael@0: // Test Coverage: michael@0: // - BluetoothAdapter.startDiscovery() michael@0: // - BluetoothAdapter.stopDiscovery() michael@0: // - BluetoothAdapter.ondevicefound() michael@0: // - BluetoothAdapter.discovering [Temporarily turned off until BT API update] michael@0: // michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: MARIONETTE_TIMEOUT = 60000; michael@0: MARIONETTE_HEAD_JS = 'head.js'; michael@0: michael@0: startBluetoothTest(true, function testCaseMain(aAdapter) { michael@0: log("Testing the discovery process of BluetoothAdapter ..."); michael@0: michael@0: // The properties of remote device. michael@0: let theProperties = { michael@0: "name": REMOTE_DEVICE_NAME, michael@0: "discoverable": true michael@0: }; michael@0: michael@0: return Promise.resolve() michael@0: .then(() => removeEmulatorRemoteDevice(BDADDR_ALL)) michael@0: .then(() => addEmulatorRemoteDevice(/*theProperties*/ null)) michael@0: .then(function(aRemoteAddress) { michael@0: let promises = []; michael@0: promises.push(waitForAdapterEvent(aAdapter, "devicefound")); michael@0: promises.push(startDiscovery(aAdapter)); michael@0: return Promise.all(promises) michael@0: .then(function(aResults) { michael@0: is(aResults[0].device.address, aRemoteAddress, "BluetoothDevice.address"); michael@0: }); michael@0: }) michael@0: .then(() => stopDiscovery(aAdapter)) michael@0: .then(() => removeEmulatorRemoteDevice(BDADDR_ALL)); michael@0: });