OLD | NEW |
---|---|
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 /** @fileoverview Suite of tests for extensions-detail-view. */ | 5 /** @fileoverview Suite of tests for extensions-detail-view. */ |
6 cr.define('extension_detail_view_tests', function() { | 6 cr.define('extension_detail_view_tests', function() { |
7 /** @enum {string} */ | 7 /** @enum {string} */ |
8 var TestNames = { | 8 var TestNames = { |
9 Layout: 'layout', | 9 Layout: 'layout', |
10 ClickableElements: 'clickable elements', | 10 ClickableElements: 'clickable elements', |
(...skipping 26 matching lines...) Expand all Loading... | |
37 extensionData = extension_test_util.createExtensionInfo({ | 37 extensionData = extension_test_util.createExtensionInfo({ |
38 incognitoAccess: {isEnabled: true, isActive: false}, | 38 incognitoAccess: {isEnabled: true, isActive: false}, |
39 fileAccess: {isEnabled: true, isActive: false}, | 39 fileAccess: {isEnabled: true, isActive: false}, |
40 runOnAllUrls: {isEnabled: true, isActive: false}, | 40 runOnAllUrls: {isEnabled: true, isActive: false}, |
41 errorCollection: {isEnabled: true, isActive: false}, | 41 errorCollection: {isEnabled: true, isActive: false}, |
42 }); | 42 }); |
43 mockDelegate = new extension_test_util.MockItemDelegate(); | 43 mockDelegate = new extension_test_util.MockItemDelegate(); |
44 item = new extensions.DetailView(); | 44 item = new extensions.DetailView(); |
45 item.set('data', extensionData); | 45 item.set('data', extensionData); |
46 item.set('delegate', mockDelegate); | 46 item.set('delegate', mockDelegate); |
47 item.set('inDevMode', false); | |
47 document.body.appendChild(item); | 48 document.body.appendChild(item); |
48 }); | 49 }); |
49 | 50 |
50 test(assert(TestNames.Layout), function() { | 51 test(assert(TestNames.Layout), function() { |
51 Polymer.dom.flush(); | 52 Polymer.dom.flush(); |
52 | 53 |
53 extension_test_util.testIronIcons(item); | 54 extension_test_util.testIronIcons(item); |
54 | 55 |
55 var testIsVisible = extension_test_util.isVisible.bind(null, item); | 56 var testIsVisible = extension_test_util.isVisible.bind(null, item); |
56 expectTrue(testIsVisible('#close-button')); | 57 expectTrue(testIsVisible('#close-button')); |
57 expectFalse(testIsVisible('#open-homepage')); | 58 expectTrue(testIsVisible('#icon')); |
58 expectFalse(testIsVisible('#options')); | 59 expectTrue(testIsVisible('#enable-toggle')); |
60 expectFalse(testIsVisible('#extensions-options')); | |
59 | 61 |
60 // Check the checkboxes visibility and state. They should be visible | 62 // Check the checkboxes visibility and state. They should be visible |
61 // only if the associated option is enabled, and checked if the | 63 // only if the associated option is enabled, and checked if the |
62 // associated option is active. | 64 // associated option is active. |
63 var accessOptions = [ | 65 var accessOptions = [ |
64 {key: 'incognitoAccess', id: '#allow-incognito'}, | 66 {key: 'incognitoAccess', id: '#allow-incognito'}, |
65 {key: 'fileAccess', id: '#allow-on-file-urls'}, | 67 {key: 'fileAccess', id: '#allow-on-file-urls'}, |
66 {key: 'runOnAllUrls', id: '#allow-on-all-sites'}, | 68 {key: 'runOnAllUrls', id: '#allow-on-all-sites'}, |
67 {key: 'errorCollection', id: '#collect-errors'}, | 69 {key: 'errorCollection', id: '#collect-errors'}, |
68 ]; | 70 ]; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 Polymer.dom.flush(); | 102 Polymer.dom.flush(); |
101 expectTrue(testIsVisible('#permissions-list')); | 103 expectTrue(testIsVisible('#permissions-list')); |
102 expectEquals(2, | 104 expectEquals(2, |
103 item.$$('#permissions-list').querySelectorAll('li'). | 105 item.$$('#permissions-list').querySelectorAll('li'). |
104 length); | 106 length); |
105 expectFalse(testIsVisible('#no-permissions')); | 107 expectFalse(testIsVisible('#no-permissions')); |
106 | 108 |
107 var optionsUrl = | 109 var optionsUrl = |
108 'chrome-extension://' + extensionData.id + '/options.html'; | 110 'chrome-extension://' + extensionData.id + '/options.html'; |
109 item.set('data.optionsPage', {openInTab: true, url: optionsUrl}); | 111 item.set('data.optionsPage', {openInTab: true, url: optionsUrl}); |
110 expectTrue(testIsVisible('#options')); | 112 expectTrue(testIsVisible('#extensions-options')); |
111 | 113 |
112 var homepageUrl = 'https://www.example.com/'; | 114 // TODO(devlin): Add these back once homepages are in the mocks again. |
michaelpg
2017/03/06 19:08:46
I would leave a TODO remove the unused code. Yay v
michaelpg
2017/03/06 19:55:02
That is, leave this TODO, *but* remove commented-o
Devlin
2017/03/06 20:12:12
Okay, done.
| |
113 item.set('data.homePage', {specified: true, url: homepageUrl}); | 115 // expectFalse(testIsVisible('#open-homepage')); |
114 expectTrue(testIsVisible('#open-homepage')); | 116 // var homepageUrl = 'https://www.example.com/'; |
115 expectEquals(homepageUrl, item.$$('#open-homepage').href); | 117 // item.set('data.homePage', {specified: true, url: homepageUrl}); |
118 // expectTrue(testIsVisible('#open-homepage')); | |
119 // expectEquals(homepageUrl, item.$$('#open-homepage').href); | |
120 | |
121 expectFalse(testIsVisible('#id-section')); | |
122 expectFalse(testIsVisible('#inspectable-views')); | |
123 | |
124 item.set('inDevMode', true); | |
125 Polymer.dom.flush(); | |
126 expectTrue(testIsVisible('#id-section')); | |
127 expectTrue(testIsVisible('#inspectable-views')); | |
116 }); | 128 }); |
117 | 129 |
118 test(assert(TestNames.ClickableElements), function() { | 130 test(assert(TestNames.ClickableElements), function() { |
119 var optionsUrl = | 131 var optionsUrl = |
120 'chrome-extension://' + extensionData.id + '/options.html'; | 132 'chrome-extension://' + extensionData.id + '/options.html'; |
121 item.set('data.optionsPage', {openInTab: true, url: optionsUrl}); | 133 item.set('data.optionsPage', {openInTab: true, url: optionsUrl}); |
122 Polymer.dom.flush(); | 134 Polymer.dom.flush(); |
123 mockDelegate.testClickingCalls( | 135 mockDelegate.testClickingCalls( |
124 item.$$('#allow-incognito'), 'setItemAllowedIncognito', | 136 item.$$('#allow-incognito'), 'setItemAllowedIncognito', |
125 [extensionData.id, true]); | 137 [extensionData.id, true]); |
126 mockDelegate.testClickingCalls( | 138 mockDelegate.testClickingCalls( |
127 item.$$('#allow-on-file-urls'), 'setItemAllowedOnFileUrls', | 139 item.$$('#allow-on-file-urls'), 'setItemAllowedOnFileUrls', |
128 [extensionData.id, true]); | 140 [extensionData.id, true]); |
129 mockDelegate.testClickingCalls( | 141 mockDelegate.testClickingCalls( |
130 item.$$('#allow-on-all-sites'), 'setItemAllowedOnAllSites', | 142 item.$$('#allow-on-all-sites'), 'setItemAllowedOnAllSites', |
131 [extensionData.id, true]); | 143 [extensionData.id, true]); |
132 mockDelegate.testClickingCalls( | 144 mockDelegate.testClickingCalls( |
133 item.$$('#collect-errors'), 'setItemCollectsErrors', | 145 item.$$('#collect-errors'), 'setItemCollectsErrors', |
134 [extensionData.id, true]); | 146 [extensionData.id, true]); |
135 mockDelegate.testClickingCalls( | 147 mockDelegate.testClickingCalls( |
136 item.$$('#options'), 'showItemOptionsPage', [extensionData.id]); | 148 item.$$('#extensions-options'), 'showItemOptionsPage', |
149 [extensionData.id]); | |
150 mockDelegate.testClickingCalls( | |
151 item.$$('#remove-extension'), 'deleteItem', | |
152 [extensionData.id]); | |
137 }); | 153 }); |
138 }); | 154 }); |
139 } | 155 } |
140 | 156 |
141 return { | 157 return { |
142 registerTests: registerTests, | 158 registerTests: registerTests, |
143 TestNames: TestNames, | 159 TestNames: TestNames, |
144 }; | 160 }; |
145 }); | 161 }); |
OLD | NEW |