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

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

Issue 2691033008: MD Settings: Display a message when no other search engines exist. (Closed)
Patch Set: Nit Created 3 years, 10 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/browser/ui/webui/settings/md_settings_localized_strings_provider.cc ('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
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 * @param {boolean} canBeDefault 7 * @param {boolean} canBeDefault
8 * @param {boolean} canBeEdited 8 * @param {boolean} canBeEdited
9 * @param {boolean} canBeRemoved 9 * @param {boolean} canBeRemoved
10 * @return {!SearchEngine} 10 * @return {!SearchEngine}
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 extensions: [createSampleOmniboxExtension()], 286 extensions: [createSampleOmniboxExtension()],
287 }; 287 };
288 288
289 setup(function() { 289 setup(function() {
290 browserProxy = new settings_search.TestSearchEnginesBrowserProxy(); 290 browserProxy = new settings_search.TestSearchEnginesBrowserProxy();
291 browserProxy.setSearchEnginesInfo(searchEnginesInfo); 291 browserProxy.setSearchEnginesInfo(searchEnginesInfo);
292 settings.SearchEnginesBrowserProxyImpl.instance_ = browserProxy; 292 settings.SearchEnginesBrowserProxyImpl.instance_ = browserProxy;
293 PolymerTest.clearBody(); 293 PolymerTest.clearBody();
294 page = document.createElement('settings-search-engines-page'); 294 page = document.createElement('settings-search-engines-page');
295 document.body.appendChild(page); 295 document.body.appendChild(page);
296 return browserProxy.whenCalled('getSearchEnginesList');
296 }); 297 });
297 298
298 teardown(function() { page.remove(); }); 299 teardown(function() { page.remove(); });
299 300
300 // Tests that the page is querying and displaying search engine info on 301 // Tests that the page is querying and displaying search engine info on
301 // startup. 302 // startup.
302 test('Initialization', function() { 303 test('Initialization', function() {
303 return browserProxy.whenCalled('getSearchEnginesList').then(function() { 304 var searchEnginesLists = page.shadowRoot.
304 var searchEnginesLists = Polymer.dom(page.shadowRoot). 305 querySelectorAll('settings-search-engines-list');
305 querySelectorAll('settings-search-engines-list'); 306 assertEquals(2, searchEnginesLists.length);
306 assertEquals(2, searchEnginesLists.length);
307 307
308 // Note: iron-list may create hidden children, so test the length 308 // Note: iron-list may create hidden children, so test the length
309 // if IronList.items instead of the child nodes. 309 // if IronList.items instead of the child nodes.
310 Polymer.dom.flush(); 310 Polymer.dom.flush();
311 var defaultsList = searchEnginesLists[0]; 311 var defaultsList = searchEnginesLists[0];
312 var defaultsEntries = Polymer.dom(defaultsList.shadowRoot). 312 var defaultsEntries = Polymer.dom(defaultsList.shadowRoot).
313 querySelector('iron-list').items; 313 querySelector('iron-list').items;
314 assertEquals( 314 assertEquals(
315 searchEnginesInfo.defaults.length, defaultsEntries.length); 315 searchEnginesInfo.defaults.length, defaultsEntries.length);
316 316
317 var othersList = searchEnginesLists[1]; 317 var othersList = searchEnginesLists[1];
318 var othersEntries = Polymer.dom(othersList.shadowRoot). 318 var othersEntries = Polymer.dom(othersList.shadowRoot).
319 querySelector('iron-list').items; 319 querySelector('iron-list').items;
320 assertEquals( 320 assertEquals(
321 searchEnginesInfo.others.length, othersEntries.length); 321 searchEnginesInfo.others.length, othersEntries.length);
322 322
323 var extensionEntries = Polymer.dom(page.shadowRoot). 323 var extensionEntries = Polymer.dom(page.shadowRoot).
324 querySelector('iron-list').items; 324 querySelector('iron-list').items;
325 assertEquals( 325 assertEquals(
326 searchEnginesInfo.extensions.length, extensionEntries.length); 326 searchEnginesInfo.extensions.length, extensionEntries.length);
327 });
328
329 // Test that the "no other search engines" message is shown/hidden as
330 // expected.
331 test('NoOtherSearchEnginesMessage', function() {
332 var message = page.root.querySelector('#noOtherEngines');
333 assertTrue(!!message);
334 assertFalse(message.hasAttribute('hidden'));
335
336 cr.webUIListenerCallback('search-engines-changed', {
337 defaults: [],
338 others: [createSampleSearchEngine()],
339 extensions: [],
327 }); 340 });
341 assertTrue(message.hasAttribute('hidden'));
328 }); 342 });
329 343
330 // Tests that the add search engine dialog opens when the corresponding 344 // Tests that the add search engine dialog opens when the corresponding
331 // button is tapped. 345 // button is tapped.
332 test('AddSearchEngineDialog', function() { 346 test('AddSearchEngineDialog', function() {
333 assertFalse(!!page.$$('settings-search-engine-dialog')); 347 assertFalse(!!page.$$('settings-search-engine-dialog'));
334 var addSearchEngineButton = page.$.addSearchEngine; 348 var addSearchEngineButton = page.$.addSearchEngine;
335 assertTrue(!!addSearchEngineButton); 349 assertTrue(!!addSearchEngineButton);
336 350
337 MockInteractions.tap(addSearchEngineButton); 351 MockInteractions.tap(addSearchEngineButton);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 400
387 return { 401 return {
388 registerTests: function() { 402 registerTests: function() {
389 registerDialogTests(); 403 registerDialogTests();
390 registerSearchEngineEntryTests(); 404 registerSearchEngineEntryTests();
391 registerOmniboxExtensionEntryTests(); 405 registerOmniboxExtensionEntryTests();
392 registerPageTests(); 406 registerPageTests();
393 }, 407 },
394 }; 408 };
395 }); 409 });
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698