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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 test('device list', function() { | 123 test('device list', function() { |
124 var bluetoothSection = self.getSection(advanced, 'bluetooth'); | 124 var bluetoothSection = self.getSection(advanced, 'bluetooth'); |
125 var bluetooth = | 125 var bluetooth = |
126 bluetoothSection.querySelector('settings-bluetooth-page'); | 126 bluetoothSection.querySelector('settings-bluetooth-page'); |
127 assertTrue(!!bluetooth); | 127 assertTrue(!!bluetooth); |
128 var deviceList = bluetooth.$.deviceList; | 128 var deviceList = bluetooth.$.deviceList; |
129 assertTrue(!!deviceList); | 129 assertTrue(!!deviceList); |
130 // Set enabled, with default (empty) device list. | 130 // Set enabled, with default (empty) device list. |
131 self.bluetoothApi_.setEnabled(true); | 131 self.bluetoothApi_.setEnabled(true); |
132 Polymer.dom.flush(); | 132 Polymer.dom.flush(); |
133 // Ensure that initially the 'device list empty' span is visible. | 133 // Ensure that initially the 'no devices' element is visible. |
134 expectFalse(deviceList.hidden); | 134 expectFalse(deviceList.hidden); |
135 var noDevices = deviceList.querySelector('span'); | 135 var noDevices = deviceList.querySelector('.no-devices'); |
136 assertTrue(!!noDevices); | 136 assertTrue(!!noDevices); |
137 expectFalse(noDevices.hidden); | 137 expectFalse(noDevices.hidden); |
138 // Set some devices (triggers onDeviceAdded events). 'empty' span should | 138 // Set some devices (triggers onDeviceAdded events). 'no devices' element |
139 // be hidden. | 139 // should be hidden. |
140 self.bluetoothApi_.setDevicesForTest(fakeDevices_); | 140 self.bluetoothApi_.setDevicesForTest(fakeDevices_); |
141 Polymer.dom.flush(); | 141 Polymer.dom.flush(); |
142 expectTrue(noDevices.hidden); | 142 expectTrue(noDevices.hidden); |
143 // Confirm that there are two paired devices in the list. | 143 // Confirm that there are two paired devices in the list. |
144 var devices = deviceList.querySelectorAll('bluetooth-device-list-item'); | 144 var devices = deviceList.querySelectorAll('bluetooth-device-list-item'); |
145 assertEquals(2, devices.length); | 145 assertEquals(2, devices.length); |
146 // Check the state of each device. | 146 // Check the state of each device. |
147 assertTrue(devices[0].device.connected); | 147 assertTrue(devices[0].device.connected); |
148 assertFalse(devices[1].device.connected); | 148 assertFalse(devices[1].device.connected); |
149 assertTrue(devices[1].device.connecting); | 149 assertTrue(devices[1].device.connecting); |
150 }); | 150 }); |
151 | 151 |
152 test('device dialog', function() { | 152 test('device dialog', function() { |
153 var bluetoothSection = self.getSection(advanced, 'bluetooth'); | 153 var bluetoothSection = self.getSection(advanced, 'bluetooth'); |
154 var bluetooth = | 154 var bluetooth = |
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.$.addDevice); | 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.opened); |
166 var addDialog = bluetooth.$$('settings-bluetooth-add-device-dialog'); | 166 var addDialog = bluetooth.$$('settings-bluetooth-add-device-dialog'); |
167 assertTrue(!!addDialog); | 167 assertTrue(!!addDialog); |
168 // Ensure the dialog has the expected devices. | 168 // Ensure the dialog has the expected devices. |
169 var devicesDiv = addDialog.$.dialogDeviceList; | 169 var devicesDiv = addDialog.$.dialogDeviceList; |
170 var devices = devicesDiv.querySelectorAll('bluetooth-device-list-item'); | 170 var devices = devicesDiv.querySelectorAll('bluetooth-device-list-item'); |
(...skipping 17 matching lines...) Expand all Loading... |
188 var response = self.bluetoothPrivateApi_.pairingResponses_[deviceAddress]; | 188 var response = self.bluetoothPrivateApi_.pairingResponses_[deviceAddress]; |
189 assertTrue(!!response); | 189 assertTrue(!!response); |
190 expectEquals(chrome.bluetoothPrivate.PairingResponse.CANCEL, | 190 expectEquals(chrome.bluetoothPrivate.PairingResponse.CANCEL, |
191 response.response); | 191 response.response); |
192 }); | 192 }); |
193 }); | 193 }); |
194 | 194 |
195 // Run all registered tests. | 195 // Run all registered tests. |
196 mocha.run(); | 196 mocha.run(); |
197 }); | 197 }); |
OLD | NEW |