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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/bluetooth_low_energy/create_characteristic/runtest.js
diff --git a/chrome/test/data/extensions/api_test/bluetooth_low_energy/create_characteristic/runtest.js b/chrome/test/data/extensions/api_test/bluetooth_low_energy/create_characteristic/runtest.js
new file mode 100644
index 0000000000000000000000000000000000000000..0c286e6f1839aa8d6bea0de435a334f767230aab
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/bluetooth_low_energy/create_characteristic/runtest.js
@@ -0,0 +1,43 @@
+// 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']};
+ // Invalid service ID.
+ chrome.bluetoothLowEnergy.createCharacteristic(characteristic,
+ 'invalidServiceId', function(characteristicId) {
+ if (failOnSuccess())
+ return;
+
+ // Valid service ID.
+ chrome.bluetoothLowEnergy.createCharacteristic(characteristic, serviceId,
+ function(characteristicId) {
+ if (failOnError(characteristicId))
+ return;
+ chrome.test.succeed();
+ });
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698