| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 Tests for chrome://bluetooth-internals | 6 * @fileoverview Tests for chrome://bluetooth-internals |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 /** @const {string} Path to source root. */ | 9 /** @const {string} Path to source root. */ |
| 10 var ROOT_PATH = '../../../../'; | 10 var ROOT_PATH = '../../../../'; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 * | 58 * |
| 59 * @constructor | 59 * @constructor |
| 60 * @extends {TestBrowserProxyBase} | 60 * @extends {TestBrowserProxyBase} |
| 61 */ | 61 */ |
| 62 var TestAdapterFactoryProxy = function() { | 62 var TestAdapterFactoryProxy = function() { |
| 63 settings.TestBrowserProxy.call(this, [ | 63 settings.TestBrowserProxy.call(this, [ |
| 64 'getAdapter', | 64 'getAdapter', |
| 65 ]); | 65 ]); |
| 66 | 66 |
| 67 this.binding = new bindings.Binding(adapter.AdapterFactory, this); | 67 this.binding = new bindings.Binding(adapter.AdapterFactory, this); |
| 68 this.adapter = new TestAdapter(); | 68 this.adapter = new TestAdapterProxy(); |
| 69 this.adapterBinding_ = new bindings.Binding(adapter.Adapter, | 69 this.adapterBinding_ = new bindings.Binding(adapter.Adapter, |
| 70 this.adapter); | 70 this.adapter); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 TestAdapterFactoryProxy.prototype = { | 73 TestAdapterFactoryProxy.prototype = { |
| 74 __proto__: settings.TestBrowserProxy.prototype, | 74 __proto__: settings.TestBrowserProxy.prototype, |
| 75 getAdapter: function() { | 75 getAdapter: function() { |
| 76 this.methodCalled('getAdapter'); | 76 this.methodCalled('getAdapter'); |
| 77 | 77 |
| 78 // Create message pipe bound to TestAdapter. | 78 // Create message pipe bound to TestAdapter. |
| 79 return Promise.resolve({ | 79 return Promise.resolve({ |
| 80 adapter: this.adapterBinding_.createInterfacePtrAndBind(), | 80 adapter: this.adapterBinding_.createInterfacePtrAndBind(), |
| 81 }); | 81 }); |
| 82 } | 82 } |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 /** | 85 /** |
| 86 * A test adapter for the chrome://bluetooth-internals page. | |
| 87 * Must be used to create message pipe handle from test code. | |
| 88 * | |
| 89 * @constructor | |
| 90 */ | |
| 91 var TestAdapter = function() { | |
| 92 this.proxy = new TestAdapterProxy(); | |
| 93 }; | |
| 94 | |
| 95 TestAdapter.prototype = { | |
| 96 getInfo: function() { return this.proxy.getInfo(); }, | |
| 97 getDevices: function() { return this.proxy.getDevices(); }, | |
| 98 setClient: function(client) { return this.proxy.setClient(client); } | |
| 99 }; | |
| 100 | |
| 101 /** | |
| 102 * A test adapter proxy for the chrome://bluetooth-internals page. | 86 * A test adapter proxy for the chrome://bluetooth-internals page. |
| 103 * | 87 * |
| 104 * @constructor | 88 * @constructor |
| 105 * @extends {TestBrowserProxyBase} | 89 * @extends {TestBrowserProxyBase} |
| 106 */ | 90 */ |
| 107 var TestAdapterProxy = function() { | 91 var TestAdapterProxy = function() { |
| 108 settings.TestBrowserProxy.call(this, [ | 92 settings.TestBrowserProxy.call(this, [ |
| 109 'getInfo', | 93 'getInfo', |
| 110 'getDevices', | 94 'getDevices', |
| 111 'setClient', | 95 'setClient', |
| (...skipping 27 matching lines...) Expand all Loading... |
| 139 setTestDevices: function(devices) { | 123 setTestDevices: function(devices) { |
| 140 this.devices_ = devices; | 124 this.devices_ = devices; |
| 141 } | 125 } |
| 142 }; | 126 }; |
| 143 | 127 |
| 144 frameInterfaces.addInterfaceOverrideForTesting( | 128 frameInterfaces.addInterfaceOverrideForTesting( |
| 145 adapter.AdapterFactory.name, function(handle) { | 129 adapter.AdapterFactory.name, function(handle) { |
| 146 this.adapterFactory = new TestAdapterFactoryProxy(); | 130 this.adapterFactory = new TestAdapterFactoryProxy(); |
| 147 this.adapterFactory.binding.bind(handle); | 131 this.adapterFactory.binding.bind(handle); |
| 148 | 132 |
| 149 this.adapterFactory.adapter.proxy.setTestDevices([ | 133 this.adapterFactory.adapter.setTestDevices([ |
| 150 this.fakeDeviceInfo1(), | 134 this.fakeDeviceInfo1(), |
| 151 this.fakeDeviceInfo2(), | 135 this.fakeDeviceInfo2(), |
| 152 ]); | 136 ]); |
| 153 this.adapterFactory.adapter.proxy.setTestAdapter( | 137 this.adapterFactory.adapter.setTestAdapter( |
| 154 this.fakeAdapterInfo()); | 138 this.fakeAdapterInfo()); |
| 155 | 139 |
| 156 this.setupResolver.resolve(); | 140 this.setupResolver.resolve(); |
| 157 }.bind(this)); | 141 }.bind(this)); |
| 158 | 142 |
| 159 }.bind(this)); | 143 }.bind(this)); |
| 160 }.bind(this); | 144 }.bind(this); |
| 161 }, | 145 }, |
| 162 | 146 |
| 163 /** | 147 /** |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 adapterFactory = this.adapterFactory; | 216 adapterFactory = this.adapterFactory; |
| 233 }.bind(this)); | 217 }.bind(this)); |
| 234 | 218 |
| 235 suite('BluetoothInternalsUITest', function() { | 219 suite('BluetoothInternalsUITest', function() { |
| 236 var EXPECTED_DEVICES = 2; | 220 var EXPECTED_DEVICES = 2; |
| 237 | 221 |
| 238 suiteSetup(function() { | 222 suiteSetup(function() { |
| 239 return setupPromise.then(function() { | 223 return setupPromise.then(function() { |
| 240 return Promise.all([ | 224 return Promise.all([ |
| 241 adapterFactory.whenCalled('getAdapter'), | 225 adapterFactory.whenCalled('getAdapter'), |
| 242 adapterFactory.adapter.proxy.whenCalled('getInfo'), | 226 adapterFactory.adapter.whenCalled('getInfo'), |
| 243 adapterFactory.adapter.proxy.whenCalled('getDevices'), | 227 adapterFactory.adapter.whenCalled('getDevices'), |
| 244 adapterFactory.adapter.proxy.whenCalled('setClient'), | 228 adapterFactory.adapter.whenCalled('setClient'), |
| 245 ]); | 229 ]); |
| 246 }); | 230 }); |
| 247 }); | 231 }); |
| 248 | 232 |
| 249 setup(function() { | 233 setup(function() { |
| 250 deviceTable = document.querySelector('#devices table'); | 234 deviceTable = document.querySelector('#devices table'); |
| 251 sidebarNode = document.querySelector('#sidebar'); | 235 sidebarNode = document.querySelector('#sidebar'); |
| 252 devices.splice(0, devices.length); | 236 devices.splice(0, devices.length); |
| 253 adapterBroker.adapterClient_.deviceAdded(fakeDeviceInfo1()); | 237 adapterBroker.adapterClient_.deviceAdded(fakeDeviceInfo1()); |
| 254 adapterBroker.adapterClient_.deviceAdded(fakeDeviceInfo2()); | 238 adapterBroker.adapterClient_.deviceAdded(fakeDeviceInfo2()); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 expectEquals(0, snackbar.Snackbar.queue_.length); | 544 expectEquals(0, snackbar.Snackbar.queue_.length); |
| 561 expectFalse(!!snackbar.Snackbar.current_); | 545 expectFalse(!!snackbar.Snackbar.current_); |
| 562 }).then(finishSnackbarTest); | 546 }).then(finishSnackbarTest); |
| 563 }); | 547 }); |
| 564 }); | 548 }); |
| 565 | 549 |
| 566 | 550 |
| 567 // Run all registered tests. | 551 // Run all registered tests. |
| 568 mocha.run(); | 552 mocha.run(); |
| 569 }); | 553 }); |
| OLD | NEW |