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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 function failOnError() {
6 if (chrome.runtime.lastError) {
7 chrome.test.fail(chrome.runtime.lastError.message);
8 return true;
9 }
10 return false;
11 }
12
13 function failOnSuccess() {
14 if (!chrome.runtime.lastError) {
15 chrome.test.fail('lastError not set, operation succeeded.');
16 return true;
17 }
18 return false;
19 }
20
21 // Normal correct input.
22 chrome.bluetoothLowEnergy.setAdvertisingInterval(100, 200, function() {
23 if (failOnError())
24 return;
25 // Correct input still.
26 chrome.bluetoothLowEnergy.setAdvertisingInterval(30, 30, function() {
27 if (failOnError())
28 return;
29 // Incorrect input, out of bounds (min).
30 chrome.bluetoothLowEnergy.setAdvertisingInterval(19, 30, function() {
31 if (failOnSuccess())
32 return;
33 // Incorrect input, out of bounds (max).
34 chrome.bluetoothLowEnergy.setAdvertisingInterval(100, 10241, function() {
35 if (failOnSuccess())
36 return;
37 // Incorrect input, min > max.
38 chrome.bluetoothLowEnergy.setAdvertisingInterval(100, 50, function() {
39 if (failOnSuccess())
40 return;
41 // Correct input, min.
42 chrome.bluetoothLowEnergy.setAdvertisingInterval(20, 50, function() {
43 if (failOnError())
44 return;
45 // Correct input, max.
46 chrome.bluetoothLowEnergy.setAdvertisingInterval(50, 10240,
47 function() {
48 if (failOnError())
49 return;
50 chrome.test.succeed()
51 });
52 });
53 });
54 });
55 });
56 });
57 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698