| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 extension-sidebar. */ | 5 /** @fileoverview Suite of tests for extension-sidebar. */ |
| 6 cr.define('extension_manager_tests', function() { | 6 cr.define('extension_manager_tests', function() { |
| 7 /** @enum {string} */ | 7 /** @enum {string} */ |
| 8 var TestNames = { | 8 var TestNames = { |
| 9 ItemOrder: 'item order', | 9 ItemOrder: 'item order', |
| 10 ItemListVisibility: 'item list visibility', | 10 ItemListVisibility: 'item list visibility', |
| 11 ShowItems: 'show items', | 11 ShowItems: 'show items', |
| 12 ChangePages: 'change pages', | 12 ChangePages: 'change pages', |
| 13 UrlNavigationToDetails: 'url navigation to details', | 13 UrlNavigationToDetails: 'url navigation to details', |
| 14 UpdateItemData: 'update item data', |
| 14 }; | 15 }; |
| 15 | 16 |
| 16 function getDataByName(list, name) { | 17 function getDataByName(list, name) { |
| 17 return assert(list.find(function(el) { return el.name == name; })); | 18 return assert(list.find(function(el) { return el.name == name; })); |
| 18 } | 19 } |
| 19 | 20 |
| 20 function registerTests() { | 21 function registerTests() { |
| 21 suite('ExtensionManagerTest', function() { | 22 suite('ExtensionManagerTest', function() { |
| 22 /** @type {extensions.Manager} */ | 23 /** @type {extensions.Manager} */ |
| 23 var manager; | 24 var manager; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 MockInteractions.tap(manager.sidebar.$['keyboard-shortcuts']); | 153 MockInteractions.tap(manager.sidebar.$['keyboard-shortcuts']); |
| 153 Polymer.dom.flush(); | 154 Polymer.dom.flush(); |
| 154 expectEquals(Page.KEYBOARD_SHORTCUTS, pages.selected); | 155 expectEquals(Page.KEYBOARD_SHORTCUTS, pages.selected); |
| 155 }); | 156 }); |
| 156 | 157 |
| 157 test(assert(TestNames.UrlNavigationToDetails), function() { | 158 test(assert(TestNames.UrlNavigationToDetails), function() { |
| 158 expectEquals(Page.DETAIL_VIEW, manager.$.pages.selected); | 159 expectEquals(Page.DETAIL_VIEW, manager.$.pages.selected); |
| 159 var detailsView = manager.$['details-view']; | 160 var detailsView = manager.$['details-view']; |
| 160 expectEquals('ldnnhddmnhbkjipkidpdiheffobcpfmf', detailsView.data.id); | 161 expectEquals('ldnnhddmnhbkjipkidpdiheffobcpfmf', detailsView.data.id); |
| 161 }); | 162 }); |
| 163 |
| 164 test(assert(TestNames.UpdateItemData), function() { |
| 165 var oldDescription = 'old description'; |
| 166 var newDescription = 'new description'; |
| 167 var extension = extension_test_util.createExtensionInfo( |
| 168 {description: oldDescription}); |
| 169 var secondExtension = extension_test_util.createExtensionInfo({ |
| 170 description: 'irrelevant', |
| 171 id: 'b'.repeat(32), |
| 172 }); |
| 173 manager.addItem(extension); |
| 174 manager.addItem(secondExtension); |
| 175 var data = manager.extensions[0]; |
| 176 manager.showItemDetails(extension); |
| 177 var detailsView = manager.$['details-view']; |
| 178 expectEquals(extension.id, detailsView.data.id); |
| 179 expectEquals(oldDescription, detailsView.data.description); |
| 180 expectEquals( |
| 181 oldDescription, |
| 182 detailsView.$$('.section .section-content').textContent.trim()); |
| 183 |
| 184 var extensionCopy = Object.assign({}, extension); |
| 185 extensionCopy.description = newDescription; |
| 186 manager.updateItem(extensionCopy); |
| 187 expectEquals(extension.id, detailsView.data.id); |
| 188 expectEquals(newDescription, detailsView.data.description); |
| 189 expectEquals( |
| 190 newDescription, |
| 191 detailsView.$$('.section .section-content').textContent.trim()); |
| 192 |
| 193 // Updating a different extension shouldn't have any impact. |
| 194 var secondExtensionCopy = Object.assign({}, secondExtension); |
| 195 secondExtensionCopy.description = 'something else'; |
| 196 manager.updateItem(secondExtensionCopy); |
| 197 expectEquals(extension.id, detailsView.data.id); |
| 198 expectEquals(newDescription, detailsView.data.description); |
| 199 expectEquals( |
| 200 newDescription, |
| 201 detailsView.$$('.section .section-content').textContent.trim()); |
| 202 |
| 203 }); |
| 162 }); | 204 }); |
| 163 } | 205 } |
| 164 | 206 |
| 165 return { | 207 return { |
| 166 registerTests: registerTests, | 208 registerTests: registerTests, |
| 167 TestNames: TestNames, | 209 TestNames: TestNames, |
| 168 }; | 210 }; |
| 169 }); | 211 }); |
| OLD | NEW |