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

Unified Diff: chrome/test/data/webui/settings/settings_main_test.js

Issue 2449663002: MD Settings: Implement search URLs. (Closed)
Patch Set: Fix test. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/settings/settings_main_test.js
diff --git a/chrome/test/data/webui/settings/settings_main_test.js b/chrome/test/data/webui/settings/settings_main_test.js
index e4af140ca7e78b8623cdce4d7a7150d961294335..177581b8e7471ca1770fe7fb333e12ff0ecdcdef 100644
--- a/chrome/test/data/webui/settings/settings_main_test.js
+++ b/chrome/test/data/webui/settings/settings_main_test.js
@@ -4,9 +4,19 @@
cr.define('settings_main_page', function() {
/**
+ * Extending TestBrowserProxy even though SearchManager is not a browser proxy
+ * itself. Essentially TestBrowserProxy can act as a "proxy" for any external
+ * dependency, not just "browser proxies" (and maybe should be renamed to
+ * TestProxy).
+ *
* @implements {SearchManager}
+ * @extends {settings.TestBrowserProxy}
*/
var TestSearchManager = function() {
+ settings.TestBrowserProxy.call(this, [
+ 'search',
+ ]);
+
/** @private {boolean} */
this.matchesFound_ = true;
@@ -15,6 +25,8 @@ cr.define('settings_main_page', function() {
}
TestSearchManager.prototype = {
+ __proto__: settings.TestBrowserProxy.prototype,
+
/**
* @param {boolean} matchesFound
*/
@@ -24,6 +36,8 @@ cr.define('settings_main_page', function() {
/** @override */
search: function(text, page) {
+ this.methodCalled('search', text);
+
if (this.searchRequest_ == null || !this.searchRequest_.isSame(text)) {
this.searchRequest_ = new settings.SearchRequest(text);
this.searchRequest_.finished = true;
@@ -62,6 +76,34 @@ cr.define('settings_main_page', function() {
teardown(function() { settingsMain.remove(); });
+ test('searchContents() triggers SearchManager', function() {
+ Polymer.dom.flush();
+
+ var expectedQuery1 = 'foo';
+ var expectedQuery2 = 'bar';
+ var expectedQuery3 = '';
+
+ return settingsMain.searchContents(expectedQuery1).then(function() {
+ return searchManager.whenCalled('search');
+ }).then(function(query) {
+ assertEquals(expectedQuery1, query);
+
+ searchManager.resetResolver('search');
+ return settingsMain.searchContents(expectedQuery2);
+ }).then(function() {
+ return searchManager.whenCalled('search');
+ }).then(function(query) {
+ assertEquals(expectedQuery2, query);
+
+ searchManager.resetResolver('search');
+ return settingsMain.searchContents(expectedQuery3);
+ }).then(function() {
+ return searchManager.whenCalled('search');
+ }).then(function(query) {
+ assertEquals(expectedQuery3, query);
+ });
+ });
+
test('no results page shows and hides', function() {
Polymer.dom.flush();
var noSearchResults = settingsMain.$.noSearchResults;
« no previous file with comments | « chrome/test/data/webui/settings/cr_settings_browsertest.js ('k') | chrome/test/data/webui/settings/settings_ui_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698