OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * TestFixture for Invalidations WebUI testing. | 6 * TestFixture for Invalidations WebUI testing. |
7 * @extends {testing.Test} | 7 * @extends {testing.Test} |
8 * @constructor | 8 * @constructor |
9 **/ | 9 **/ |
10 function InvalidationsWebUITest() {} | 10 function InvalidationsWebUITest() {} |
11 | 11 |
12 InvalidationsWebUITest.prototype = { | 12 InvalidationsWebUITest.prototype = { |
13 __proto__: testing.Test.prototype, | 13 __proto__: testing.Test.prototype, |
14 | 14 |
15 /** | 15 /** |
16 * Browse to the Invalidations page. | 16 * Browse to the Invalidations page. |
17 **/ | 17 **/ |
18 browsePreload: 'chrome://invalidations', | 18 browsePreload: 'chrome://invalidations', |
19 runAccessibilityChecks: false, | 19 runAccessibilityChecks: false, |
20 accessibilityIssuesAreErrors: false, | 20 accessibilityIssuesAreErrors: false |
21 }; | 21 }; |
22 | 22 |
23 // Test that registering an invalidations appears properly on the textarea. | 23 // Test that registering an invalidations appears properly on the textarea. |
24 TEST_F('InvalidationsWebUITest', 'testRegisteringNewInvalidation', function() { | 24 TEST_F('InvalidationsWebUITest', 'testRegisteringNewInvalidation', function() { |
25 var invalidationsLog = $('invalidations-log'); | 25 var invalidationsLog = $('invalidations-log'); |
26 var invalidation = [{ | 26 var invalidation = [{ |
27 isUnknownVersion: 'true', | 27 isUnknownVersion: 'true', |
28 objectId: {name: 'EXTENSIONS', source: 1004} | 28 objectId: {name: 'EXTENSIONS', source: 1004} |
29 }]; | 29 }]; |
30 invalidationsLog.value = ''; | 30 invalidationsLog.value = ''; |
(...skipping 17 matching lines...) Expand all Loading... |
48 chrome.invalidations.updateState(newState); | 48 chrome.invalidations.updateState(newState); |
49 expectEquals(invalidationsState.textContent, | 49 expectEquals(invalidationsState.textContent, |
50 'INVALIDATIONS_ENABLED', | 50 'INVALIDATIONS_ENABLED', |
51 'could not change the invalidations text'); | 51 'could not change the invalidations text'); |
52 invalidationsLog.value = ''; | 52 invalidationsLog.value = ''; |
53 chrome.invalidations.updateState(newNewState); | 53 chrome.invalidations.updateState(newNewState); |
54 expectEquals(invalidationsState.textContent, | 54 expectEquals(invalidationsState.textContent, |
55 'TRANSIENT_INVALIDATION_ERROR'); | 55 'TRANSIENT_INVALIDATION_ERROR'); |
56 var isContained = | 56 var isContained = |
57 invalidationsLog.value.indexOf( | 57 invalidationsLog.value.indexOf( |
58 'Invalidations service state changed to '+ | 58 'Invalidations service state changed to ' + |
59 '"TRANSIENT_INVALIDATION_ERROR"') != -1; | 59 '"TRANSIENT_INVALIDATION_ERROR"') != -1; |
60 expectTrue(isContained, 'Actual log is:' + invalidationsLog.value); | 60 expectTrue(isContained, 'Actual log is:' + invalidationsLog.value); |
61 }); | 61 }); |
62 | 62 |
| 63 // Test that objects ids appear on the table. |
| 64 TEST_F('InvalidationsWebUITest', 'testRegisteringNewIds', function() { |
| 65 var newDataType = [ |
| 66 { name: 'EXTENSIONS', source: 1004}, |
| 67 { name: 'FAVICON_IMAGE', source: 1004} |
| 68 ]; |
| 69 var pattern1 = ['Fake', '1004', 'EXTENSIONS', '0', '', '', '']; |
| 70 var pattern2 = ['Fake', '1004', 'FAVICON_IMAGE', '0', '', '', '']; |
| 71 // Register two objects ID with 'Fake' registrar |
| 72 chrome.invalidations.updateIds('Fake', newDataType); |
| 73 // Disable the Extensions ObjectId by only sending FAVICON_IMAGE |
| 74 newDataType = [{ name: 'FAVICON_IMAGE', source: 1004}]; |
| 75 chrome.invalidations.updateIds('Fake', newDataType); |
| 76 |
| 77 // Test that the two patterns are contained in the table. |
| 78 var oidTable = $('objectsid-table-container'); |
| 79 var foundPattern1 = false; |
| 80 var foundPattern2 = false; |
| 81 for (var row = 0; row < oidTable.rows.length; row++) { |
| 82 var pattern1Test = true; |
| 83 var pattern2Test = true; |
| 84 for (var cell = 0; cell < oidTable.rows[row].cells.length; cell++) { |
| 85 pattern1Test = pattern1Test |
| 86 && (pattern1[cell] == oidTable.rows[row].cells[cell].textContent); |
| 87 pattern2Test = pattern2Test |
| 88 && (pattern2[cell] == oidTable.rows[row].cells[cell].textContent); |
| 89 } |
| 90 if (pattern1Test) |
| 91 expectEquals('greyed', oidTable.rows[row].className); |
| 92 if (pattern2Test) |
| 93 expectEquals('content', oidTable.rows[row].className); |
| 94 |
| 95 foundPattern1 = foundPattern1 || pattern1Test; |
| 96 foundPattern2 = foundPattern2 || pattern2Test; |
| 97 if (foundPattern2) |
| 98 expectTrue(foundPattern1, 'The entries were not ordererd'); |
| 99 } |
| 100 expectTrue(foundPattern1 && foundPattern2, "couldn't find both objects ids"); |
| 101 |
| 102 }); |
OLD | NEW |