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

Side by Side Diff: chrome/test/data/webui/plugins_browsertest.js

Issue 2630443002: Plugins: Remove chrome://plugins (Closed)
Patch Set: remove test Created 3 years, 11 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
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview Tests for chrome://plugins
7 */
8
9 /** @const {string} Path to source root. */
10 var ROOT_PATH = '../../../../';
11
12 /**
13 * Test fixture for testing async methods of cr.js.
14 * @constructor
15 * @extends testing.Test
16 */
17 function PluginsTest() {
18 this.browserProxy = null;
19 this.setupFnResolver = new PromiseResolver();
20 }
21
22 PluginsTest.prototype = {
23 __proto__: testing.Test.prototype,
24
25 /** @override */
26 browsePreload: 'chrome://plugins',
27
28 /** @override */
29 isAsync: true,
30
31 /** @override */
32 runAccessibilityChecks: false,
33
34 /** @override */
35 extraLibraries: [
36 ROOT_PATH + 'third_party/mocha/mocha.js',
37 ROOT_PATH + 'chrome/test/data/webui/mocha_adapter.js',
38 ROOT_PATH + 'ui/webui/resources/js/promise_resolver.js',
39 ROOT_PATH + 'ui/webui/resources/js/cr.js',
40 ROOT_PATH + 'ui/webui/resources/js/util.js',
41 ROOT_PATH + 'chrome/test/data/webui/settings/test_browser_proxy.js',
42 ],
43
44 preLoad: function() {
45 /**
46 * A test browser proxy for the chrome://plugins page.
47 *
48 * @constructor
49 * @extends {TestBrowserProxyBase}
50 */
51 var TestBrowserProxy = function() {
52 settings.TestBrowserProxy.call(this, [
53 'getPluginsData',
54 'getShowDetails',
55 'saveShowDetailsToPrefs',
56 ]);
57
58 this.bindingSet = null;
59
60 /**
61 * The data to be returned by |getPluginsData_|.
62 * @private
63 */
64 this.pluginsData_ = [];
65 };
66
67 TestBrowserProxy.prototype = {
68 __proto__: settings.TestBrowserProxy.prototype,
69
70 getPluginsData: function() {
71 this.methodCalled('getPluginsData');
72 return Promise.resolve({plugins: this.pluginsData_});
73 },
74
75 setPluginsData: function(pluginsData) {
76 this.pluginsData_ = pluginsData;
77 },
78
79 getShowDetails: function() {
80 this.methodCalled('getShowDetails');
81 return Promise.resolve({show_details: false});
82 },
83
84 saveShowDetailsToPrefs: function(expanded) {
85 this.methodCalled('saveShowDetailsToPrefs', expanded);
86 },
87
88 setClientPage: function() {
89 // Nothing to do here.
90 },
91 };
92
93 this.browserProxy = new TestBrowserProxy();
94
95 // A function that is called from chrome://plugins to allow this test to
96 // replace the real Mojo browser proxy with a fake one, before any other
97 // code runs.
98 window.setupFn = function() {
99 return importModules([
100 'mojo/public/js/bindings',
101 'chrome/browser/ui/webui/plugins/plugins.mojom',
102 'content/public/renderer/frame_interfaces',
103 ]).then(function(modules) {
104 var bindings = modules[0];
105 var pluginsMojom = modules[1];
106 var frameInterfaces = modules[2];
107
108 this.browserProxy.bindingSet = new bindings.BindingSet(
109 pluginsMojom.PluginsPageHandler);
110 frameInterfaces.addInterfaceOverrideForTesting(
111 pluginsMojom.PluginsPageHandler.name, function(handle) {
112 this.browserProxy.bindingSet.addBinding(this.browserProxy,
113 handle);
114 }.bind(this));
115 return this.setupFnResolver.promise;
116 }.bind(this));
117 }.bind(this);
118 },
119 };
120
121 TEST_F('PluginsTest', 'Plugins', function() {
122 var browserProxy = this.browserProxy;
123 var setupFnResolver = this.setupFnResolver;
124
125 var fakePluginData = {
126 name: 'Group Name',
127 description: 'description',
128 version: 'version',
129 update_url: 'http://update/',
130 critical: true,
131 enabled_mode: 'enabledByUser',
132 id: 'plugin-name',
133 always_allowed: false,
134 plugin_files: [
135 {
136 path: '/foo/bar/baz/MyPlugin.plugin',
137 name: 'MyPlugin',
138 version: '1.2.3',
139 description: 'My plugin',
140 type: 'BROWSER PLUGIN',
141 mime_types: [
142 {
143 description: 'Foo Media',
144 file_extensions: ['pdf'],
145 mime_type: 'application/x-my-foo'
146 },
147 {
148 description: 'Bar Stuff',
149 file_extensions: ['bar', 'baz'],
150 mime_type: 'application/my-bar'
151 },
152 ],
153 enabled_mode: 'enabledByUser',
154 },
155 ],
156 };
157
158 suite('PluginTest', function() {
159 var EXPECTED_PLUGINS = 2;
160 suiteSetup(function() {
161 browserProxy.setPluginsData([fakePluginData, fakePluginData]);
162 // Allow code being tested to proceed, now that fake data has been set up.
163 setupFnResolver.resolve();
164
165 return Promise.all([
166 browserProxy.whenCalled('getPluginsData'),
167 browserProxy.whenCalled('getShowDetails'),
168 ]);
169 });
170
171 teardown(function() { browserProxy.reset(); });
172
173 test('PluginsUpdated', function() {
174 var plugins = document.querySelectorAll('.plugin');
175 assertEquals(EXPECTED_PLUGINS, plugins.length);
176
177 pageImpl.onPluginsUpdated([fakePluginData]);
178 plugins = document.querySelectorAll('.plugin');
179 assertEquals(1, plugins.length);
180 });
181
182 /**
183 * Test that clicking on the +/- icons results in the expected calls to the
184 * browser.
185 */
186 test('ToggleDetails', function() {
187 var collapseEl = document.querySelector('#collapse');
188 var expandEl = document.querySelector('#expand');
189
190 var clickEvent = new MouseEvent('click', {
191 'view': window, 'bubbles': true, 'cancelable': true
192 });
193
194 assertEquals('none', collapseEl.style.display);
195 assertNotEquals('none', expandEl.style.display);
196
197 expandEl.dispatchEvent(clickEvent);
198 return browserProxy.whenCalled('saveShowDetailsToPrefs').then(
199 function(expanded) {
200 // Booleans are converted to 0/1 by underlying Mojo layers.
201 assertTrue(Boolean(expanded));
202 assertNotEquals('none', collapseEl.style.display);
203 assertEquals('none', expandEl.style.display);
204
205 browserProxy.resetResolver('saveShowDetailsToPrefs');
206 collapseEl.dispatchEvent(clickEvent);
207 return browserProxy.whenCalled('saveShowDetailsToPrefs');
208 }).then(function(expanded) {
209 assertFalse(Boolean(expanded));
210 });
211 });
212 });
213
214 // Run all registered tests.
215 mocha.run();
216 });
OLDNEW
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698