Commit bfbf7940 authored by Demetrios Papadopoulos's avatar Demetrios Papadopoulos Committed by Commit Bot

Settings: Remove unnecessary wrapper functions in search engines tests.

Specifically removing:
 - cr.define wrapper
 - registerDialogTests
 - registerSearchEngineEntryTests,
 - registerOmniboxExtensionEntryTests,
 - registerPageTests

In preparation of migrating to Polymer 3.

Bug: 1026426
Change-Id: Ida9a6a4201f970d20475a0a5861702c6e5531eed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036637
Auto-Submit: Demetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738017}
parent 0080c863
......@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.define('settings_search_engines_page', function() {
/**
/**
* @param {number} id
* @param {string} name
* @param {boolean} canBeDefault
......@@ -11,7 +10,7 @@ cr.define('settings_search_engines_page', function() {
* @param {boolean} canBeRemoved
* @return {!SearchEngine}
*/
function createSampleSearchEngine(
function createSampleSearchEngine(
id, name, canBeDefault, canBeEdited, canBeRemoved) {
return {
canBeDefault: canBeDefault,
......@@ -28,10 +27,10 @@ cr.define('settings_search_engines_page', function() {
url: 'https://' + name + '.com/search?p=%s',
urlLocked: false,
};
}
}
/** @return {!SearchEngine} */
function createSampleOmniboxExtension() {
/** @return {!SearchEngine} */
function createSampleOmniboxExtension() {
return {
canBeDefault: false,
canBeEdited: false,
......@@ -51,10 +50,9 @@ cr.define('settings_search_engines_page', function() {
url: 'chrome-extension://dummyextensionid/?q=%s',
urlLocked: false
};
}
}
function registerDialogTests() {
suite('AddSearchEngineDialogTests', function() {
suite('AddSearchEngineDialogTests', function() {
/** @type {?SettingsAddSearchEngineDialog} */
let dialog = null;
let browserProxy = null;
......@@ -74,8 +72,7 @@ cr.define('settings_search_engines_page', function() {
// Tests that the dialog calls 'searchEngineEditStarted' and
// 'searchEngineEditCancelled' when closed from the 'cancel' button.
test('DialogOpenAndCancel', function() {
return browserProxy.whenCalled('searchEngineEditStarted')
.then(function() {
return browserProxy.whenCalled('searchEngineEditStarted').then(function() {
dialog.$.cancel.click();
return browserProxy.whenCalled('searchEngineEditCancelled');
});
......@@ -134,8 +131,7 @@ cr.define('settings_search_engines_page', function() {
});
test('DialogCloseWhenEnginesChangedModelEngineNotFound', function() {
dialog.set(
'model', createSampleSearchEngine(0, 'G', false, false, false));
dialog.set('model', createSampleSearchEngine(0, 'G', false, false, false));
cr.webUIListenerCallback('search-engines-changed', {
defaults: [],
others: [createSampleSearchEngine(1, 'H', false, false, false)],
......@@ -145,8 +141,7 @@ cr.define('settings_search_engines_page', function() {
});
test('DialogValidateInputsWhenEnginesChanged', function() {
dialog.set(
'model', createSampleSearchEngine(0, 'G', false, false, false));
dialog.set('model', createSampleSearchEngine(0, 'G', false, false, false));
dialog.set('keyword_', 'G');
cr.webUIListenerCallback('search-engines-changed', {
defaults: [],
......@@ -155,11 +150,9 @@ cr.define('settings_search_engines_page', function() {
});
return browserProxy.whenCalled('validateSearchEngineInput');
});
});
}
});
function registerSearchEngineEntryTests() {
suite('SearchEngineEntryTests', function() {
suite('SearchEngineEntryTests', function() {
/** @type {?SettingsSearchEngineEntryElement} */
let entry = null;
......@@ -192,8 +185,7 @@ cr.define('settings_search_engines_page', function() {
searchEngine.keyword,
entry.root.querySelector('#keyword-column').textContent);
assertEquals(
searchEngine.url,
entry.root.querySelector('#url-column').textContent);
searchEngine.url, entry.root.querySelector('#url-column').textContent);
});
test('Remove_Enabled', function() {
......@@ -287,11 +279,9 @@ cr.define('settings_search_engines_page', function() {
Polymer.dom.flush();
assertFalse(entry.hasAttribute('show-dots_'));
});
});
}
});
function registerPageTests() {
suite('SearchEnginePageTests', function() {
suite('SearchEnginePageTests', function() {
/** @type {?SettingsSearchEnginesPageElement} */
let page = null;
......@@ -299,8 +289,8 @@ cr.define('settings_search_engines_page', function() {
/** @type {!SearchEnginesInfo} */
const searchEnginesInfo = {
defaults: [createSampleSearchEngine(
0, 'search_engine_G', false, false, false)],
defaults:
[createSampleSearchEngine(0, 'search_engine_G', false, false, false)],
others: [
createSampleSearchEngine(1, 'search_engine_B', false, false, false),
createSampleSearchEngine(2, 'search_engine_A', false, false, false),
......@@ -358,10 +348,8 @@ cr.define('settings_search_engines_page', function() {
assertEquals(searchEnginesInfo.others[1].name, othersEntries[0].name);
assertEquals(searchEnginesInfo.others[0].name, othersEntries[1].name);
const extensionEntries =
page.shadowRoot.querySelector('iron-list').items;
assertEquals(
searchEnginesInfo.extensions.length, extensionEntries.length);
const extensionEntries = page.shadowRoot.querySelector('iron-list').items;
assertEquals(searchEnginesInfo.extensions.length, extensionEntries.length);
});
// Test that the "no other search engines" message is shown/hidden as
......@@ -400,8 +388,7 @@ cr.define('settings_search_engines_page', function() {
test('EditSearchEngineDialog', function() {
const engine = searchEnginesInfo.others[0];
page.fire(
'edit-search-engine',
{engine, anchorElement: page.$.addSearchEngine});
'edit-search-engine', {engine, anchorElement: page.$.addSearchEngine});
return browserProxy.whenCalled('searchEngineEditStarted')
.then(modelIndex => {
assertEquals(engine.modelIndex, modelIndex);
......@@ -439,14 +426,13 @@ cr.define('settings_search_engines_page', function() {
return getListItems(1);
}
function assertSearchResults(
defaultsCount, othersCount, extensionsCount) {
function assertSearchResults(defaultsCount, othersCount, extensionsCount) {
assertEquals(defaultsCount, getListItems(0).length);
assertEquals(othersCount, getListItems(1).length);
assertEquals(extensionsCount, getListItems(2).length);
const noResultsElements = Array.from(
page.shadowRoot.querySelectorAll('.no-search-results'));
const noResultsElements =
Array.from(page.shadowRoot.querySelectorAll('.no-search-results'));
assertEquals(defaultsCount > 0, noResultsElements[0].hidden);
assertEquals(othersCount > 0, noResultsElements[1].hidden);
assertEquals(extensionsCount > 0, noResultsElements[2].hidden);
......@@ -484,11 +470,9 @@ cr.define('settings_search_engines_page', function() {
Polymer.dom.flush();
assertSearchResults(0, 0, 1);
});
});
}
});
function registerOmniboxExtensionEntryTests() {
suite('OmniboxExtensionEntryTests', function() {
suite('OmniboxExtensionEntryTests', function() {
/** @type {?SettingsOmniboxExtensionEntryElement} */
let entry = null;
......@@ -529,11 +513,4 @@ cr.define('settings_search_engines_page', function() {
assertEquals(entry.engine.extension.id, extensionId);
});
});
});
}
registerDialogTests();
registerSearchEngineEntryTests();
registerOmniboxExtensionEntryTests();
registerPageTests();
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment