Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / bluetooth_private / adapter_state / test.js
blob78ac8b8e13b39f20596540effd6af5f2041affc4
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.
14 setAdapterState();
15 });
18 function setAdapterState() {
19 var newState = {
20 name: newAdapterName,
21 powered: true,
22 discoverable: true
25 chrome.bluetoothPrivate.setAdapterState(newState, function() {
26 chrome.test.assertNoLastError();
27 if (chrome.runtime.lastError)
28 chrome.test.fail(chrome.runtime.lastError);
29 checkFinalAdapterState();
30 });
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.
44 setAdapterState();
45 } else {
46 chrome.test.succeed();
48 });
51 chrome.test.runTests([ testSetAdapterState ]);