| Index: chrome/test/data/webui/settings/bluetooth_page_tests.js
|
| diff --git a/chrome/test/data/webui/settings/bluetooth_page_tests.js b/chrome/test/data/webui/settings/bluetooth_page_tests.js
|
| index 6e1ccfc4d059e563b497346c9c2bb04e22ef18f2..518c7669f2a41e0f1a5775fd3de4549e2aea5e8d 100644
|
| --- a/chrome/test/data/webui/settings/bluetooth_page_tests.js
|
| +++ b/chrome/test/data/webui/settings/bluetooth_page_tests.js
|
| @@ -23,16 +23,15 @@ suite('Bluetooth', function() {
|
| name: 'FakePairedDevice2',
|
| paired: true,
|
| connected: false,
|
| - connecting: true,
|
| },
|
| {
|
| address: '00:00:00:00:00:01',
|
| - name: 'FakeUnPairedDevice1',
|
| + name: 'FakeUnpairedDevice1',
|
| paired: false,
|
| },
|
| {
|
| address: '00:00:00:00:00:02',
|
| - name: 'FakeUnPairedDevice2',
|
| + name: 'FakeUnpairedDevice2',
|
| paired: false,
|
| },
|
| ];
|
| @@ -65,6 +64,7 @@ suite('Bluetooth', function() {
|
| bluetoothPage = document.createElement('settings-bluetooth-page');
|
| assertTrue(!!bluetoothPage);
|
|
|
| + bluetoothApi_.setDevicesForTest([]);
|
| document.body.appendChild(bluetoothPage);
|
| Polymer.dom.flush();
|
| });
|
| @@ -108,61 +108,77 @@ suite('Bluetooth', function() {
|
| assertFalse(bluetoothPage.bluetoothEnabled_);
|
| });
|
|
|
| - test('device list', function() {
|
| - var deviceList = subpage.$.container;
|
| - assertTrue(!!deviceList);
|
| - assertTrue(deviceList.hidden);
|
| - assertFalse(subpage.$.noDevices.hidden);
|
| + test('paired device list', function() {
|
| + var pairedContainer = subpage.$.pairedContainer;
|
| + assertTrue(!!pairedContainer);
|
| + assertTrue(pairedContainer.hidden);
|
| + assertFalse(subpage.$.noPairedDevices.hidden);
|
|
|
| bluetoothApi_.setDevicesForTest(fakeDevices_);
|
| Polymer.dom.flush();
|
| assertEquals(4, subpage.deviceList_.length);
|
| - assertTrue(subpage.$.noDevices.hidden);
|
| + assertEquals(2, subpage.pairedDeviceList_.length);
|
| + assertTrue(subpage.$.noPairedDevices.hidden);
|
|
|
| - var devicesIronList = subpage.$$('#container > iron-list');
|
| - assertTrue(!!devicesIronList);
|
| - devicesIronList.notifyResize();
|
| + var ironList = subpage.$.pairedDevices;
|
| + assertTrue(!!ironList);
|
| + ironList.notifyResize();
|
| Polymer.dom.flush();
|
| - var devices = deviceList.querySelectorAll('bluetooth-device-list-item');
|
| + var devices = ironList.querySelectorAll('bluetooth-device-list-item');
|
| assertEquals(2, devices.length);
|
| assertTrue(devices[0].device.connected);
|
| assertFalse(devices[1].device.connected);
|
| - assertTrue(devices[1].device.connecting);
|
| });
|
|
|
| - test('device dialog', function() {
|
| - // Tap the 'add device' button.
|
| - MockInteractions.tap(subpage.$.pairButton);
|
| - Polymer.dom.flush();
|
| -
|
| - // Ensure the dialog appears.
|
| - var dialog = subpage.$.deviceDialog;
|
| - assertTrue(!!dialog);
|
| - assertTrue(dialog.$.dialog.open);
|
| - assertEquals(dialog.deviceList.length, 4);
|
| + test('unpaired device list', function() {
|
| + var unpairedContainer = subpage.$.unpairedContainer;
|
| + assertTrue(!!unpairedContainer);
|
| + assertTrue(unpairedContainer.hidden);
|
| + assertFalse(subpage.$.noUnpairedDevices.hidden);
|
|
|
| - // Ensure the dialog has the expected devices.
|
| - var devicesIronList = dialog.$$('#dialogDeviceList iron-list');
|
| - assertTrue(!!devicesIronList);
|
| - devicesIronList.notifyResize();
|
| + bluetoothApi_.setDevicesForTest(fakeDevices_);
|
| Polymer.dom.flush();
|
| - var devices =
|
| - devicesIronList.querySelectorAll('bluetooth-device-list-item');
|
| - assertEquals(devices.length, 2);
|
| + assertEquals(4, subpage.deviceList_.length);
|
| + assertEquals(2, subpage.unpairedDeviceList_.length);
|
| + assertTrue(subpage.$.noUnpairedDevices.hidden);
|
|
|
| - // Select a device.
|
| - MockInteractions.tap(devices[0].$$('div'));
|
| + var ironList = subpage.$.unpairedDevices;
|
| + assertTrue(!!ironList);
|
| + ironList.notifyResize();
|
| Polymer.dom.flush();
|
| - // Ensure the pairing dialog is shown.
|
| - assertTrue(!!dialog.$$('#pairing'));
|
| + var devices = ironList.querySelectorAll('bluetooth-device-list-item');
|
| + assertEquals(2, devices.length);
|
| + assertFalse(devices[0].device.paired);
|
| + assertFalse(devices[1].device.paired);
|
| + });
|
|
|
| - // Ensure the device wass connected to.
|
| - expectEquals(1, bluetoothPrivateApi_.connectedDevices_.size);
|
| + test('pair device', function(done) {
|
| + bluetoothApi_.setDevicesForTest(fakeDevices_);
|
| + Polymer.dom.flush();
|
| + assertEquals(4, subpage.deviceList_.length);
|
| + assertEquals(2, subpage.pairedDeviceList_.length);
|
| + assertEquals(2, subpage.unpairedDeviceList_.length);
|
| +
|
| + var address = subpage.unpairedDeviceList_[0].address;
|
| + bluetoothPrivateApi_.connect(address, function() {
|
| + Polymer.dom.flush();
|
| + assertEquals(3, subpage.pairedDeviceList_.length);
|
| + assertEquals(1, subpage.unpairedDeviceList_.length);
|
| + done();
|
| + });
|
| + });
|
|
|
| - // Close the dialog.
|
| - dialog.close();
|
| + test('pair dialog', function() {
|
| + bluetoothApi_.setDevicesForTest(fakeDevices_);
|
| Polymer.dom.flush();
|
| + var dialog = subpage.$.deviceDialog;
|
| + assertTrue(!!dialog);
|
| assertFalse(dialog.$.dialog.open);
|
| +
|
| + // Simulate selecting an unpaired device; should show the pair dialog.
|
| + subpage.connectDevice_(subpage.unpairedDeviceList_[0]);
|
| + Polymer.dom.flush();
|
| + assertTrue(dialog.$.dialog.open);
|
| });
|
| });
|
| });
|
|
|