| 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="resources/bluetooth-helpers.js"></script> | 4 <script src="resources/bluetooth-helpers.js"></script> | 
| 5 <script> | 5 <script> | 
| 6 'use strict'; | 6 'use strict'; | 
| 7 | 7 | 
| 8 test(t => { assert_true(window.testRunner instanceof Object); t.done(); }, | 8 test(t => { assert_true(window.testRunner instanceof Object); t.done(); }, | 
| 9      'window.testRunner is required for the following tests.'); | 9      'window.testRunner is required for the following tests.'); | 
| 10 | 10 | 
| 11 // TODO(ortuno): Write tests to check that "Disconnect" was actually | 11 // TODO(ortuno): Write tests to check that "Disconnect" was actually | 
| 12 // called on the device. | 12 // called on the device. | 
| 13 // http://crbug.com/569716 | 13 // http://crbug.com/569716 | 
| 14 promise_test(() => { | 14 promise_test(() => { | 
| 15   testRunner.setBluetoothMockDataSet('HeartRateAdapter'); | 15   return setBluetoothFakeAdapter('HeartRateAdapter') | 
| 16   return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) | 16     .then(() => requestDeviceWithKeyDown({ | 
|  | 17       filters: [{services: ['heart_rate']}]})) | 
| 17     .then(device => device.gatt.connect()) | 18     .then(device => device.gatt.connect()) | 
| 18     .then(gattServer => { | 19     .then(gattServer => { | 
| 19       gattServer.disconnect(); | 20       gattServer.disconnect(); | 
| 20       assert_false(gattServer.connected); | 21       assert_false(gattServer.connected); | 
| 21     }); | 22     }); | 
| 22 }, '\'connected\' is set to false after disconnect is called.'); | 23 }, '\'connected\' is set to false after disconnect is called.'); | 
| 23 | 24 | 
| 24 promise_test(() => { | 25 promise_test(() => { | 
| 25   testRunner.setBluetoothMockDataSet('HeartRateAdapter'); | 26   return setBluetoothFakeAdapter('HeartRateAdapter') | 
| 26   return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) | 27     .then(() => requestDeviceWithKeyDown({ | 
|  | 28       filters: [{services: ['heart_rate']}]})) | 
| 27     .then(device => device.gatt.connect()) | 29     .then(device => device.gatt.connect()) | 
| 28     .then(gattServer => { | 30     .then(gattServer => { | 
| 29       gattServer.disconnect(); | 31       gattServer.disconnect(); | 
| 30       assert_false(gattServer.connected); | 32       assert_false(gattServer.connected); | 
| 31       gattServer.disconnect(); | 33       gattServer.disconnect(); | 
| 32       assert_false(gattServer.connected); | 34       assert_false(gattServer.connected); | 
| 33     }); | 35     }); | 
| 34 }, 'Calling disconnect twice in a row still results in \'connected\' ' + | 36 }, 'Calling disconnect twice in a row still results in \'connected\' ' + | 
| 35    'being false.'); | 37    'being false.'); | 
| 36 | 38 | 
| 37 promise_test(() => { | 39 promise_test(() => { | 
| 38   testRunner.setBluetoothMockDataSet('HeartRateAdapter'); | 40   return setBluetoothFakeAdapter('HeartRateAdapter') | 
| 39   return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) | 41     .then(() => requestDeviceWithKeyDown({ | 
|  | 42       filters: [{services: ['heart_rate']}]})) | 
| 40     .then(device => { | 43     .then(device => { | 
| 41       return device.gatt.connect().then(gattServer => { | 44       return device.gatt.connect().then(gattServer => { | 
| 42         gattServer.disconnect(); | 45         gattServer.disconnect(); | 
| 43         assert_false(gattServer.connected); | 46         assert_false(gattServer.connected); | 
| 44       }) | 47       }) | 
| 45       .then(() => device.gatt.connect()).then(gattServer => { | 48       .then(() => device.gatt.connect()).then(gattServer => { | 
| 46         gattServer.disconnect(); | 49         gattServer.disconnect(); | 
| 47         assert_false(gattServer.connected); | 50         assert_false(gattServer.connected); | 
| 48       }); | 51       }); | 
| 49     }); | 52     }); | 
| 50 }, 'Connect + Disconnect twice still results in \'connected\' being false.'); | 53 }, 'Connect + Disconnect twice still results in \'connected\' being false.'); | 
| 51 </script> | 54 </script> | 
| OLD | NEW | 
|---|