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.$.dialog.opened); | 165 assertTrue(dialog.$.dialog.open); |
166 | 166 |
167 // Ensure the dialog has the expected devices. | 167 // Ensure the dialog has the expected devices. |
168 var devicesDiv = dialog.$$('#dialogDeviceList'); | 168 var devicesDiv = dialog.$$('#dialogDeviceList'); |
169 assertTrue(!!devicesDiv); | 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 assertTrue(!!dialog.$$('#pairing')); | 177 assertTrue(!!dialog.$$('#pairing')); |
178 // Ensure the device is connected to. | 178 // Ensure the device is connected to. |
179 expectEquals(1, self.bluetoothPrivateApi_.connectedDevices_.size); | 179 expectEquals(1, self.bluetoothPrivateApi_.connectedDevices_.size); |
180 var deviceAddress = | 180 var deviceAddress = |
181 self.bluetoothPrivateApi_.connectedDevices_.keys().next().value; | 181 self.bluetoothPrivateApi_.connectedDevices_.keys().next().value; |
182 | 182 |
183 // Close the dialog. | 183 // Close the dialog. |
184 var close = dialog.$.dialog.getCloseButton(); | 184 var close = dialog.$.dialog.getCloseButton(); |
185 assertTrue(!!close); | 185 assertTrue(!!close); |
186 MockInteractions.tap(close); | 186 MockInteractions.tap(close); |
187 Polymer.dom.flush(); | 187 Polymer.dom.flush(); |
188 expectFalse(dialog.$.dialog.opened); | 188 expectFalse(dialog.$.dialog.open); |
189 var response = self.bluetoothPrivateApi_.pairingResponses_[deviceAddress]; | 189 var response = self.bluetoothPrivateApi_.pairingResponses_[deviceAddress]; |
190 assertTrue(!!response); | 190 assertTrue(!!response); |
191 expectEquals(chrome.bluetoothPrivate.PairingResponse.CANCEL, | 191 expectEquals(chrome.bluetoothPrivate.PairingResponse.CANCEL, |
192 response.response); | 192 response.response); |
193 }); | 193 }); |
194 }); | 194 }); |
195 | 195 |
196 // Run all registered tests. | 196 // Run all registered tests. |
197 mocha.run(); | 197 mocha.run(); |
198 }); | 198 }); |
OLD | NEW |