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 12 matching lines...) Expand all Loading... |
43 for (var j = 0; j < details[i].data.length; ++j) { | 49 for (var j = 0; j < details[i].data.length; ++j) { |
44 var obj = details[i].data[j]; | 50 var obj = details[i].data[j]; |
45 if (obj.stat_name == key) | 51 if (obj.stat_name == key) |
46 return obj.is_valid == isValid && obj.stat_value == value; | 52 return obj.is_valid == isValid && obj.stat_value == value; |
47 } | 53 } |
48 } | 54 } |
49 return false; | 55 return false; |
50 } | 56 } |
51 }; | 57 }; |
52 | 58 |
53 /** Constant hard-coded value to return from mock getAllNodes */ | 59 /** |
| 60 * Constant hard-coded value to return from mock getAllNodes. |
| 61 * @const |
| 62 */ |
54 var HARD_CODED_ALL_NODES = [ | 63 var HARD_CODED_ALL_NODES = [ |
55 { | 64 { |
56 "BASE_SERVER_SPECIFICS": {}, | 65 "BASE_SERVER_SPECIFICS": {}, |
57 "BASE_VERSION": "1388699799780000", | 66 "BASE_VERSION": "1388699799780000", |
58 "CTIME": "Wednesday, December 31, 1969 4:00:00 PM", | 67 "CTIME": "Wednesday, December 31, 1969 4:00:00 PM", |
59 "ID": "sZ:ADqtAZw5kjSwSkukraMoMX6z0OlFXENzhA+1HZNcO6LbATQrkVenHJS5" + | 68 "ID": "sZ:ADqtAZw5kjSwSkukraMoMX6z0OlFXENzhA+1HZNcO6LbATQrkVenHJS5" + |
60 "AgICYfj8/6KcvwlCw3FIvcRFtOEP3zSP5YJ1VH53/Q==", | 69 "AgICYfj8/6KcvwlCw3FIvcRFtOEP3zSP5YJ1VH53/Q==", |
61 "IS_DEL": false, | 70 "IS_DEL": false, |
62 "IS_DIR": true, | 71 "IS_DIR": true, |
63 "IS_UNAPPLIED_UPDATE": false, | 72 "IS_UNAPPLIED_UPDATE": false, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 "TRANSACTION_VERSION": "1", | 160 "TRANSACTION_VERSION": "1", |
152 "UNIQUE_BOOKMARK_TAG": "", | 161 "UNIQUE_BOOKMARK_TAG": "", |
153 "UNIQUE_CLIENT_TAG": "J28uWKpXPuQwR3SJKbuLqzYGOcM=", | 162 "UNIQUE_CLIENT_TAG": "J28uWKpXPuQwR3SJKbuLqzYGOcM=", |
154 "UNIQUE_POSITION": "INVALID[]", | 163 "UNIQUE_POSITION": "INVALID[]", |
155 "UNIQUE_SERVER_TAG": "", | 164 "UNIQUE_SERVER_TAG": "", |
156 "isDirty": false, | 165 "isDirty": false, |
157 "serverModelType": "Typed URLs" | 166 "serverModelType": "Typed URLs" |
158 } | 167 } |
159 ]; | 168 ]; |
160 | 169 |
| 170 /** |
| 171 * Constant hard-coded value to return from mock getAboutInfo. |
| 172 * @const |
| 173 */ |
| 174 HARD_CODED_ABOUT_INFO = { |
| 175 "actionable_error": [ |
| 176 { |
| 177 "is_valid": false, |
| 178 "stat_name": "Error Type", |
| 179 "stat_value": "Uninitialized" |
| 180 }, |
| 181 { |
| 182 "is_valid": false, |
| 183 "stat_name": "Action", |
| 184 "stat_value": "Uninitialized" |
| 185 }, |
| 186 { |
| 187 "is_valid": false, |
| 188 "stat_name": "URL", |
| 189 "stat_value": "Uninitialized" |
| 190 }, |
| 191 { |
| 192 "is_valid": false, |
| 193 "stat_name": "Error Description", |
| 194 "stat_value": "Uninitialized" |
| 195 } |
| 196 ], |
| 197 "actionable_error_detected": false, |
| 198 "details": [ |
| 199 { |
| 200 "data": [ |
| 201 { |
| 202 "is_valid": true, |
| 203 "stat_name": "Summary", |
| 204 "stat_value": "Sync service initialized" |
| 205 } |
| 206 ], |
| 207 "is_sensitive": false, |
| 208 "title": "Summary" |
| 209 }, |
| 210 ], |
| 211 "type_status": [ |
| 212 { |
| 213 "name": "Model Type", |
| 214 "num_entries": "Total Entries", |
| 215 "num_live": "Live Entries", |
| 216 "status": "header", |
| 217 "value": "Group Type" |
| 218 }, |
| 219 { |
| 220 "name": "Bookmarks", |
| 221 "num_entries": 2793, |
| 222 "num_live": 2793, |
| 223 "status": "ok", |
| 224 "value": "Active: GROUP_UI" |
| 225 }, |
| 226 ], |
| 227 "unrecoverable_error_detected": false |
| 228 }; |
| 229 |
161 TEST_F('SyncInternalsWebUITest', 'Uninitialized', function() { | 230 TEST_F('SyncInternalsWebUITest', 'Uninitialized', function() { |
162 assertNotEquals(null, chrome.sync.aboutInfo); | 231 assertNotEquals(null, chrome.sync.aboutInfo); |
163 expectTrue(this.hasInDetails(true, 'Username', '')); | 232 expectTrue(this.hasInDetails(true, 'Username', '')); |
164 expectTrue(this.hasInDetails(false, 'Summary', 'Uninitialized')); | 233 expectTrue(this.hasInDetails(false, 'Summary', 'Uninitialized')); |
165 }); | 234 }); |
166 | 235 |
| 236 TEST_F('SyncInternalsWebUITest', 'LoadPastedAboutInfo', function() { |
| 237 // Expose the text field. |
| 238 $('import-status').click(); |
| 239 |
| 240 // Fill it with fake data. |
| 241 $('status-text').value = JSON.stringify(HARD_CODED_ABOUT_INFO); |
| 242 |
| 243 // Trigger the import. |
| 244 $('import-status').click(); |
| 245 |
| 246 expectTrue(this.hasInDetails(true, 'Summary', 'Sync service initialized')); |
| 247 }); |
| 248 |
167 TEST_F('SyncInternalsWebUITest', 'SearchTabDoesntChangeOnItemSelect', | 249 TEST_F('SyncInternalsWebUITest', 'SearchTabDoesntChangeOnItemSelect', |
168 function() { | 250 function() { |
169 // Select the search tab. | 251 // Select the search tab. |
170 $('sync-search-tab').selected = true; | 252 $('sync-search-tab').selected = true; |
171 expectTrue($('sync-search-tab').selected); | 253 expectTrue($('sync-search-tab').selected); |
172 | 254 |
173 // Build the data model and attach to result list. | 255 // Build the data model and attach to result list. |
174 cr.ui.List.decorate($('sync-results-list')); | 256 cr.ui.List.decorate($('sync-results-list')); |
175 $('sync-results-list').dataModel = new cr.ui.ArrayDataModel([ | 257 $('sync-results-list').dataModel = new cr.ui.ArrayDataModel([ |
176 { | 258 { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // Selecting the tab will refresh it. | 316 // Selecting the tab will refresh it. |
235 $('sync-browser-tab').selected = true; | 317 $('sync-browser-tab').selected = true; |
236 expectNotEquals($('node-browser-refresh-time').textContent, 'Never'); | 318 expectNotEquals($('node-browser-refresh-time').textContent, 'Never'); |
237 | 319 |
238 // Re-selecting the tab shouldn't re-refresh. | 320 // Re-selecting the tab shouldn't re-refresh. |
239 $('node-browser-refresh-time').textContent = 'TestCanary'; | 321 $('node-browser-refresh-time').textContent = 'TestCanary'; |
240 $('sync-browser-tab').selected = false; | 322 $('sync-browser-tab').selected = false; |
241 $('sync-browser-tab').selected = true; | 323 $('sync-browser-tab').selected = true; |
242 expectEquals($('node-browser-refresh-time').textContent, 'TestCanary'); | 324 expectEquals($('node-browser-refresh-time').textContent, 'TestCanary'); |
243 }); | 325 }); |
| 326 |
| 327 // Tests that the events log page correctly receives and displays an event. |
| 328 TEST_F('SyncInternalsWebUITest', 'EventLogTest', function() { |
| 329 // Dispatch an event. |
| 330 var connectionEvent = new Event('onConnectionStatusChange'); |
| 331 connectionEvent.details = {'status': 'CONNECTION_OK'}; |
| 332 chrome.sync.events.dispatchEvent(connectionEvent); |
| 333 |
| 334 // Verify that it is displayed in the events log. |
| 335 var syncEventsTable = $('sync-events'); |
| 336 var firstRow = syncEventsTable.children[0]; |
| 337 |
| 338 // Makes some assumptions about column ordering. We'll need re-think this if |
| 339 // it turns out to be a maintenance burden. |
| 340 assertEquals(4, firstRow.children.length); |
| 341 var submoduleName = firstRow.children[1].textContent; |
| 342 var eventName = firstRow.children[2].textContent; |
| 343 var detailsText = firstRow.children[3].textContent; |
| 344 |
| 345 expectGE(submoduleName.indexOf('manager'), 0, |
| 346 'submoduleName=' + submoduleName); |
| 347 expectGE(eventName.indexOf('onConnectionStatusChange'), 0, |
| 348 'eventName=' + eventName); |
| 349 expectGE(detailsText.indexOf('CONNECTION_OK'), 0, |
| 350 'detailsText=' + detailsText); |
| 351 }); |
| 352 |
| 353 TEST_F('SyncInternalsWebUITest', 'DumpSyncEventsToText', function() { |
| 354 // Dispatch an event. |
| 355 var connectionEvent = new Event('onConnectionStatusChange'); |
| 356 connectionEvent.details = {'status': 'CONNECTION_OK'} |
| 357 chrome.sync.events.dispatchEvent(connectionEvent); |
| 358 |
| 359 // Click the dump-to-text button. |
| 360 $('dump-to-text').click(); |
| 361 |
| 362 // Verify our event is among the results. |
| 363 var eventDumpText = $('data-dump').textContent; |
| 364 |
| 365 expectGE(eventDumpText.indexOf('onConnectionStatusChange'), 0); |
| 366 expectGE(eventDumpText.indexOf('CONNECTION_OK'), 0); |
| 367 }); |
OLD | NEW |