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

Side by Side Diff: chrome/test/data/extensions/api_test/bluetooth_low_energy/create_characteristic/runtest.js

Issue 1920353002: Implement create attribute API functions for BTLE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@api_changes
Patch Set: owners Created 4 years, 7 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 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 function failOnError(result) {
6 if (chrome.runtime.lastError || !result) {
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
22 var service = { uuid: '00001234-0000-1000-8000-00805f9b34fb', isPrimary: true };
23 chrome.bluetoothLowEnergy.createService(service, function(serviceId) {
24 if (failOnError(serviceId))
25 return;
26
27 var characteristic = { uuid: '00001234-0000-1000-8000-00805f9b34fa',
28 properties: ['read']};
29 // Invalid service ID.
30 chrome.bluetoothLowEnergy.createCharacteristic(characteristic,
31 'invalidServiceId', function(characteristicId) {
32 if (failOnSuccess())
33 return;
34
35 // Valid service ID.
36 chrome.bluetoothLowEnergy.createCharacteristic(characteristic, serviceId,
37 function(characteristicId) {
38 if (failOnError(characteristicId))
39 return;
40 chrome.test.succeed();
41 });
42 });
43 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698