| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview Fake implementation of chrome.bluetoothPrivate for testing. | 6 * @fileoverview Fake implementation of chrome.bluetoothPrivate for testing. |
| 7 */ | 7 */ |
| 8 cr.define('settings', function() { | 8 cr.define('settings', function() { |
| 9 /** | 9 /** |
| 10 * Fake of the chrome.bluetooth API. | 10 * Fake of the chrome.bluetooth API. |
| 11 * @param {!Bluetooth} bluetoothApi | 11 * @param {!Bluetooth} bluetoothApi |
| 12 * @constructor | 12 * @constructor |
| 13 * @implements {BluetoothPrivate} | 13 * @implements {BluetoothPrivate} |
| 14 */ | 14 */ |
| 15 function FakeBluetoothPrivate(bluetoothApi) { | 15 function FakeBluetoothPrivate(bluetoothApi) { |
| 16 /** @private {!Bluetooth} */ this.bluetoothApi_ = bluetoothApi; | 16 /** @private {!Bluetooth} */ this.bluetoothApi_ = bluetoothApi; |
| 17 | 17 |
| 18 /** @type {!Set<string>} */ this.connectedDevices_ = new Set(); | 18 /** @type {!Set<string>} */ this.connectedDevices_ = new Set(); |
| 19 | 19 |
| 20 /** @type {!Object<!chrome.bluetoothPrivate.SetPairingResponseOptions>} */ | 20 /** @type {!Object<!chrome.bluetoothPrivate.SetPairingResponseOptions>} */ |
| 21 this.pairingResponses_ = {}; | 21 this.pairingResponses_ = {}; |
| 22 } | 22 } |
| 23 | 23 |
| 24 FakeBluetoothPrivate.prototype = { | 24 FakeBluetoothPrivate.prototype = { |
| 25 /** @override */ | 25 /** @override */ |
| 26 setAdapterState: function(state, opt_callback) { | 26 setAdapterState: function(state, opt_callback) { |
| 27 this.bluetoothApi_.adapterState = state; | 27 this.bluetoothApi_.setAdapterState(state); |
| 28 if (opt_callback) | 28 if (opt_callback) |
| 29 opt_callback(); | 29 opt_callback(); |
| 30 }, | 30 }, |
| 31 | 31 |
| 32 /** @override */ | 32 /** @override */ |
| 33 setPairingResponse: function(options, opt_callback) { | 33 setPairingResponse: function(options, opt_callback) { |
| 34 this.pairingResponses_[options.device.address] = options; | 34 this.pairingResponses_[options.device.address] = options; |
| 35 if (opt_callback) | 35 if (opt_callback) |
| 36 opt_callback(); | 36 opt_callback(); |
| 37 }, | 37 }, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 58 | 58 |
| 59 /** @override */ | 59 /** @override */ |
| 60 pair: assertNotReached, | 60 pair: assertNotReached, |
| 61 | 61 |
| 62 /** @type {!FakeChromeEvent} */ | 62 /** @type {!FakeChromeEvent} */ |
| 63 onPairing: new FakeChromeEvent(), | 63 onPairing: new FakeChromeEvent(), |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 return {FakeBluetoothPrivate: FakeBluetoothPrivate}; | 66 return {FakeBluetoothPrivate: FakeBluetoothPrivate}; |
| 67 }); | 67 }); |
| OLD | NEW |