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

Side by Side Diff: chrome/test/data/webui/settings/search_engines_page_test.js

Issue 1836583003: MD Settings: Use paper-dropdown-menu for search engines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change paper-item to div Created 4 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 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 cr.define('settings_search_engines_page', function() { 5 cr.define('settings_search_engines_page', function() {
6 /** 6 /**
7 * A test version of SearchEnginesBrowserProxy. Provides helper methods
8 * for allowing tests to know when a method was called, as well as
9 * specifying mock responses.
10 *
11 * @constructor
12 * @implements {settings.SearchEnginesBrowserProxy}
13 * @extends {settings.TestBrowserProxy}
14 */
15 var TestSearchEnginesBrowserProxy = function() {
16 settings.TestBrowserProxy.call(this, [
17 'getSearchEnginesList',
18 'removeSearchEngine',
19 'searchEngineEditCancelled',
20 'searchEngineEditCompleted',
21 'searchEngineEditStarted',
22 'setDefaultSearchEngine',
23 'validateSearchEngineInput',
24 'manageExtension',
25 'disableExtension',
26 ]);
27
28 /** @private {!SearchEnginesInfo} */
29 this.searchEnginesInfo_ = {defaults: [], others: [], extensions: []};
30 };
31
32 TestSearchEnginesBrowserProxy.prototype = {
33 __proto__: settings.TestBrowserProxy.prototype,
34
35 /** @override */
36 setDefaultSearchEngine: function(modelIndex) {
37 this.methodCalled('setDefaultSearchEngine', modelIndex);
38 },
39
40 /** @override */
41 removeSearchEngine: function(modelIndex) {
42 this.methodCalled('removeSearchEngine', modelIndex);
43 },
44
45 /** @override */
46 searchEngineEditStarted: function(modelIndex) {
47 this.methodCalled('searchEngineEditStarted', modelIndex);
48 },
49
50 /** @override */
51 searchEngineEditCancelled: function() {
52 this.methodCalled('searchEngineEditCancelled');
53 },
54
55 /** @override */
56 searchEngineEditCompleted: function(searchEngine, keyword, queryUrl) {
57 this.methodCalled('searchEngineEditCompleted');
58 },
59
60 /**
61 * Sets the response to be returned by |getSearchEnginesList|.
62 * @param {!SearchEnginesInfo}
63 */
64 setSearchEnginesInfo: function(searchEnginesInfo) {
65 this.searchEnginesInfo_ = searchEnginesInfo;
66 },
67
68 /** @override */
69 getSearchEnginesList: function() {
70 this.methodCalled('getSearchEnginesList');
71 return Promise.resolve(this.searchEnginesInfo_);
72 },
73
74 /** @override */
75 validateSearchEngineInput: function(fieldName, fieldValue) {
76 this.methodCalled('validateSearchEngineInput');
77 return Promise.resolve(true);
78 },
79
80 /** @override */
81 manageExtension: function(extensionId) {
82 this.methodCalled('manageExtension', extensionId);
83 },
84
85 /** @override */
86 disableExtension: function(extensionId) {
87 this.methodCalled('disableExtension', extensionId);
88 },
89 };
90
91 /**
92 * @param {boolean} canBeDefault 7 * @param {boolean} canBeDefault
93 * @param {boolean} canBeEdited 8 * @param {boolean} canBeEdited
94 * @param {boolean} canBeRemoved 9 * @param {boolean} canBeRemoved
95 * @return {!SearchEngine} 10 * @return {!SearchEngine}
96 */ 11 */
97 var createSampleSearchEngine = function( 12 var createSampleSearchEngine = function(
98 canBeDefault, canBeEdited, canBeRemoved) { 13 canBeDefault, canBeEdited, canBeRemoved) {
99 return { 14 return {
100 canBeDefault: canBeDefault, 15 canBeDefault: canBeDefault,
101 canBeEdited: canBeEdited, 16 canBeEdited: canBeEdited,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 }; 49 };
135 }; 50 };
136 51
137 function registerDialogTests() { 52 function registerDialogTests() {
138 suite('AddSearchEngineDialogTests', function() { 53 suite('AddSearchEngineDialogTests', function() {
139 /** @type {?SettingsAddSearchEngineDialog} */ 54 /** @type {?SettingsAddSearchEngineDialog} */
140 var dialog = null; 55 var dialog = null;
141 var browserProxy = null; 56 var browserProxy = null;
142 57
143 setup(function() { 58 setup(function() {
144 browserProxy = new TestSearchEnginesBrowserProxy(); 59 browserProxy = new settings_search.TestSearchEnginesBrowserProxy();
145 settings.SearchEnginesBrowserProxyImpl.instance_ = browserProxy; 60 settings.SearchEnginesBrowserProxyImpl.instance_ = browserProxy;
146 PolymerTest.clearBody(); 61 PolymerTest.clearBody();
147 dialog = document.createElement('settings-search-engine-dialog'); 62 dialog = document.createElement('settings-search-engine-dialog');
148 document.body.appendChild(dialog); 63 document.body.appendChild(dialog);
149 }); 64 });
150 65
151 teardown(function() { dialog.remove(); }); 66 teardown(function() { dialog.remove(); });
152 67
153 // Tests that the dialog calls 'searchEngineEditStarted' and 68 // Tests that the dialog calls 'searchEngineEditStarted' and
154 // 'searchEngineEditCancelled' when closed from the 'x' button. 69 // 'searchEngineEditCancelled' when closed from the 'x' button.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 139 }
225 140
226 function registerSearchEngineEntryTests() { 141 function registerSearchEngineEntryTests() {
227 suite('SearchEngineEntryTests', function() { 142 suite('SearchEngineEntryTests', function() {
228 /** @type {?SettingsSearchEngineEntryElement} */ 143 /** @type {?SettingsSearchEngineEntryElement} */
229 var entry = null; 144 var entry = null;
230 145
231 var browserProxy = null; 146 var browserProxy = null;
232 147
233 setup(function() { 148 setup(function() {
234 browserProxy = new TestSearchEnginesBrowserProxy(); 149 browserProxy = new settings_search.TestSearchEnginesBrowserProxy();
235 settings.SearchEnginesBrowserProxyImpl.instance_ = browserProxy; 150 settings.SearchEnginesBrowserProxyImpl.instance_ = browserProxy;
236 PolymerTest.clearBody(); 151 PolymerTest.clearBody();
237 entry = document.createElement('settings-search-engine-entry'); 152 entry = document.createElement('settings-search-engine-entry');
238 entry.set('engine', createSampleSearchEngine(true, true, true)); 153 entry.set('engine', createSampleSearchEngine(true, true, true));
239 document.body.appendChild(entry); 154 document.body.appendChild(entry);
240 }); 155 });
241 156
242 teardown(function() { entry.remove(); }); 157 teardown(function() { entry.remove(); });
243 158
244 test('Remove_Enabled', function() { 159 test('Remove_Enabled', function() {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 var browserProxy = null; 236 var browserProxy = null;
322 237
323 /** @type {!SearchEnginesInfo} */ 238 /** @type {!SearchEnginesInfo} */
324 var searchEnginesInfo = { 239 var searchEnginesInfo = {
325 defaults: [createSampleSearchEngine()], 240 defaults: [createSampleSearchEngine()],
326 others: [], 241 others: [],
327 extensions: [createSampleOmniboxExtension()], 242 extensions: [createSampleOmniboxExtension()],
328 }; 243 };
329 244
330 setup(function() { 245 setup(function() {
331 browserProxy = new TestSearchEnginesBrowserProxy(); 246 browserProxy = new settings_search.TestSearchEnginesBrowserProxy();
332 browserProxy.setSearchEnginesInfo(searchEnginesInfo); 247 browserProxy.setSearchEnginesInfo(searchEnginesInfo);
333 settings.SearchEnginesBrowserProxyImpl.instance_ = browserProxy; 248 settings.SearchEnginesBrowserProxyImpl.instance_ = browserProxy;
334 PolymerTest.clearBody(); 249 PolymerTest.clearBody();
335 page = document.createElement('settings-search-engines-page'); 250 page = document.createElement('settings-search-engines-page');
336 document.body.appendChild(page); 251 document.body.appendChild(page);
337 }); 252 });
338 253
339 teardown(function() { page.remove(); }); 254 teardown(function() { page.remove(); });
340 255
341 // Tests that the page is querying and displaying search engine info on 256 // Tests that the page is querying and displaying search engine info on
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 296 }
382 297
383 function registerOmniboxExtensionEntryTests() { 298 function registerOmniboxExtensionEntryTests() {
384 suite('OmniboxExtensionEntryTests', function() { 299 suite('OmniboxExtensionEntryTests', function() {
385 /** @type {?SettingsOmniboxExtensionEntryElement} */ 300 /** @type {?SettingsOmniboxExtensionEntryElement} */
386 var entry = null; 301 var entry = null;
387 302
388 var browserProxy = null; 303 var browserProxy = null;
389 304
390 setup(function() { 305 setup(function() {
391 browserProxy = new TestSearchEnginesBrowserProxy(); 306 browserProxy = new settings_search.TestSearchEnginesBrowserProxy();
392 settings.SearchEnginesBrowserProxyImpl.instance_ = browserProxy; 307 settings.SearchEnginesBrowserProxyImpl.instance_ = browserProxy;
393 PolymerTest.clearBody(); 308 PolymerTest.clearBody();
394 entry = document.createElement('settings-omnibox-extension-entry'); 309 entry = document.createElement('settings-omnibox-extension-entry');
395 entry.set('engine', createSampleOmniboxExtension()); 310 entry.set('engine', createSampleOmniboxExtension());
396 document.body.appendChild(entry); 311 document.body.appendChild(entry);
397 }); 312 });
398 313
399 teardown(function() { entry.remove(); }); 314 teardown(function() { entry.remove(); });
400 315
401 test('Manage', function() { 316 test('Manage', function() {
(...skipping 11 matching lines...) Expand all
413 assertTrue(!!disableButton); 328 assertTrue(!!disableButton);
414 MockInteractions.tap(disableButton); 329 MockInteractions.tap(disableButton);
415 return browserProxy.whenCalled('disableExtension').then( 330 return browserProxy.whenCalled('disableExtension').then(
416 function(extensionId) { 331 function(extensionId) {
417 assertEquals(entry.engine.extension.id, extensionId); 332 assertEquals(entry.engine.extension.id, extensionId);
418 }); 333 });
419 }); 334 });
420 }); 335 });
421 } 336 }
422 337
423
424 return { 338 return {
425 registerDialogTests: registerDialogTests, 339 registerTests: function() {
426 registerSearchEngineEntryTests: registerSearchEngineEntryTests, 340 registerDialogTests();
427 registerOmniboxExtensionEntryTests: registerOmniboxExtensionEntryTests, 341 registerSearchEngineEntryTests();
428 registerPageTests: registerPageTests, 342 registerOmniboxExtensionEntryTests();
343 registerPageTests();
344 },
429 }; 345 };
430 }); 346 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/settings/cr_settings_browsertest.js ('k') | chrome/test/data/webui/settings/search_page_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698