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

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

Issue 2353133005: Add the chrome.bluetoothLowEnergy.setAdvertisingInterval API. (Closed)
Patch Set: . Created 4 years, 3 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/set_advertising_interval/runtest.js
diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/set_advertising_interval/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/set_advertising_interval/runtest.js
new file mode 100644
index 0000000000000000000000000000000000000000..8f3a244c3020a73d50e4109247c89ac037774f29
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/set_advertising_interval/runtest.js
@@ -0,0 +1,57 @@
+// Copyright 2015 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.
+
+function failOnError() {
+ if (chrome.runtime.lastError) {
+ chrome.test.fail(chrome.runtime.lastError.message);
+ return true;
+ }
+ return false;
+}
+
+function failOnSuccess() {
+ if (!chrome.runtime.lastError) {
+ chrome.test.fail('lastError not set, operation succeeded.');
+ return true;
+ }
+ return false;
+}
+
+// Normal correct input.
+chrome.bluetoothLowEnergy.setAdvertisingInterval(100, 200, function() {
+ if (failOnError())
+ return;
+ // Correct input still.
+ chrome.bluetoothLowEnergy.setAdvertisingInterval(30, 30, function() {
+ if (failOnError())
+ return;
+ // Incorrect input, out of bounds (min).
+ chrome.bluetoothLowEnergy.setAdvertisingInterval(19, 30, function() {
+ if (failOnSuccess())
+ return;
+ // Incorrect input, out of bounds (max).
+ chrome.bluetoothLowEnergy.setAdvertisingInterval(100, 10241, function() {
+ if (failOnSuccess())
+ return;
+ // Incorrect input, min > max.
+ chrome.bluetoothLowEnergy.setAdvertisingInterval(100, 50, function() {
+ if (failOnSuccess())
+ return;
+ // Correct input, min.
+ chrome.bluetoothLowEnergy.setAdvertisingInterval(20, 50, function() {
+ if (failOnError())
+ return;
+ // Correct input, max.
+ chrome.bluetoothLowEnergy.setAdvertisingInterval(50, 10240,
+ function() {
+ if (failOnError())
+ return;
+ chrome.test.succeed()
+ });
+ });
+ });
+ });
+ });
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698