Chromium Code Reviews| 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 SplitSections: 'split sections', | 9 SplitSections: 'split sections', |
| 10 ItemOrder: 'item order', | |
| 10 }; | 11 }; |
| 11 | 12 |
| 12 function registerTests() { | 13 function registerTests() { |
| 13 suite('ExtensionManagerTest', function() { | 14 suite('ExtensionManagerTest', function() { |
| 14 /** @type {extensions.Manager} */ | 15 /** @type {extensions.Manager} */ |
| 15 var manager; | 16 var manager; |
| 16 | 17 |
| 17 setup(function() { | 18 setup(function() { |
| 18 manager = document.querySelector('extensions-manager'); | 19 manager = document.querySelector('extensions-manager'); |
| 19 }); | 20 }); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 var hosted_app = findItemWithName('hosted_app'); | 58 var hosted_app = findItemWithName('hosted_app'); |
| 58 selector = '#' + hosted_app.data.id; | 59 selector = '#' + hosted_app.data.id; |
| 59 testVisible(selector, true) | 60 testVisible(selector, true) |
| 60 expectTrue(!!manager.$$('#websites-list').querySelector(selector)); | 61 expectTrue(!!manager.$$('#websites-list').querySelector(selector)); |
| 61 | 62 |
| 62 var packaged_app = findItemWithName('Packaged App Test'); | 63 var packaged_app = findItemWithName('Packaged App Test'); |
| 63 selector = '#' + packaged_app.data.id; | 64 selector = '#' + packaged_app.data.id; |
| 64 testVisible(selector, true) | 65 testVisible(selector, true) |
| 65 expectTrue(!!manager.$$('#websites-list').querySelector(selector)); | 66 expectTrue(!!manager.$$('#websites-list').querySelector(selector)); |
| 66 }); | 67 }); |
| 68 | |
| 69 test(assert(TestNames.ItemOrder), function() { | |
| 70 var extensionsSection = manager.$['extensions-list']; | |
| 71 var service = extensions.Service.getInstance(); | |
| 72 expectEquals(0, extensionsSection.children.length); | |
| 73 | |
| 74 var alphaFromStore = extension_test_util.createExtensionInfo( | |
| 75 {location: 'FROM_STORE', name: 'Alpha', id: 'a'.repeat(32)}); | |
| 76 manager.addItem(alphaFromStore, service); | |
| 77 | |
| 78 expectEquals(1, extensionsSection.children.length); | |
| 79 expectEquals(alphaFromStore.id, extensionsSection.children[0].id); | |
| 80 | |
| 81 var betaUnpacked = extension_test_util.createExtensionInfo( | |
| 82 {location: 'UNPACKED', name: 'Beta', id: 'b'.repeat(32)}); | |
| 83 manager.addItem(betaUnpacked, service); | |
| 84 | |
| 85 expectEquals(2, extensionsSection.children.length); | |
| 86 expectEquals(betaUnpacked.id, extensionsSection.children[0].id); | |
| 87 expectEquals(alphaFromStore.id, extensionsSection.children[1].id); | |
| 88 | |
| 89 var gammaUnpacked = extension_test_util.createExtensionInfo( | |
| 90 {location: 'UNPACKED', name: 'Gamma', id: 'c'.repeat(32)}); | |
| 91 manager.addItem(gammaUnpacked, service); | |
| 92 | |
| 93 expectEquals(3, extensionsSection.children.length); | |
| 94 expectEquals(betaUnpacked.id, extensionsSection.children[0].id); | |
| 95 expectEquals(gammaUnpacked.id, extensionsSection.children[1].id); | |
| 96 expectEquals(alphaFromStore.id, extensionsSection.children[2].id); | |
| 97 | |
| 98 var aaFromStore = extension_test_util.createExtensionInfo( | |
| 99 {location: 'FROM_STORE', name: 'AA', id: 'd'.repeat(32)}); | |
|
michaelpg
2015/11/18 09:08:46
would you mind also adding items like
{location:
Devlin
2015/11/18 17:16:59
Done.
| |
| 100 manager.addItem(aaFromStore, service); | |
| 101 | |
| 102 expectEquals(4, extensionsSection.children.length); | |
| 103 expectEquals(betaUnpacked.id, extensionsSection.children[0].id); | |
| 104 expectEquals(gammaUnpacked.id, extensionsSection.children[1].id); | |
| 105 expectEquals(aaFromStore.id, extensionsSection.children[2].id); | |
| 106 expectEquals(alphaFromStore.id, extensionsSection.children[3].id); | |
| 107 }); | |
| 67 }); | 108 }); |
| 68 } | 109 } |
| 69 | 110 |
| 70 return { | 111 return { |
| 71 registerTests: registerTests, | 112 registerTests: registerTests, |
| 72 TestNames: TestNames, | 113 TestNames: TestNames, |
| 73 }; | 114 }; |
| 74 }); | 115 }); |
| OLD | NEW |