| 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 20 matching lines...) Expand all Loading... |
| 31 return PolymerTest.importHtml('chrome://extensions/item.html'); | 31 return PolymerTest.importHtml('chrome://extensions/item.html'); |
| 32 }); | 32 }); |
| 33 | 33 |
| 34 // Initialize an extension item before each test. | 34 // Initialize an extension item before each test. |
| 35 setup(function() { | 35 setup(function() { |
| 36 PolymerTest.clearBody(); | 36 PolymerTest.clearBody(); |
| 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 document.body.appendChild(item); | 47 document.body.appendChild(item); |
| 48 }); | 48 }); |
| 49 | 49 |
| 50 test(assert(TestNames.Layout), function() { | 50 test(assert(TestNames.Layout), function() { |
| 51 Polymer.dom.flush(); | 51 Polymer.dom.flush(); |
| 52 | 52 |
| 53 extension_test_util.testIronIcons(item); | 53 extension_test_util.testIronIcons(item); |
| 54 | 54 |
| 55 var testIsVisible = extension_test_util.isVisible.bind(null, item); | 55 var testIsVisible = extension_test_util.isVisible.bind(null, item); |
| 56 expectTrue(testIsVisible('#close-button')); | 56 expectTrue(testIsVisible('#close-button')); |
| 57 expectTrue(testIsVisible('#open-in-webstore')); | 57 expectTrue(testIsVisible('#open-in-webstore')); |
| 58 expectTrue(testIsVisible('#options')); | 58 expectFalse(testIsVisible('#options')); |
| 59 | 59 |
| 60 // Check the checkboxes visibility and state. They should be visible | 60 // Check the checkboxes visibility and state. They should be visible |
| 61 // only if the associated option is enabled, and checked if the | 61 // only if the associated option is enabled, and checked if the |
| 62 // associated option is active. | 62 // associated option is active. |
| 63 var accessOptions = [ | 63 var accessOptions = [ |
| 64 {key: 'incognitoAccess', id: '#allow-incognito'}, | 64 {key: 'incognitoAccess', id: '#allow-incognito'}, |
| 65 {key: 'fileAccess', id: '#allow-on-file-urls'}, | 65 {key: 'fileAccess', id: '#allow-on-file-urls'}, |
| 66 {key: 'runOnAllUrls', id: '#allow-on-all-sites'}, | 66 {key: 'runOnAllUrls', id: '#allow-on-all-sites'}, |
| 67 {key: 'errorCollection', id: '#collect-errors'}, | 67 {key: 'errorCollection', id: '#collect-errors'}, |
| 68 ]; | 68 ]; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 96 | 96 |
| 97 expectFalse(testIsVisible('#permissions-list')); | 97 expectFalse(testIsVisible('#permissions-list')); |
| 98 expectTrue(testIsVisible('#no-permissions')); | 98 expectTrue(testIsVisible('#no-permissions')); |
| 99 item.set('data.permissions', ['Permission 1', 'Permission 2']); | 99 item.set('data.permissions', ['Permission 1', 'Permission 2']); |
| 100 Polymer.dom.flush(); | 100 Polymer.dom.flush(); |
| 101 expectTrue(testIsVisible('#permissions-list')); | 101 expectTrue(testIsVisible('#permissions-list')); |
| 102 expectEquals(2, | 102 expectEquals(2, |
| 103 item.$$('#permissions-list').querySelectorAll('li'). | 103 item.$$('#permissions-list').querySelectorAll('li'). |
| 104 length); | 104 length); |
| 105 expectFalse(testIsVisible('#no-permissions')); | 105 expectFalse(testIsVisible('#no-permissions')); |
| 106 |
| 107 var optionsUrl = |
| 108 'chrome-extension://' + extensionData.id + '/options.html'; |
| 109 item.set('data.optionsPage', {openInTab: true, url: optionsUrl}); |
| 110 expectTrue(testIsVisible('#options')); |
| 106 }); | 111 }); |
| 107 | 112 |
| 108 test(assert(TestNames.ClickableElements), function() { | 113 test(assert(TestNames.ClickableElements), function() { |
| 114 var optionsUrl = |
| 115 'chrome-extension://' + extensionData.id + '/options.html'; |
| 116 item.set('data.optionsPage', {openInTab: true, url: optionsUrl}); |
| 109 Polymer.dom.flush(); | 117 Polymer.dom.flush(); |
| 110 mockDelegate.testClickingCalls( | 118 mockDelegate.testClickingCalls( |
| 111 item.$$('#allow-incognito'), 'setItemAllowedIncognito', | 119 item.$$('#allow-incognito'), 'setItemAllowedIncognito', |
| 112 [extensionData.id, true]); | 120 [extensionData.id, true]); |
| 113 mockDelegate.testClickingCalls( | 121 mockDelegate.testClickingCalls( |
| 114 item.$$('#allow-on-file-urls'), 'setItemAllowedOnFileUrls', | 122 item.$$('#allow-on-file-urls'), 'setItemAllowedOnFileUrls', |
| 115 [extensionData.id, true]); | 123 [extensionData.id, true]); |
| 116 mockDelegate.testClickingCalls( | 124 mockDelegate.testClickingCalls( |
| 117 item.$$('#allow-on-all-sites'), 'setItemAllowedOnAllSites', | 125 item.$$('#allow-on-all-sites'), 'setItemAllowedOnAllSites', |
| 118 [extensionData.id, true]); | 126 [extensionData.id, true]); |
| 119 mockDelegate.testClickingCalls( | 127 mockDelegate.testClickingCalls( |
| 120 item.$$('#collect-errors'), 'setItemCollectsErrors', | 128 item.$$('#collect-errors'), 'setItemCollectsErrors', |
| 121 [extensionData.id, true]); | 129 [extensionData.id, true]); |
| 130 mockDelegate.testClickingCalls( |
| 131 item.$$('#options'), 'showItemOptionsPage', [extensionData.id]); |
| 122 }); | 132 }); |
| 123 }); | 133 }); |
| 124 } | 134 } |
| 125 | 135 |
| 126 return { | 136 return { |
| 127 registerTests: registerTests, | 137 registerTests: registerTests, |
| 128 TestNames: TestNames, | 138 TestNames: TestNames, |
| 129 }; | 139 }; |
| 130 }); | 140 }); |
| OLD | NEW |