1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_discovery.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,47 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * vim: sw=2 ts=2 sts=2 et filetype=javascript 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +/////////////////////////////////////////////////////////////////////////////// 1.11 +// Test Purpose: 1.12 +// To verify that discovery process of BluetoothAdapter is correct. 1.13 +// Use B2G emulator commands to add/remote remote devices to simulate 1.14 +// discovering behavior. 1.15 +// 1.16 +// Test Coverage: 1.17 +// - BluetoothAdapter.startDiscovery() 1.18 +// - BluetoothAdapter.stopDiscovery() 1.19 +// - BluetoothAdapter.ondevicefound() 1.20 +// - BluetoothAdapter.discovering [Temporarily turned off until BT API update] 1.21 +// 1.22 +/////////////////////////////////////////////////////////////////////////////// 1.23 + 1.24 +MARIONETTE_TIMEOUT = 60000; 1.25 +MARIONETTE_HEAD_JS = 'head.js'; 1.26 + 1.27 +startBluetoothTest(true, function testCaseMain(aAdapter) { 1.28 + log("Testing the discovery process of BluetoothAdapter ..."); 1.29 + 1.30 + // The properties of remote device. 1.31 + let theProperties = { 1.32 + "name": REMOTE_DEVICE_NAME, 1.33 + "discoverable": true 1.34 + }; 1.35 + 1.36 + return Promise.resolve() 1.37 + .then(() => removeEmulatorRemoteDevice(BDADDR_ALL)) 1.38 + .then(() => addEmulatorRemoteDevice(/*theProperties*/ null)) 1.39 + .then(function(aRemoteAddress) { 1.40 + let promises = []; 1.41 + promises.push(waitForAdapterEvent(aAdapter, "devicefound")); 1.42 + promises.push(startDiscovery(aAdapter)); 1.43 + return Promise.all(promises) 1.44 + .then(function(aResults) { 1.45 + is(aResults[0].device.address, aRemoteAddress, "BluetoothDevice.address"); 1.46 + }); 1.47 + }) 1.48 + .then(() => stopDiscovery(aAdapter)) 1.49 + .then(() => removeEmulatorRemoteDevice(BDADDR_ALL)); 1.50 +});