Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 * Test fixture for sync internals WebUI testing. | 6 * Test fixture for sync internals WebUI testing. |
| 7 * @constructor | 7 * @constructor |
| 8 * @extends {testing.Test} | 8 * @extends {testing.Test} |
| 9 */ | 9 */ |
| 10 function SyncInternalsWebUITest() {} | 10 function SyncInternalsWebUITest() {} |
| 11 | 11 |
| 12 SyncInternalsWebUITest.prototype = { | 12 SyncInternalsWebUITest.prototype = { |
| 13 __proto__: testing.Test.prototype, | 13 __proto__: testing.Test.prototype, |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Browse to the sync internals page. | 16 * Browse to the sync internals page. |
| 17 * @override | 17 * @override |
| 18 */ | 18 */ |
| 19 browsePreload: 'chrome://sync-internals', | 19 browsePreload: 'chrome://sync-internals', |
| 20 | 20 |
| 21 /** | |
| 22 * Disable accessibility testing for this page. | |
| 23 * @override | |
| 24 */ | |
| 25 runAccessibilityChecks: false, | |
| 26 | |
| 21 /** @override */ | 27 /** @override */ |
| 22 preLoad: function() { | 28 preLoad: function() { |
| 23 this.makeAndRegisterMockHandler([ | 29 this.makeAndRegisterMockHandler([ |
| 24 'getAllNodes', | 30 'getAllNodes', |
| 25 ]); | 31 ]); |
| 26 }, | 32 }, |
| 27 | 33 |
| 28 /** | 34 /** |
| 29 * Checks aboutInfo's details section for the specified field. | 35 * Checks aboutInfo's details section for the specified field. |
| 30 * @param {boolean} isValid Whether the field is valid. | 36 * @param {boolean} isValid Whether the field is valid. |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 // Selecting the tab will refresh it. | 240 // Selecting the tab will refresh it. |
| 235 $('sync-browser-tab').selected = true; | 241 $('sync-browser-tab').selected = true; |
| 236 expectNotEquals($('node-browser-refresh-time').textContent, 'Never'); | 242 expectNotEquals($('node-browser-refresh-time').textContent, 'Never'); |
| 237 | 243 |
| 238 // Re-selecting the tab shouldn't re-refresh. | 244 // Re-selecting the tab shouldn't re-refresh. |
| 239 $('node-browser-refresh-time').textContent = 'TestCanary'; | 245 $('node-browser-refresh-time').textContent = 'TestCanary'; |
| 240 $('sync-browser-tab').selected = false; | 246 $('sync-browser-tab').selected = false; |
| 241 $('sync-browser-tab').selected = true; | 247 $('sync-browser-tab').selected = true; |
| 242 expectEquals($('node-browser-refresh-time').textContent, 'TestCanary'); | 248 expectEquals($('node-browser-refresh-time').textContent, 'TestCanary'); |
| 243 }); | 249 }); |
| 250 | |
| 251 // Tests that the events log page correctly receives and displays an event. | |
| 252 TEST_F('SyncInternalsWebUITest', 'EventLogTest', function() { | |
| 253 // Dispatch an event. | |
| 254 var connectionEvent = new Event('onConnectionStatusChange'); | |
| 255 connectionEvent.details = { 'status': 'CONNECTION_OK' } | |
|
Dan Beam
2014/02/11 23:21:48
nit: unfortunately (because it differs from C++),
rlarocque
2014/02/12 00:39:55
Done.
| |
| 256 chrome.sync.events.dispatchEvent(connectionEvent); | |
| 257 | |
| 258 // Verify that it is displayed in the events log. | |
| 259 var syncEventsTable = $('sync-events'); | |
| 260 var firstRow = syncEventsTable.children[0]; | |
| 261 | |
| 262 // Makes some assumptions about column ordering. We'll need re-think this if | |
| 263 // it turns out to be a maintenance burden. | |
| 264 assertLE(4, firstRow.children.length); | |
|
Dan Beam
2014/02/12 00:46:19
shouldn't this be assertGE(), btw?
rlarocque
2014/02/12 01:00:46
Let's just go with assertEquals(). If someone add
| |
| 265 var submoduleName = firstRow.children[1].textContent; | |
| 266 var eventName = firstRow.children[2].textContent; | |
| 267 var detailsText = firstRow.children[3].textContent; | |
| 268 | |
| 269 assertNotEquals(undefined, submoduleName, firstRow); | |
|
Dan Beam
2014/02/11 23:21:48
nit: don't think you need to explicitly say undefi
rlarocque
2014/02/12 00:39:55
Wouldn't that end up comparing submoduleName != fi
Dan Beam
2014/02/12 00:46:19
ah, I see. these checks will never fail AFAIK as
rlarocque
2014/02/12 01:00:46
I think the idea here was to make sure that the DO
| |
| 270 assertNotEquals(undefined, eventName, firstRow); | |
| 271 assertNotEquals(undefined, detailsText, firstRow); | |
| 272 | |
| 273 expectTrue(submoduleName.indexOf('manager') != -1, | |
| 274 'submoduleName=' + submoduleName); | |
|
Dan Beam
2014/02/11 23:21:48
nit:
expectGE(submoduleName.indexOf('manager'), 0
rlarocque
2014/02/12 00:39:55
Done.
| |
| 275 expectTrue(eventName.indexOf('onConnectionStatusChange') != -1, | |
| 276 'eventName=' + eventName); | |
| 277 expectTrue(detailsText.indexOf('CONNECTION_OK') != -1, | |
| 278 'detailsText=' + detailsText); | |
| 279 }); | |
| 280 | |
| 281 TEST_F('SyncInternalsWebUITest', 'DumpSyncEventsToText', function() { | |
| 282 // Dispatch an event. | |
| 283 var connectionEvent = new Event('onConnectionStatusChange'); | |
| 284 connectionEvent.details = { 'status': 'CONNECTION_OK' } | |
| 285 chrome.sync.events.dispatchEvent(connectionEvent); | |
| 286 | |
| 287 // Click the dump-to-text button. | |
| 288 $('dump-to-text').click(); | |
| 289 | |
| 290 // Verify our event is among the results. | |
| 291 var eventDumpText = $('data-dump').textContent; | |
| 292 | |
| 293 expectTrue(eventDumpText.indexOf('onConnectionStatusChange') != -1); | |
| 294 expectTrue(eventDumpText.indexOf('CONNECTION_OK') != -1); | |
| 295 }); | |
| OLD | NEW |