1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 var newAdapterName
= 'Dome';
7 function testSetAdapterState() {
8 chrome
.bluetooth
.getAdapterState(function(state
) {
9 chrome
.test
.assertNoLastError();
10 chrome
.test
.assertFalse(state
.powered
);
11 chrome
.test
.assertTrue(state
.name
!= newAdapterName
);
12 // TODO(tengs): Check if adapter is discoverable when the attribute is
13 // exposed to the chrome.bluetooth API.
18 function setAdapterState() {
25 chrome
.bluetoothPrivate
.setAdapterState(newState
, function() {
26 chrome
.test
.assertNoLastError();
27 if (chrome
.runtime
.lastError
)
28 chrome
.test
.fail(chrome
.runtime
.lastError
);
29 checkFinalAdapterState();
33 var adapterStateSet
= false;
34 function checkFinalAdapterState() {
35 chrome
.bluetooth
.getAdapterState(function(state
) {
36 chrome
.test
.assertNoLastError();
37 chrome
.test
.assertTrue(state
.powered
);
38 chrome
.test
.assertTrue(state
.name
== newAdapterName
);
39 // TODO(tengs): Check if adapter is discoverable when the attribute is
40 // exposed to the chrome.bluetooth API.
41 if (!adapterStateSet
) {
42 adapterStateSet
= true;
43 // Check indempotence of bluetoothPrivate.setAdapterState.
46 chrome
.test
.succeed();
51 chrome
.test
.runTests([ testSetAdapterState
]);