Index: chrome/test/data/extensions/api_test/bluetooth_low_energy/create_descriptor/runtest.js |
diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/create_descriptor/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/create_descriptor/runtest.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..13b1b6969b60920a2f42e8cd66f391e758f59aa8 |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/create_descriptor/runtest.js |
@@ -0,0 +1,50 @@ |
+// 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. |
+ |
+function failOnError(result) { |
+ if (chrome.runtime.lastError || !result) { |
+ 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; |
+} |
+ |
+var service = { uuid: '00001234-0000-1000-8000-00805f9b34fb', isPrimary: true }; |
+chrome.bluetoothLowEnergy.createService(service, function(serviceId) { |
+ if (failOnError(serviceId)) |
+ return; |
+ |
+ var characteristic = { uuid: '00001234-0000-1000-8000-00805f9b34fa', |
+ properties: ['read']}; |
+ chrome.bluetoothLowEnergy.createCharacteristic(characteristic, serviceId, |
+ function(characteristicId) { |
+ if (failOnError(characteristicId)) |
+ return; |
+ |
+ var descriptor = { uuid: '00001234-0000-1000-8000-00805f9b34fc' }; |
+ // Invalid characteristic ID. |
+ chrome.bluetoothLowEnergy.createDescriptor(descriptor, |
+ 'invalidCharacteristicId', function(descriptorId) { |
+ if (failOnSuccess()) |
+ return; |
+ |
+ // Valid characteristic ID. |
+ chrome.bluetoothLowEnergy.createDescriptor(descriptor, characteristicId, |
+ function(descriptorId) { |
+ if (failOnError(descriptorId)) |
+ return; |
+ |
+ chrome.test.succeed(); |
+ }); |
+ }); |
+ }); |
+}); |