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

Unified Diff: LayoutTests/bluetooth/readValue.html

Issue 1147243004: bluetooth: readValue Blink implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@bluetooth-read-value-interface
Patch Set: Address jyasskin's comments Created 5 years, 6 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/readValue.html
diff --git a/LayoutTests/bluetooth/readValue.html b/LayoutTests/bluetooth/readValue.html
new file mode 100644
index 0000000000000000000000000000000000000000..0473294a842a1e823dc895541b909e04913cb74d
--- /dev/null
+++ b/LayoutTests/bluetooth/readValue.html
@@ -0,0 +1,69 @@
+<!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.');
+
+// Generic Access Service.
+var serviceUUID = '00001800-0000-1000-8000-00805f9b34fb';
+// Device Name Characteristic. Belongs to Generic Access.
+var includedCharacteristicUUID = '00002a00-0000-1000-8000-00805f9b34fb';
+// Reconnection Address. Belongs to Generic Access.
+var unreadableCharacteristicUUID = '00002a03-0000-1000-8000-00805f9b34fb';
+
+sequential_promise_test(function() {
+ testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
+ return navigator.bluetooth.requestDevice().then(function(device) {
+ return device.connectGATT();
+ }).then(function(gattServer) {
+ return gattServer.getPrimaryService(serviceUUID);
+ }).then(function(service) {
+ return service.getCharacteristic(includedCharacteristicUUID);
+ }).then(function(characteristic) {
+ testRunner.setBluetoothMockDataSet('EmptyAdapter');
+ return characteristic.readValue().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(serviceUUID);
+ }).then(function(service) {
+ return service.getCharacteristic(unreadableCharacteristicUUID);
+ }).then(function(characteristic) {
+ return characteristic.readValue().then(function() {
+ assert_unreached('Characteristic is unreadable. Should fail.');
+ }, function(e) {
+ assert_equals(e.name, 'NetworkError');
Jeffrey Yasskin 2015/06/11 00:31:37 And probably a TODO here saying this should be a N
ortuno 2015/06/11 02:56:33 Done.
+ });
+ });
+}, 'Device goes out of range. Reject with NetworkError.');
+
+// TODO(ortuno): Add a test for when a characterstics gets removed.
+
+sequential_promise_test(function() {
+ testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
+ return navigator.bluetooth.requestDevice().then(function(device) {
+ return device.connectGATT();
+ }).then(function(gattServer) {
+ return gattServer.getPrimaryService(serviceUUID);
+ }).then(function(service) {
+ return service.getCharacteristic(includedCharacteristicUUID);
+ }).then(function(characteristic) {
+ return characteristic.readValue();
+ }).then(function(value) {
+ var decoder = new TextDecoder('utf-8');
+ var value_str = decoder.decode(value);
+ assert_equals(value_str, 'Empty Mock Device name');
+ });
+}, 'Request for characteristic. Should return right characteristic');
+</script>
« no previous file with comments | « no previous file | Source/modules/bluetooth/BluetoothArrayBuffer.h » ('j') | Source/modules/bluetooth/BluetoothArrayBuffer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698