Bug 1006320 - Add a marionette test for verifying the functionality BluetoothManager based on bluetooth API v2. r=btian

This commit is contained in:
Jamin Liu 2014-07-04 16:38:40 +08:00
parent 1f24c3b60b
commit d045f724ae
2 changed files with 50 additions and 0 deletions

View File

@ -2,3 +2,5 @@
b2g = true
browser = false
qemu = false
[test_dom_BluetoothManager_API2.js]

View File

@ -0,0 +1,48 @@
/* 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"],
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.");
});