Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4518)

Unified Diff: chrome/test/data/extensions/api_test/bluetooth_low_energy/reconnect_after_disconnected/runtest.js

Issue 349433002: chrome.bluetoothLowEnergy: Introduce connect and disconnect methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/bluetooth_low_energy/reconnect_after_disconnected/runtest.js
diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/reconnect_after_disconnected/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/reconnect_after_disconnected/runtest.js
new file mode 100644
index 0000000000000000000000000000000000000000..094602326992357609012ae0338a45ea88f49bf2
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/reconnect_after_disconnected/runtest.js
@@ -0,0 +1,35 @@
+// 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 deviceAddress0 = '11:22:33:44:55:66';
+var ble = chrome.bluetoothLowEnergy;
+
+var errorAlreadyConnected = 'Already connected';
+
+function expectError(message) {
+ if (!chrome.runtime.lastError ||
+ chrome.runtime.lastError.message != message)
+ chrome.test.fail('Expected error: ' + message);
+}
+
+function expectSuccess() {
+ if (chrome.runtime.lastError)
+ chrome.test.fail('Unexpected error: ' + chrome.runtime.lastError.message);
+}
+
+// First attempt should succeed.
+ble.connect(deviceAddress0, function () {
+ expectSuccess();
+
+ // Second attempt should fail.
+ ble.connect(deviceAddress0, function () {
+ expectError(errorAlreadyConnected);
+
+ // Third attempt should succeed.
+ ble.connect(deviceAddress0, function () {
+ expectSuccess();
+ chrome.test.succeed();
+ });
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698