| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <script src="bluetooth-helpers.js"></script> | 4 <script src="bluetooth-helpers.js"></script> |
| 5 <script> | 5 <script> |
| 6 test(function(t) { assert_exists(window, "testRunner"); t.done(); }, | 6 test(function(t) { assert_exists(window, "testRunner"); t.done(); }, |
| 7 "window.testRunner is required for the following tests."); | 7 "window.testRunner is required for the following tests."); |
| 8 | 8 |
| 9 var generic_access = "00001800-0000-1000-8000-00805f9b34fb"; | 9 var generic_access = "00001800-0000-1000-8000-00805f9b34fb"; |
| 10 var heart_rate = "0000180D-0000-1000-8000-00805f9b34fb"; | 10 var heart_rate = "0000180D-0000-1000-8000-00805f9b34fb"; |
| 11 | 11 |
| 12 sequential_promise_test(function() { | 12 sequential_promise_test(function() { |
| 13 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter'); | 13 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter'); |
| 14 return navigator.bluetooth.requestDevice().then(function(device) { | 14 return navigator.bluetooth.requestDevice().then(function(device) { |
| 15 return device.connectGATT(); | 15 return device.connectGATT(); |
| 16 }).then(function(gattServer) { | 16 }).then(function(gattServer) { |
| 17 testRunner.setBluetoothMockDataSet('EmptyAdapter'); | 17 testRunner.setBluetoothMockDataSet('EmptyAdapter'); |
| 18 return gattServer.getPrimaryService(generic_access).then(function() { | 18 return gattServer.getPrimaryService(generic_access).then(function() { |
| 19 assert_unreached('Should return error if device not in adapter.'); | 19 assert_unreached('Should return error if device not in adapter.'); |
| 20 }, function(e) { | 20 }, function(e) { |
| 21 assert_equals(e.name, "NetworkError"); | 21 assert_equals(e.name, "NetworkError"); |
| 22 assert_equals(e.message, 'Bluetooth Device is no longer in range.'); |
| 22 }); | 23 }); |
| 23 }); | 24 }); |
| 24 }, 'Device goes out of range. Reject with NetworkError.'); | 25 }, 'Device goes out of range. Reject with NetworkError.'); |
| 25 | 26 |
| 26 sequential_promise_test(function() { | 27 sequential_promise_test(function() { |
| 27 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter'); | 28 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter'); |
| 28 return navigator.bluetooth.requestDevice().then(function(device) { | 29 return navigator.bluetooth.requestDevice().then(function(device) { |
| 29 return device.connectGATT(); | 30 return device.connectGATT(); |
| 30 }).then(function(gattServer) { | 31 }).then(function(gattServer) { |
| 31 return gattServer.getPrimaryService(heart_rate); | 32 return gattServer.getPrimaryService(heart_rate); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 59 }).then(function(services) { | 60 }).then(function(services) { |
| 60 // getPrimaryService should return the same object if it was created | 61 // getPrimaryService should return the same object if it was created |
| 61 // earlier. https://crbug.com/495270 | 62 // earlier. https://crbug.com/495270 |
| 62 // TODO(ortuno): Change to assert_equals. | 63 // TODO(ortuno): Change to assert_equals. |
| 63 assert_not_equals(services[0], services[1], | 64 assert_not_equals(services[0], services[1], |
| 64 "Should return the same service as the first call."); | 65 "Should return the same service as the first call."); |
| 65 }); | 66 }); |
| 66 }, 'Calls to get the same service should return the same object.'); | 67 }, 'Calls to get the same service should return the same object.'); |
| 67 | 68 |
| 68 </script> | 69 </script> |
| OLD | NEW |