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

Side by Side 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: Removed new line 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="bluetooth-helpers.js"></script>
5 <script>
6 test(function(t) { assert_exists(window, "testRunner"); t.done(); },
7 "window.testRunner is required for the following tests.");
8
9 // Generic Access Service.
10 var service1 = "00001800-0000-1000-8000-00805f9b34fb";
11 // Device Name Characteristic. Belongs to Generic Access.
12 var characteristic1 = "00002a00-0000-1000-8000-00805f9b34fb";
scheib 2015/06/04 18:30:52 Name these more meaninfully than '1' '2'. How abou
ortuno 2015/06/05 20:58:00 Done.
13 // Battery Level. Belongs to Battery Service.
14 var characteristic2 = "00002a19-0000-1000-8000-00805f9b34fb";
15
16 sequential_promise_test(function() {
17 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
18 return navigator.bluetooth.requestDevice().then(function(device) {
19 return device.connectGATT();
20 }).then(function(gattServer) {
21 return gattServer.getPrimaryService(service1);
22 }).then(function(service) {
23 testRunner.setBluetoothMockDataSet('EmptyAdapter');
24 return service.getCharacteristic(characteristic1).then(function() {
25 assert_unreached("Device went out of range, should fail.");
26 }, function(e) {
27 assert_equals(e.name, "NetworkError");
28 });
29 });
30 }, 'Device goes out of range. Reject with NetworkError.');
31
32 sequential_promise_test(function() {
33 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
34 return navigator.bluetooth.requestDevice().then(function(device) {
35 return device.connectGATT();
36 }).then(function(gattServer) {
37 return gattServer.getPrimaryService(service1);
38 }).then(function(service) {
39 return service.getCharacteristic(characteristic2);
40 }).then(function(characteristic) {
41 assert_equals(characteristic, null,
42 "Non existent characteristic should return null.");
43 });
44 }, 'Request for wrong characteristic. Should return null.');
45
46 sequential_promise_test(function() {
47 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
48 return navigator.bluetooth.requestDevice().then(function(device) {
49 return device.connectGATT();
50 }).then(function(gattServer) {
51 return gattServer.getPrimaryService(service1);
52 }).then(function(service) {
53 return service.getCharacteristic(characteristic1);
54 }).then(function(characteristic) {
55 assert_equals(characteristic.uuid, characteristic1,
56 "Characteristic UUID should be the same as requested UUID.");
57 });
58 }, 'Request for characteristic. Should return right characteristic');
59
60 sequential_promise_test(function() {
61 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
62 return navigator.bluetooth.requestDevice().then(function(device) {
63 return device.connectGATT();
64 }).then(function(gattServer) {
65 return gattServer.getPrimaryService(service1);
66 }).then(function(services) {
67 return Promise.all([services.getCharacteristic(characteristic1),
68 services.getCharacteristic(characteristic1)]);
69 }).then(function(characteristics) {
70 // TODO(ortuno): getCharacteristic should return the same object
71 // if it was created earlier.
72 // https://crbug.com/495270
73 assert_not_equals(characteristics[0], characteristics[1],
74 "Should return the same service as the first call.");
75 });
76 }, 'Calls to get the same characteristic should return the same object.');
77
78 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698