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

Unified Diff: LayoutTests/bluetooth/getCharacteristic.html

Issue 1146163005: bluetooth: Blink-side implementation of getCharacteristic. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@bluetooth-characteristic-interface
Patch Set: getCharacteristic Blink-Side Created 5 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: LayoutTests/bluetooth/getCharacteristic.html
diff --git a/LayoutTests/bluetooth/getCharacteristic.html b/LayoutTests/bluetooth/getCharacteristic.html
new file mode 100644
index 0000000000000000000000000000000000000000..9fd60f3d2f50ca211d6b95142ac9cdba0231ad27
--- /dev/null
+++ b/LayoutTests/bluetooth/getCharacteristic.html
@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="bluetooth-helpers.js"></script>
+<script>
+test(function(t) { assert_exists(window, "testRunner"); t.done(); },
+ "window.testRunner is required for the following tests.");
+
+var service1 = "00001800-0000-1000-8000-00805f9b34fb";
Jeffrey Yasskin 2015/06/03 00:24:04 Comment what these services and characteristics ar
ortuno 2015/06/03 21:57:03 Done.
+var characteristic1 = "00002a00-0000-1000-8000-00805f9b34fb";
+var characteristic2 = "00002a01-0000-1000-8000-00805f9b34fb";
+
+sequential_promise_test(function() {
+ testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
+ return navigator.bluetooth.requestDevice().then(function(device) {
+ return device.connectGATT().then(function(gattServer) {
Jeffrey Yasskin 2015/06/03 00:24:04 I think this could be: sequential_promise_test(fu
ortuno 2015/06/03 21:57:04 Done.
+ return gattServer.getPrimaryService(service1).then(function(service) {
+ testRunner.setBluetoothMockDataSet('EmptyAdapter');
+ return service.getCharacteristic(characteristic1).then(function() {
+ assert_unreached("Device went out of range, should fail.");
+ }, function(e) {
+ assert_equals(e.name, "NetworkError");
+ });
+ });
+ });
+ });
+}, 'Device goes out of range. Reject with NetworkError.');
+
+sequential_promise_test(function() {
+ testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
+ return navigator.bluetooth.requestDevice().then(function(device) {
+ return device.connectGATT();
+ }).then(function(gattServer) {
+ return gattServer.getPrimaryService(service1);
+ }).then(function(service) {
+ return service.getCharacteristic(characteristic2);
Jeffrey Yasskin 2015/06/03 00:24:04 It'd be better to query for a characteristic that
ortuno 2015/06/03 21:57:04 Done.
+ }).then(function(characteristic) {
+ assert_equals(characteristic, null,
+ "Non existent characteristic should return null.");
+ });
+}, 'Request for wrong characteristic. Should return null.');
+
+sequential_promise_test(function() {
+ testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
+ return navigator.bluetooth.requestDevice().then(function(device) {
+ return device.connectGATT();
+ }).then(function(gattServer) {
+ return gattServer.getPrimaryService(service1);
+ }).then(function(service) {
+ return service.getCharacteristic(characteristic1);
+ }).then(function(characteristic) {
+ assert_equals(characteristic.uuid, characteristic1,
+ "Characteristic UUID should be the same as requested UUID.");
+ });
+}, 'Request for characteristic. Should return right characteristic');
+
+sequential_promise_test(function() {
+ testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
+ return navigator.bluetooth.requestDevice().then(function(device) {
+ return device.connectGATT();
+ }).then(function(gattServer) {
+ return gattServer.getPrimaryService(service1);
+ }).then(function(services) {
+ return Promise.all([services.getCharacteristic(characteristic1),
+ services.getCharacteristic(characteristic1)]);
+ }).then(function(characteristics) {
+ // TODO(ortuno): getCharacteristic should return the same object
+ // if it was created earlier.
+ // https://crbug.com/495270
+ assert_not_equals(characteristics[0], characteristics[1],
+ "Should return the same service as the first call.");
+ });
+}, 'Calls to get the same characteristic should return the same object.');
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698