Index: chrome/test/data/webui/bluetooth_internals_browsertest.js |
diff --git a/chrome/test/data/webui/bluetooth_internals_browsertest.js b/chrome/test/data/webui/bluetooth_internals_browsertest.js |
index 998eeafafafe3babfe2019339e9215e1cfeee4a9..d68f2e729b15561639dc4e6590631976b308b9d9 100644 |
--- a/chrome/test/data/webui/bluetooth_internals_browsertest.js |
+++ b/chrome/test/data/webui/bluetooth_internals_browsertest.js |
@@ -65,7 +65,7 @@ BluetoothInternalsTest.prototype = { |
]); |
this.binding = new bindings.Binding(adapter.AdapterFactory, this); |
- this.adapter = new TestAdapter(); |
+ this.adapter = new TestAdapterProxy(); |
this.adapterBinding_ = new bindings.Binding(adapter.Adapter, |
this.adapter); |
}; |
@@ -83,22 +83,6 @@ BluetoothInternalsTest.prototype = { |
}; |
/** |
- * A test adapter for the chrome://bluetooth-internals page. |
- * Must be used to create message pipe handle from test code. |
- * |
- * @constructor |
- */ |
- var TestAdapter = function() { |
- this.proxy = new TestAdapterProxy(); |
- }; |
- |
- TestAdapter.prototype = { |
- getInfo: function() { return this.proxy.getInfo(); }, |
- getDevices: function() { return this.proxy.getDevices(); }, |
- setClient: function(client) { return this.proxy.setClient(client); } |
- }; |
- |
- /** |
* A test adapter proxy for the chrome://bluetooth-internals page. |
* |
* @constructor |
@@ -146,11 +130,11 @@ BluetoothInternalsTest.prototype = { |
this.adapterFactory = new TestAdapterFactoryProxy(); |
this.adapterFactory.binding.bind(handle); |
- this.adapterFactory.adapter.proxy.setTestDevices([ |
+ this.adapterFactory.adapter.setTestDevices([ |
this.fakeDeviceInfo1(), |
this.fakeDeviceInfo2(), |
]); |
- this.adapterFactory.adapter.proxy.setTestAdapter( |
+ this.adapterFactory.adapter.setTestAdapter( |
this.fakeAdapterInfo()); |
this.setupResolver.resolve(); |
@@ -219,10 +203,14 @@ BluetoothInternalsTest.prototype = { |
}; |
TEST_F('BluetoothInternalsTest', 'Startup_BluetoothInternals', function() { |
+ /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
+ |
var adapterFactory = null; |
+ var adapterFieldSet = null; |
var deviceTable = null; |
var sidebarNode = null; |
+ var fakeAdapterInfo = this.fakeAdapterInfo; |
var fakeDeviceInfo1 = this.fakeDeviceInfo1; |
var fakeDeviceInfo2 = this.fakeDeviceInfo2; |
var fakeDeviceInfo3 = this.fakeDeviceInfo3; |
@@ -239,14 +227,15 @@ TEST_F('BluetoothInternalsTest', 'Startup_BluetoothInternals', function() { |
return setupPromise.then(function() { |
return Promise.all([ |
adapterFactory.whenCalled('getAdapter'), |
- adapterFactory.adapter.proxy.whenCalled('getInfo'), |
- adapterFactory.adapter.proxy.whenCalled('getDevices'), |
- adapterFactory.adapter.proxy.whenCalled('setClient'), |
+ adapterFactory.adapter.whenCalled('getInfo'), |
+ adapterFactory.adapter.whenCalled('getDevices'), |
+ adapterFactory.adapter.whenCalled('setClient'), |
]); |
}); |
}); |
setup(function() { |
+ adapterFieldSet = document.querySelector('#adapter fieldset'); |
deviceTable = document.querySelector('#devices table'); |
sidebarNode = document.querySelector('#sidebar'); |
devices.splice(0, devices.length); |
@@ -258,6 +247,7 @@ TEST_F('BluetoothInternalsTest', 'Startup_BluetoothInternals', function() { |
adapterFactory.reset(); |
sidebarObj.close(); |
snackbar.Snackbar.dismiss(true); |
+ PageManager.registeredPages['adapter'].setAdapterInfo(fakeAdapterInfo()); |
}); |
/** |
@@ -427,7 +417,7 @@ TEST_F('BluetoothInternalsTest', 'Startup_BluetoothInternals', function() { |
var sidebarItems = Array.from( |
sidebarNode.querySelectorAll('.sidebar-content li')); |
- ['devices'].forEach(function(pageName) { |
+ ['adapter', 'devices'].forEach(function(pageName) { |
expectTrue(sidebarItems.some(function(item) { |
return item.dataset.pageName === pageName; |
})); |
@@ -561,8 +551,56 @@ TEST_F('BluetoothInternalsTest', 'Startup_BluetoothInternals', function() { |
expectFalse(!!snackbar.Snackbar.current_); |
}).then(finishSnackbarTest); |
}); |
- }); |
+ /* AdapterPage Tests */ |
+ function checkAdapterFieldSet(adapterInfo) { |
+ for (var propName in adapterInfo) { |
+ var valueCell = adapterFieldSet.querySelector( |
+ '[data-field="' + propName + '"]'); |
+ var value = adapterInfo[propName]; |
+ |
+ if (typeof(value) === 'boolean') { |
+ expectEquals(value, valueCell.classList.contains('checked')); |
+ } else if (typeof(value) === 'string') { |
+ expectEquals(value, valueCell.textContent); |
+ } else { |
+ assert('boolean or string type expected but got ' + typeof(value)); |
+ } |
+ } |
+ } |
+ |
+ test('AdapterPage_DefaultState', function() { |
+ checkAdapterFieldSet(adapterFieldSet.value); |
+ }); |
+ |
+ test('AdapterPage_AdapterChanged', function() { |
+ var adapterInfo = adapterFieldSet.value; |
+ |
+ adapterInfo.present = !adapterInfo.present; |
+ adapterBroker.adapterClient_.presentChanged(adapterInfo.present); |
+ checkAdapterFieldSet(adapterInfo); |
+ |
+ adapterInfo.discovering = !adapterInfo.discovering; |
+ adapterBroker.adapterClient_.discoveringChanged(adapterInfo.discovering); |
+ checkAdapterFieldSet(adapterInfo); |
+ }); |
+ |
+ test('AdapterPage_AdapterChanged_RepeatTwice', function() { |
+ var adapterInfo = adapterFieldSet.value; |
+ |
+ adapterInfo.present = !adapterInfo.present; |
+ adapterBroker.adapterClient_.presentChanged(adapterInfo.present); |
+ checkAdapterFieldSet(adapterInfo); |
+ adapterBroker.adapterClient_.presentChanged(adapterInfo.present); |
+ checkAdapterFieldSet(adapterInfo); |
+ |
+ adapterInfo.discovering = !adapterInfo.discovering; |
+ adapterBroker.adapterClient_.discoveringChanged(adapterInfo.discovering); |
+ checkAdapterFieldSet(adapterInfo); |
+ adapterBroker.adapterClient_.discoveringChanged(adapterInfo.discovering); |
+ checkAdapterFieldSet(adapterInfo); |
+ }); |
+ }); |
// Run all registered tests. |
mocha.run(); |