| 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 /** @fileoverview Suite of tests for settings-bluetooth-page. */ | 5 /** @fileoverview Suite of tests for settings-bluetooth-page. */ |
| 6 | 6 |
| 7 GEN_INCLUDE(['settings_page_browsertest.js']); | 7 GEN_INCLUDE(['settings_page_browsertest.js']); |
| 8 | 8 |
| 9 var bluetoothPage = bluetoothPage || {}; | 9 var bluetoothPage = bluetoothPage || {}; |
| 10 | 10 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 bluetoothSection.querySelector('settings-bluetooth-page'); | 155 bluetoothSection.querySelector('settings-bluetooth-page'); |
| 156 assertTrue(!!bluetooth); | 156 assertTrue(!!bluetooth); |
| 157 self.bluetoothApi_.setEnabled(true); | 157 self.bluetoothApi_.setEnabled(true); |
| 158 | 158 |
| 159 // Tap the 'add device' button. | 159 // Tap the 'add device' button. |
| 160 MockInteractions.tap(bluetooth.$$('.primary-button')); | 160 MockInteractions.tap(bluetooth.$$('.primary-button')); |
| 161 Polymer.dom.flush(); | 161 Polymer.dom.flush(); |
| 162 // Ensure the dialog appears. | 162 // Ensure the dialog appears. |
| 163 var dialog = bluetooth.$.deviceDialog; | 163 var dialog = bluetooth.$.deviceDialog; |
| 164 assertTrue(!!dialog); | 164 assertTrue(!!dialog); |
| 165 assertTrue(dialog.opened); | 165 assertTrue(dialog.$.dialog.opened); |
| 166 var addDialog = bluetooth.$$('settings-bluetooth-add-device-dialog'); | 166 |
| 167 assertTrue(!!addDialog); | |
| 168 // Ensure the dialog has the expected devices. | 167 // Ensure the dialog has the expected devices. |
| 169 var devicesDiv = addDialog.$.dialogDeviceList; | 168 var devicesDiv = dialog.$$('#dialogDeviceList'); |
| 169 assertTrue(!!devicesDiv); |
| 170 var devices = devicesDiv.querySelectorAll('bluetooth-device-list-item'); | 170 var devices = devicesDiv.querySelectorAll('bluetooth-device-list-item'); |
| 171 assertEquals(2, devices.length); | 171 assertEquals(2, devices.length); |
| 172 | 172 |
| 173 // Select a device. | 173 // Select a device. |
| 174 MockInteractions.tap(devices[0].$$('div')); | 174 MockInteractions.tap(devices[0].$$('div')); |
| 175 Polymer.dom.flush(); | 175 Polymer.dom.flush(); |
| 176 // Ensure the pairing dialog is shown. | 176 // Ensure the pairing dialog is shown. |
| 177 var pairDialog = bluetooth.$$('settings-bluetooth-pair-device-dialog'); | 177 assertTrue(!!dialog.$$('#pairing')); |
| 178 assertTrue(!!pairDialog); | |
| 179 // Ensure the device is connected to. | 178 // Ensure the device is connected to. |
| 180 expectEquals(1, self.bluetoothPrivateApi_.connectedDevices_.size); | 179 expectEquals(1, self.bluetoothPrivateApi_.connectedDevices_.size); |
| 181 var deviceAddress = | 180 var deviceAddress = |
| 182 self.bluetoothPrivateApi_.connectedDevices_.keys().next().value; | 181 self.bluetoothPrivateApi_.connectedDevices_.keys().next().value; |
| 183 | 182 |
| 184 // Close the dialog. | 183 // Close the dialog. |
| 185 MockInteractions.tap(pairDialog.$.close); | 184 var close = dialog.$$('#closePair'); |
| 185 assertTrue(!!close); |
| 186 MockInteractions.tap(close); |
| 186 Polymer.dom.flush(); | 187 Polymer.dom.flush(); |
| 187 expectFalse(dialog.opened); | 188 expectFalse(dialog.$.dialog.opened); |
| 188 var response = self.bluetoothPrivateApi_.pairingResponses_[deviceAddress]; | 189 var response = self.bluetoothPrivateApi_.pairingResponses_[deviceAddress]; |
| 189 assertTrue(!!response); | 190 assertTrue(!!response); |
| 190 expectEquals(chrome.bluetoothPrivate.PairingResponse.CANCEL, | 191 expectEquals(chrome.bluetoothPrivate.PairingResponse.CANCEL, |
| 191 response.response); | 192 response.response); |
| 192 }); | 193 }); |
| 193 }); | 194 }); |
| 194 | 195 |
| 195 // Run all registered tests. | 196 // Run all registered tests. |
| 196 mocha.run(); | 197 mocha.run(); |
| 197 }); | 198 }); |
| OLD | NEW |