Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 var generic_access = "00001800-0000-1000-8000-00805f9b34fb"; | |
| 10 var heart_rate = "0000180D-0000-1000-8000-00805f9b34fb"; | |
| 11 | |
| 12 sequential_promise_test(function(t) { | |
| 13 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter'); | |
| 14 return navigator.bluetooth.requestDevice().then(function(device) { | |
| 15 return device.connectGATT().then(function(gattServer) { | |
| 16 testRunner.setBluetoothMockDataSet('EmptyAdapter'); | |
| 17 return gattServer.getPrimaryService(generic_access).then(function() { | |
| 18 assert_unreached('Should return error if device not in adapter.'); | |
| 19 }, function(e) { | |
| 20 assert_equals(e.name, "NetworkError"); | |
| 21 }); | |
| 22 }); | |
| 23 }); | |
| 24 }, 'Device goes out of range. Reject with NetworkError.'); | |
| 25 | |
| 26 sequential_promise_test(function(t) { | |
| 27 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter'); | |
| 28 return navigator.bluetooth.requestDevice().then(function(device) { | |
| 29 return device.connectGATT(); | |
| 30 }).then(function(gattServer) { | |
| 31 return gattServer.getPrimaryService(heart_rate); | |
| 32 }).then(function(service) { | |
| 33 assert_equals(service, null, | |
| 34 "Non existent services should return null."); | |
| 35 }); | |
| 36 }, 'Request for wrong service. Should return null.'); | |
| 37 | |
| 38 sequential_promise_test(function(t) { | |
| 39 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter'); | |
| 40 return navigator.bluetooth.requestDevice().then(function(device) { | |
| 41 return device.connectGATT(); | |
| 42 }).then(function(gattServer) { | |
| 43 return gattServer.getPrimaryService(generic_access); | |
| 44 }).then(function(service) { | |
| 45 assert_equals(service.uuid, generic_access, | |
|
scheib
2015/05/29 00:17:32
test that the device matches as well.
ortuno
2015/06/01 21:21:34
There is no reference to device yet.
scheib
2015/06/03 03:28:24
Add a TODO in the BluetoothGATTService.idl then fo
ortuno
2015/06/03 03:33:12
Done.
| |
| 46 "Service UUID should be the same as requested UUID."); | |
| 47 assert_true(service.isPrimary, | |
| 48 "getPrimaryService should return a primary service."); | |
| 49 }); | |
|
scheib
2015/05/29 00:17:32
An additional call to getPrimaryService must retur
ortuno
2015/06/01 21:21:34
Done.
| |
| 50 }, 'Request for service. Should return right service'); | |
| 51 </script> | |
| OLD | NEW |