OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 var deviceAddress = '11:12:13:14:15:16'; |
| 6 var errorNotConnected = 'Device is not connected'; |
| 7 var errorDisconnectFailed = 'Failed to disconnect device'; |
| 8 |
| 9 var btp = chrome.bluetoothPrivate; |
| 10 |
| 11 function testDisconnect() { |
| 12 btp.disconnectAll(deviceAddress, function() { |
| 13 assertFailure(errorNotConnected); |
| 14 btp.disconnectAll(deviceAddress, function() { |
| 15 assertFailure(errorNotConnected); |
| 16 btp.disconnectAll(deviceAddress, function() { |
| 17 assertFailure(errorDisconnectFailed); |
| 18 btp.disconnectAll(deviceAddress, function() { |
| 19 chrome.test.assertNoLastError(); |
| 20 chrome.test.succeed(); |
| 21 }); |
| 22 }); |
| 23 }); |
| 24 }); |
| 25 } |
| 26 |
| 27 function assertFailure(message) { |
| 28 if (!chrome.runtime.lastError) |
| 29 chrome.test.fail('Expected failure but got success.'); |
| 30 |
| 31 if (chrome.runtime.lastError.message == message) |
| 32 return; |
| 33 |
| 34 chrome.test.fail('Expected error "' + message + '" but got "' + |
| 35 chrome.runtime.lastError.message + '" instead.'); |
| 36 } |
| 37 |
| 38 chrome.test.runTests([testDisconnect]); |
OLD | NEW |