Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: chrome/test/data/webui/bluetooth_internals_browsertest.js

Issue 2563113002: bluetooth: Add tests for Sidebar in bluetooth internals browser test suite. (Closed)
Patch Set: Merge upstream Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/bluetooth_internals/bluetooth_internals.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 /** 5 /**
6 * @fileoverview Tests for chrome://bluetooth-internals 6 * @fileoverview Tests for chrome://bluetooth-internals
7 */ 7 */
8 8
9 /** @const {string} Path to source root. */ 9 /** @const {string} Path to source root. */
10 var ROOT_PATH = '../../../../'; 10 var ROOT_PATH = '../../../../';
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 address: "CC:CC:84:96:92:84", 220 address: "CC:CC:84:96:92:84",
221 name: "CCC", 221 name: "CCC",
222 name_for_display: "CCC", 222 name_for_display: "CCC",
223 }; 223 };
224 }, 224 },
225 }; 225 };
226 226
227 TEST_F('BluetoothInternalsTest', 'Startup_BluetoothInternals', function() { 227 TEST_F('BluetoothInternalsTest', 'Startup_BluetoothInternals', function() {
228 var adapterFactory = null; 228 var adapterFactory = null;
229 var deviceTable = null; 229 var deviceTable = null;
230 var sidebarNode = null;
230 231
231 var fakeDeviceInfo1 = this.fakeDeviceInfo1; 232 var fakeDeviceInfo1 = this.fakeDeviceInfo1;
232 var fakeDeviceInfo2 = this.fakeDeviceInfo2; 233 var fakeDeviceInfo2 = this.fakeDeviceInfo2;
233 var fakeDeviceInfo3 = this.fakeDeviceInfo3; 234 var fakeDeviceInfo3 = this.fakeDeviceInfo3;
234 235
235 // Before tests are run, make sure setup completes. 236 // Before tests are run, make sure setup completes.
236 var setupPromise = this.setupResolver.promise.then(function() { 237 var setupPromise = this.setupResolver.promise.then(function() {
237 adapterFactory = this.adapterFactory; 238 adapterFactory = this.adapterFactory;
238 }.bind(this)); 239 }.bind(this));
239 240
240
241 suite('BluetoothInternalsUITest', function() { 241 suite('BluetoothInternalsUITest', function() {
242 var EXPECTED_DEVICES = 2; 242 var EXPECTED_DEVICES = 2;
243 243
244 suiteSetup(function() { 244 suiteSetup(function() {
245 return setupPromise.then(function() { 245 return setupPromise.then(function() {
246 return Promise.all([ 246 return Promise.all([
247 adapterFactory.whenCalled('getAdapter'), 247 adapterFactory.whenCalled('getAdapter'),
248 adapterFactory.adapter.proxy.whenCalled('getInfo'), 248 adapterFactory.adapter.proxy.whenCalled('getInfo'),
249 adapterFactory.adapter.proxy.whenCalled('getDevices'), 249 adapterFactory.adapter.proxy.whenCalled('getDevices'),
250 adapterFactory.adapter.proxy.whenCalled('setClient'), 250 adapterFactory.adapter.proxy.whenCalled('setClient'),
251 ]); 251 ]);
252 }); 252 });
253 }); 253 });
254 254
255 setup(function() { 255 setup(function() {
256 deviceTable = document.querySelector('#devices table'); 256 deviceTable = document.querySelector('#devices table');
257 sidebarNode = document.querySelector('#sidebar');
257 devices.splice(0, devices.length); 258 devices.splice(0, devices.length);
258 adapterBroker.adapterClient_.deviceAdded(fakeDeviceInfo1()); 259 adapterBroker.adapterClient_.deviceAdded(fakeDeviceInfo1());
259 adapterBroker.adapterClient_.deviceAdded(fakeDeviceInfo2()); 260 adapterBroker.adapterClient_.deviceAdded(fakeDeviceInfo2());
260 }); 261 });
261 262
262 teardown(function() { 263 teardown(function() {
263 adapterFactory.reset(); 264 adapterFactory.reset();
ortuno 2016/12/12 23:24:48 I think you also want to reset the state of the si
mbrunson 2016/12/13 01:05:35 Done.
264 }); 265 });
265 266
266 /** 267 /**
267 * Updates device info and verifies the contents of the device table. 268 * Updates device info and verifies the contents of the device table.
268 * @param {!device_collection.DeviceInfo} deviceInfo 269 * @param {!device_collection.DeviceInfo} deviceInfo
269 */ 270 */
270 function changeDevice(deviceInfo) { 271 function changeDevice(deviceInfo) {
271 var deviceRow = deviceTable.querySelector('#' + escapeDeviceAddress( 272 var deviceRow = deviceTable.querySelector('#' + escapeDeviceAddress(
272 deviceInfo.address)); 273 deviceInfo.address));
273 var nameForDisplayColumn = deviceRow.children[0]; 274 var nameForDisplayColumn = deviceRow.children[0];
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 var newDeviceInfo2 = fakeDeviceInfo3(); 418 var newDeviceInfo2 = fakeDeviceInfo3();
418 newDeviceInfo2.rssi = null; 419 newDeviceInfo2.rssi = null;
419 adapterBroker.adapterClient_.deviceChanged(newDeviceInfo2); 420 adapterBroker.adapterClient_.deviceChanged(newDeviceInfo2);
420 expectEquals('-42', rssiColumn.textContent); 421 expectEquals('-42', rssiColumn.textContent);
421 422
422 var newDeviceInfo3 = fakeDeviceInfo3(); 423 var newDeviceInfo3 = fakeDeviceInfo3();
423 newDeviceInfo3.rssi = {value: -17}; 424 newDeviceInfo3.rssi = {value: -17};
424 adapterBroker.adapterClient_.deviceChanged(newDeviceInfo3); 425 adapterBroker.adapterClient_.deviceChanged(newDeviceInfo3);
425 expectEquals('-17', rssiColumn.textContent); 426 expectEquals('-17', rssiColumn.textContent);
426 }); 427 });
428
429 /* Sidebar Tests */
430 test('SidebarSetup', function() {
431 var sidebarItems = Array.from(
432 sidebarNode.querySelectorAll('.sidebar-content li'));
433
434 ['devices'].forEach(function(pageName) {
435 var foundItem = sidebarItems.find(function(item) {
436 return item.dataset.pageName === pageName;
437 });
438
439 expectTrue(!!foundItem);
440 });
441 });
442
443 test('SidebarOpenClose', function() {
ortuno 2016/12/12 23:24:48 Would it make sense to split these? That way inste
mbrunson 2016/12/13 01:05:35 Done.
444 // Sidebar should be closed by default.
445 expectFalse(sidebarNode.classList.contains('open'));
446
447 sidebarObj.open();
448 expectTrue(sidebarNode.classList.contains('open'));
449 sidebarObj.close();
450 expectFalse(sidebarNode.classList.contains('open'));
451
452 // Multiple calls to open shouldn't change the state.
453 sidebarObj.open();
454 sidebarObj.open();
455 expectTrue(sidebarNode.classList.contains('open'));
456
457 // Multiple calls to close shouldn't change the state.
458 sidebarObj.close();
459 sidebarObj.close();
460 expectFalse(sidebarNode.classList.contains('open'));
461 });
427 }); 462 });
428 463
429 // Run all registered tests. 464 // Run all registered tests.
430 mocha.run(); 465 mocha.run();
431 }); 466 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/bluetooth_internals/bluetooth_internals.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698