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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 "TRANSACTION_VERSION": "1", | 157 "TRANSACTION_VERSION": "1", |
| 152 "UNIQUE_BOOKMARK_TAG": "", | 158 "UNIQUE_BOOKMARK_TAG": "", |
| 153 "UNIQUE_CLIENT_TAG": "J28uWKpXPuQwR3SJKbuLqzYGOcM=", | 159 "UNIQUE_CLIENT_TAG": "J28uWKpXPuQwR3SJKbuLqzYGOcM=", |
| 154 "UNIQUE_POSITION": "INVALID[]", | 160 "UNIQUE_POSITION": "INVALID[]", |
| 155 "UNIQUE_SERVER_TAG": "", | 161 "UNIQUE_SERVER_TAG": "", |
| 156 "isDirty": false, | 162 "isDirty": false, |
| 157 "serverModelType": "Typed URLs" | 163 "serverModelType": "Typed URLs" |
| 158 } | 164 } |
| 159 ]; | 165 ]; |
| 160 | 166 |
| 167 HARD_CODED_ABOUT_INFO = { | |
|
Dan Beam
2014/02/12 01:25:00
nit:
/** @const */
var HARD_CODED_ABOUT_INFO = {
rlarocque
2014/02/12 02:07:39
Done.
| |
| 168 "actionable_error": [ | |
| 169 { | |
| 170 "is_valid": false, | |
| 171 "stat_name": "Error Type", | |
| 172 "stat_value": "Uninitialized" | |
| 173 }, | |
| 174 { | |
| 175 "is_valid": false, | |
| 176 "stat_name": "Action", | |
| 177 "stat_value": "Uninitialized" | |
| 178 }, | |
| 179 { | |
| 180 "is_valid": false, | |
| 181 "stat_name": "URL", | |
| 182 "stat_value": "Uninitialized" | |
| 183 }, | |
| 184 { | |
| 185 "is_valid": false, | |
| 186 "stat_name": "Error Description", | |
| 187 "stat_value": "Uninitialized" | |
| 188 } | |
| 189 ], | |
| 190 "actionable_error_detected": false, | |
| 191 "details": [ | |
| 192 { | |
| 193 "data": [ | |
| 194 { | |
| 195 "is_valid": true, | |
| 196 "stat_name": "Summary", | |
| 197 "stat_value": "Sync service initialized" | |
| 198 } | |
| 199 ], | |
| 200 "is_sensitive": false, | |
| 201 "title": "Summary" | |
| 202 }, | |
| 203 ], | |
| 204 "type_status": [ | |
| 205 { | |
| 206 "name": "Model Type", | |
| 207 "num_entries": "Total Entries", | |
| 208 "num_live": "Live Entries", | |
| 209 "status": "header", | |
| 210 "value": "Group Type" | |
| 211 }, | |
| 212 { | |
| 213 "name": "Bookmarks", | |
| 214 "num_entries": 2793, | |
| 215 "num_live": 2793, | |
| 216 "status": "ok", | |
| 217 "value": "Active: GROUP_UI" | |
| 218 }, | |
| 219 ], | |
| 220 "unrecoverable_error_detected": false | |
| 221 }; | |
| 222 | |
| 161 TEST_F('SyncInternalsWebUITest', 'Uninitialized', function() { | 223 TEST_F('SyncInternalsWebUITest', 'Uninitialized', function() { |
| 162 assertNotEquals(null, chrome.sync.aboutInfo); | 224 assertNotEquals(null, chrome.sync.aboutInfo); |
| 163 expectTrue(this.hasInDetails(true, 'Username', '')); | 225 expectTrue(this.hasInDetails(true, 'Username', '')); |
| 164 expectTrue(this.hasInDetails(false, 'Summary', 'Uninitialized')); | 226 expectTrue(this.hasInDetails(false, 'Summary', 'Uninitialized')); |
| 165 }); | 227 }); |
| 166 | 228 |
| 229 TEST_F('SyncInternalsWebUITest', 'LoadPastedAboutInfo', function() { | |
| 230 // Expose the text field. | |
| 231 $('import-status').click(); | |
| 232 | |
| 233 // Fill it with fake data. | |
| 234 $('status-text').value = JSON.stringify(HARD_CODED_ABOUT_INFO); | |
| 235 | |
| 236 // Trigger the import. | |
| 237 $('import-status').click(); | |
| 238 | |
| 239 expectTrue(this.hasInDetails(true, 'Summary', 'Sync service initialized')); | |
| 240 }); | |
| 241 | |
| 167 TEST_F('SyncInternalsWebUITest', 'SearchTabDoesntChangeOnItemSelect', | 242 TEST_F('SyncInternalsWebUITest', 'SearchTabDoesntChangeOnItemSelect', |
| 168 function() { | 243 function() { |
| 169 // Select the search tab. | 244 // Select the search tab. |
| 170 $('sync-search-tab').selected = true; | 245 $('sync-search-tab').selected = true; |
| 171 expectTrue($('sync-search-tab').selected); | 246 expectTrue($('sync-search-tab').selected); |
| 172 | 247 |
| 173 // Build the data model and attach to result list. | 248 // Build the data model and attach to result list. |
| 174 cr.ui.List.decorate($('sync-results-list')); | 249 cr.ui.List.decorate($('sync-results-list')); |
| 175 $('sync-results-list').dataModel = new cr.ui.ArrayDataModel([ | 250 $('sync-results-list').dataModel = new cr.ui.ArrayDataModel([ |
| 176 { | 251 { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 // Selecting the tab will refresh it. | 309 // Selecting the tab will refresh it. |
| 235 $('sync-browser-tab').selected = true; | 310 $('sync-browser-tab').selected = true; |
| 236 expectNotEquals($('node-browser-refresh-time').textContent, 'Never'); | 311 expectNotEquals($('node-browser-refresh-time').textContent, 'Never'); |
| 237 | 312 |
| 238 // Re-selecting the tab shouldn't re-refresh. | 313 // Re-selecting the tab shouldn't re-refresh. |
| 239 $('node-browser-refresh-time').textContent = 'TestCanary'; | 314 $('node-browser-refresh-time').textContent = 'TestCanary'; |
| 240 $('sync-browser-tab').selected = false; | 315 $('sync-browser-tab').selected = false; |
| 241 $('sync-browser-tab').selected = true; | 316 $('sync-browser-tab').selected = true; |
| 242 expectEquals($('node-browser-refresh-time').textContent, 'TestCanary'); | 317 expectEquals($('node-browser-refresh-time').textContent, 'TestCanary'); |
| 243 }); | 318 }); |
| 319 | |
| 320 // Tests that the events log page correctly receives and displays an event. | |
| 321 TEST_F('SyncInternalsWebUITest', 'EventLogTest', function() { | |
| 322 // Dispatch an event. | |
| 323 var connectionEvent = new Event('onConnectionStatusChange'); | |
| 324 connectionEvent.details = {'status': 'CONNECTION_OK'}; | |
| 325 chrome.sync.events.dispatchEvent(connectionEvent); | |
| 326 | |
| 327 // Verify that it is displayed in the events log. | |
| 328 var syncEventsTable = $('sync-events'); | |
| 329 var firstRow = syncEventsTable.children[0]; | |
| 330 | |
| 331 // Makes some assumptions about column ordering. We'll need re-think this if | |
| 332 // it turns out to be a maintenance burden. | |
| 333 assertEquals(4, firstRow.children.length); | |
| 334 var submoduleName = firstRow.children[1].textContent; | |
| 335 var eventName = firstRow.children[2].textContent; | |
| 336 var detailsText = firstRow.children[3].textContent; | |
| 337 | |
| 338 expectGE(submoduleName.indexOf('manager'), 0, | |
| 339 'submoduleName=' + submoduleName); | |
| 340 expectGE(eventName.indexOf('onConnectionStatusChange'), 0, | |
| 341 'eventName=' + eventName); | |
| 342 expectGE(detailsText.indexOf('CONNECTION_OK'), 0, | |
| 343 'detailsText=' + detailsText); | |
| 344 }); | |
| 345 | |
| 346 TEST_F('SyncInternalsWebUITest', 'DumpSyncEventsToText', function() { | |
| 347 // Dispatch an event. | |
| 348 var connectionEvent = new Event('onConnectionStatusChange'); | |
| 349 connectionEvent.details = { 'status': 'CONNECTION_OK' } | |
|
Dan Beam
2014/02/12 01:25:00
remove \s between { and } here, too
rlarocque
2014/02/12 02:07:39
Done.
| |
| 350 chrome.sync.events.dispatchEvent(connectionEvent); | |
| 351 | |
| 352 // Click the dump-to-text button. | |
| 353 $('dump-to-text').click(); | |
| 354 | |
| 355 // Verify our event is among the results. | |
| 356 var eventDumpText = $('data-dump').textContent; | |
| 357 | |
| 358 expectTrue(eventDumpText.indexOf('onConnectionStatusChange') != -1); | |
| 359 expectTrue(eventDumpText.indexOf('CONNECTION_OK') != -1); | |
|
Dan Beam
2014/02/12 01:25:00
^ update these as well, IMO, to use expectNE
rlarocque
2014/02/12 02:07:39
I went with GE 0, since that's what I ended up usi
| |
| 360 }); | |
| OLD | NEW |