1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/bluetooth/tests/marionette/test_dom_BluetoothAdapter_getters.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,45 @@ 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 the properties of BluetoothAdapter can be updated and 1.13 +// retrieved correctly. Use B2G emulator commands to set properties for this 1.14 +// test case. 1.15 +// 1.16 +// Test Coverage: 1.17 +// - BluetoothAdapter.name 1.18 +// - BluetoothAdapter.address 1.19 +// - BluetoothAdapter.class 1.20 +// - BluetoothAdapter.discoverable 1.21 +// - BluetoothAdapter.discovering 1.22 +// ( P.S. Don't include [BluetoothAdapter.uuids], [BluetoothAdapter.devices] ) 1.23 +// 1.24 +/////////////////////////////////////////////////////////////////////////////// 1.25 + 1.26 +MARIONETTE_TIMEOUT = 60000; 1.27 +MARIONETTE_HEAD_JS = 'head.js'; 1.28 + 1.29 +function testAdapterGetter(aAdapter, aPropertyName, aParamName, aExpected) { 1.30 + let cmd = "bt property " + BDADDR_LOCAL + " " + aParamName; 1.31 + return runEmulatorCmdSafe(cmd) 1.32 + .then(function(aResults) { 1.33 + is(aResults[1], "OK", "The status report from emulator command."); 1.34 + log(" Got adapter " + aResults[0]); 1.35 + is(aResults[0], aParamName + ": " + aExpected, "BluetoothAdapter." + aPropertyName); 1.36 + }); 1.37 +} 1.38 + 1.39 +startBluetoothTest(true, function testCaseMain(aAdapter) { 1.40 + log("Checking the correctness of BluetoothAdapter properties ..."); 1.41 + 1.42 + return Promise.resolve() 1.43 + .then(() => testAdapterGetter(aAdapter, "name", "name", aAdapter.name)) 1.44 + .then(() => testAdapterGetter(aAdapter, "address", "address", aAdapter.address)) 1.45 + .then(() => testAdapterGetter(aAdapter, "class", "cod", "0x" + aAdapter.class.toString(16))) 1.46 + .then(() => testAdapterGetter(aAdapter, "discoverable", "discoverable", aAdapter.discoverable.toString())) 1.47 + .then(() => testAdapterGetter(aAdapter, "discovering", "discovering", aAdapter.discovering.toString())); 1.48 +});