Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/bluetooth_private/disconnect/test.js |
| diff --git a/chrome/test/data/extensions/api_test/bluetooth_private/disconnect/test.js b/chrome/test/data/extensions/api_test/bluetooth_private/disconnect/test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8c598224f96ec67163e1a1913f19aff55b9a58f7 |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/bluetooth_private/disconnect/test.js |
| @@ -0,0 +1,37 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +var deviceAddress = '11:12:13:14:15:16'; |
| +var errorNotConnected = 'Device is not connected'; |
| +var errorDisconnectFailed = 'Failed to disconnect device'; |
|
Jeffrey Yasskin
2014/12/20 00:53:48
This message has been really annoying when debuggi
armansito
2014/12/20 01:24:28
The only error that BlueZ returns is 'org.bluez.Er
Jeffrey Yasskin
2014/12/20 01:29:58
If this error case is impossible, you should proba
armansito
2014/12/20 01:43:38
No it's not impossible. I'm not sure I'm following
|
| + |
| +var btp = chrome.bluetoothPrivate; |
| + |
| +function testDisconnect() { |
| + btp.disconnect(deviceAddress, function() { |
| + assertFailure(errorNotConnected); |
| + btp.disconnect(deviceAddress, function() { |
| + assertFailure(errorDisconnectFailed); |
| + btp.disconnect(deviceAddress, function() { |
| + chrome.test.assertNoLastError(); |
| + if (chrome.runtime.lastError) |
|
Jeffrey Yasskin
2014/12/20 00:53:48
Isn't this redundant with the assertNoLastError()
armansito
2014/12/20 01:24:28
I'm not sure actually, as I mostly followed the ot
|
| + chrome.test.fail(chrome.runtime.lastError); |
| + chrome.test.succeed(); |
| + }); |
| + }); |
| + }); |
| +} |
| + |
| +function assertFailure(message) { |
| + if (!chrome.runtime.lastError) |
| + chrome.test.fail('Expected failure but got success.'); |
| + |
| + if (chrome.runtime.lastError.message == message) |
| + return; |
| + |
| + chrome.test.fail('Expected error "' + message + '" but got "' + |
| + chrome.runtime.lastError.message + '" instead.'); |
| +} |
| + |
| +chrome.test.runTests([testDisconnect]); |