gecko-dev/dom/bluetooth/tests/marionette/test_dom_BluetoothManager.js
Ben Tian f1367d5c1e Bug 1193379 - Move ipc and tests folders out from dom/bluetooth/bluetooth2. r=joliu
--HG--
rename : dom/bluetooth/bluetooth2/ipc/BluetoothChild.cpp => dom/bluetooth/ipc/BluetoothChild.cpp
rename : dom/bluetooth/bluetooth2/ipc/BluetoothChild.h => dom/bluetooth/ipc/BluetoothChild.h
rename : dom/bluetooth/bluetooth2/ipc/BluetoothMessageUtils.h => dom/bluetooth/ipc/BluetoothMessageUtils.h
rename : dom/bluetooth/bluetooth2/ipc/BluetoothParent.cpp => dom/bluetooth/ipc/BluetoothParent.cpp
rename : dom/bluetooth/bluetooth2/ipc/BluetoothParent.h => dom/bluetooth/ipc/BluetoothParent.h
rename : dom/bluetooth/bluetooth2/ipc/BluetoothServiceChildProcess.cpp => dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
rename : dom/bluetooth/bluetooth2/ipc/BluetoothServiceChildProcess.h => dom/bluetooth/ipc/BluetoothServiceChildProcess.h
rename : dom/bluetooth/bluetooth2/ipc/BluetoothTypes.ipdlh => dom/bluetooth/ipc/BluetoothTypes.ipdlh
rename : dom/bluetooth/bluetooth2/ipc/PBluetooth.ipdl => dom/bluetooth/ipc/PBluetooth.ipdl
rename : dom/bluetooth/bluetooth2/ipc/PBluetoothRequest.ipdl => dom/bluetooth/ipc/PBluetoothRequest.ipdl
rename : dom/bluetooth/bluetooth2/tests/marionette/head.js => dom/bluetooth/tests/marionette/head.js
rename : dom/bluetooth/bluetooth2/tests/marionette/manifest.ini => dom/bluetooth/tests/marionette/manifest.ini
rename : dom/bluetooth/bluetooth2/tests/marionette/test_dom_BluetoothAdapter_discovery_API2.js => dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_discovery.js
rename : dom/bluetooth/bluetooth2/tests/marionette/test_dom_BluetoothAdapter_enable_API2.js => dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_enable.js
rename : dom/bluetooth/bluetooth2/tests/marionette/test_dom_BluetoothAdapter_pair_API2.js => dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_pair.js
rename : dom/bluetooth/bluetooth2/tests/marionette/test_dom_BluetoothAdapter_setters_API2.js => dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_setters.js
rename : dom/bluetooth/bluetooth2/tests/marionette/test_dom_BluetoothDevice_API2.js => dom/bluetooth/tests/marionette/test_dom_BluetoothDevice.js
rename : dom/bluetooth/bluetooth2/tests/marionette/test_dom_BluetoothManager_API2.js => dom/bluetooth/tests/marionette/test_dom_BluetoothManager.js
2015-08-25 17:57:09 +08:00

49 lines
1.9 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
///////////////////////////////////////////////////////////////////////////////
// Test Purpose:
// To verify the basic functionality of BluetoothManager.
//
// Test Coverage:
// - BluetoothManager.defaultAdapter
// - BluetoothManager.getAdapters()
// TODO:
// - BluetoothManager.onattributechanged()
// - BluetoothManager.onadapteradded()
// - BluetoothManager.onadapterremoved()
//
///////////////////////////////////////////////////////////////////////////////
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
// TODO: Listens to 'onattributechanged' when B2G supports the feature that
// allows user to add/remove Bluetooth adapter.
// Currently, B2G recognizes build-in Bluetooth chip as default adapter and
// don't support adding additional Bluetooth dongles in gonk layer.
// Therefore, the 'onattributechanged' would be triggered *only* when the
// instance of BluetoothManager is created.
function waitForManagerAttributeChanged() {
let deferred = Promise.defer();
bluetoothManager.onattributechanged = function(aEvent) {
if(aEvent.attrs.indexOf("defaultAdapter")) {
bluetoothManager.onattributechanged = null;
ok(true, "BluetoothManager event 'onattributechanged' got.");
deferred.resolve(aEvent);
}
};
return deferred.promise;
}
startBluetoothTestBase(["settings-read", "settings-write", "settings-api-read", "settings-api-write"],
function testCaseMain() {
let adapters = bluetoothManager.getAdapters();
ok(Array.isArray(adapters), "Can not got the array of adapters");
ok(adapters.length, "The number of adapters should not be zero");
ok(bluetoothManager.defaultAdapter, "defaultAdapter should not be null.");
});