diff -r 000000000000 -r 6474c204b198 dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_getters.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_getters.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: sw=2 ts=2 sts=2 et filetype=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 that the properties of BluetoothAdapter can be updated and +// retrieved correctly. Use B2G emulator commands to set properties for this +// test case. +// +// Test Coverage: +// - BluetoothAdapter.name +// - BluetoothAdapter.address +// - BluetoothAdapter.class +// - BluetoothAdapter.discoverable +// - BluetoothAdapter.discovering +// ( P.S. Don't include [BluetoothAdapter.uuids], [BluetoothAdapter.devices] ) +// +/////////////////////////////////////////////////////////////////////////////// + +MARIONETTE_TIMEOUT = 60000; +MARIONETTE_HEAD_JS = 'head.js'; + +function testAdapterGetter(aAdapter, aPropertyName, aParamName, aExpected) { + let cmd = "bt property " + BDADDR_LOCAL + " " + aParamName; + return runEmulatorCmdSafe(cmd) + .then(function(aResults) { + is(aResults[1], "OK", "The status report from emulator command."); + log(" Got adapter " + aResults[0]); + is(aResults[0], aParamName + ": " + aExpected, "BluetoothAdapter." + aPropertyName); + }); +} + +startBluetoothTest(true, function testCaseMain(aAdapter) { + log("Checking the correctness of BluetoothAdapter properties ..."); + + return Promise.resolve() + .then(() => testAdapterGetter(aAdapter, "name", "name", aAdapter.name)) + .then(() => testAdapterGetter(aAdapter, "address", "address", aAdapter.address)) + .then(() => testAdapterGetter(aAdapter, "class", "cod", "0x" + aAdapter.class.toString(16))) + .then(() => testAdapterGetter(aAdapter, "discoverable", "discoverable", aAdapter.discoverable.toString())) + .then(() => testAdapterGetter(aAdapter, "discovering", "discovering", aAdapter.discovering.toString())); +});