Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_settings_browsertest.js

Issue 1049483003: [Extensions] Update extensions UI to observe events and add test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // TODO(dbeam): test for loading upacked extensions? 5 // TODO(dbeam): test for loading upacked extensions?
6 6
7 GEN('#include "chrome/browser/ui/webui/extensions/' + 7 GEN('#include "chrome/browser/ui/webui/extensions/' +
8 'extension_settings_browsertest.h"'); 8 'extension_settings_browsertest.h"');
9 9
10 // chrome/test/data/extensions/good.crx's extension ID. good.crx is loaded by 10 // chrome/test/data/extensions/good.crx's extension ID. good.crx is loaded by
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 assertEquals(this.browsePreload, document.location.href); 49 assertEquals(this.browsePreload, document.location.href);
50 50
51 // This dialog should be hidden at first. 51 // This dialog should be hidden at first.
52 assertFalse($('pack-extension-overlay').classList.contains('showing')); 52 assertFalse($('pack-extension-overlay').classList.contains('showing'));
53 53
54 // Show the dialog, which triggers a chrome.send() for metrics purposes. 54 // Show the dialog, which triggers a chrome.send() for metrics purposes.
55 cr.dispatchSimpleEvent($('pack-extension'), 'click'); 55 cr.dispatchSimpleEvent($('pack-extension'), 'click');
56 assertTrue($('pack-extension-overlay').classList.contains('showing')); 56 assertTrue($('pack-extension-overlay').classList.contains('showing'));
57 }); 57 });
58 58
59 function BasicExtensionSettingsWebUITest() {}
60
61 BasicExtensionSettingsWebUITest.prototype = {
62 __proto__: ExtensionSettingsWebUITest.prototype,
63
64 /** @override */
65 isAsync: true,
66
67 /** @override */
68 testGenPreamble: function() {
69 // Install multiple types of extensions to ensure we handle each type.
70 // TODO(devlin): There are more types to add here.
71 GEN(' InstallGoodExtension();');
72 GEN(' InstallErrorsExtension();');
73 GEN(' InstallSharedModule();');
74 GEN(' InstallPackagedApp();');
75
76 GEN(' SetAutoConfirmUninstall();');
77 },
78
79 /** @protected {Array<!Function>} */
80 steps: [],
81
82 /** @protected */
83 nextStep: function() {
84 assertTrue(this.steps.length > 0);
85 this.steps.shift().bind(this)();
Dan Beam 2015/04/06 23:53:12 .call(this)
Devlin 2015/04/07 16:07:54 Done.
86 },
87
88 /** @protected */
89 waitForPageLoad: function() {
90 extensionList = $('extension-settings-list');
91 extensionList.extensionsUpdated_.then(this.nextStep.bind(this));
92 },
93
94 /** @protected */
95 verifyDisabledWorks: function() {
96 chrome.management.setEnabled(GOOD_CRX_ID, false, function() {
97 var node = $(GOOD_CRX_ID);
Dan Beam 2015/04/06 23:53:12 $ -> getRequiredElement
Devlin 2015/04/07 16:07:54 Done.
98 assertTrue(node != null);
99 assertTrue(node.classList.contains('inactive-extension'));
100 this.nextStep();
101 }.bind(this));
102 },
103
104 /** @protected */
105 verifyEnabledWorks: function() {
106 chrome.management.setEnabled(GOOD_CRX_ID, true, function() {
107 var node = $(GOOD_CRX_ID);
108 assertTrue(node != null);
Dan Beam 2015/04/06 23:53:12 getRequiredElement
Devlin 2015/04/07 16:07:54 Done.
109 assertFalse(node.classList.contains('inactive-extension'));
110 this.nextStep();
111 }.bind(this));
112 },
113
114 /** @protected */
115 verifyUninstallWorks: function() {
116 var next = this.nextStep.bind(this);
117 chrome.test.runWithUserGesture(function() {
118 chrome.management.uninstall(GOOD_CRX_ID, function() {
119 assertEquals(null, $(GOOD_CRX_ID));
120 next();
121 });
122 });
123 },
124 };
125
126 TEST_F('BasicExtensionSettingsWebUITest', 'testDisable', function() {
127 this.steps = [this.waitForPageLoad,
128 this.verifyDisabledWorks,
129 testDone];
130 this.nextStep();
131 });
132
133 TEST_F('BasicExtensionSettingsWebUITest', 'testEnable', function() {
134 this.steps = [this.waitForPageLoad,
135 this.verifyDisabledWorks,
136 this.verifyEnabledWorks,
137 testDone];
138 this.nextStep();
139 });
140
141 TEST_F('BasicExtensionSettingsWebUITest', 'testUninstall', function() {
142 this.steps = [this.waitForPageLoad,
143 this.verifyUninstallWorks,
144 testDone];
145 this.nextStep();
146 });
147
59 function AsyncExtensionSettingsWebUITest() {} 148 function AsyncExtensionSettingsWebUITest() {}
60 149
61 AsyncExtensionSettingsWebUITest.prototype = { 150 AsyncExtensionSettingsWebUITest.prototype = {
62 __proto__: ExtensionSettingsWebUITest.prototype, 151 __proto__: ExtensionSettingsWebUITest.prototype,
63 152
64 /** @override */ 153 /** @override */
65 isAsync: true, 154 isAsync: true,
66 155
67 /** @override */ 156 /** @override */
68 testGenPreamble: function() { 157 testGenPreamble: function() {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 315
227 ExtensionOptionsDialogWebUITest.prototype = { 316 ExtensionOptionsDialogWebUITest.prototype = {
228 __proto__: InstalledExtensionSettingsWebUITest.prototype, 317 __proto__: InstalledExtensionSettingsWebUITest.prototype,
229 318
230 /** @override */ 319 /** @override */
231 browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload + 320 browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload +
232 '?options=' + GOOD_CRX_ID, 321 '?options=' + GOOD_CRX_ID,
233 }; 322 };
234 323
235 TEST_F('ExtensionOptionsDialogWebUITest', 'testAccessibility', runAudit); 324 TEST_F('ExtensionOptionsDialogWebUITest', 'testAccessibility', runAudit);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698