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

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

Issue 2366783002: MD Settings: Search engine dialog, tweak logic to show "input invalid". (Closed)
Patch Set: Undo Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/settings/search_engines_page/search_engine_dialog.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/settings/search_engines_page_test.js
diff --git a/chrome/test/data/webui/settings/search_engines_page_test.js b/chrome/test/data/webui/settings/search_engines_page_test.js
index 25a29918af0fb93f24242095e3953c6fc9f29b42..0aaa26daabffacc25658cd32c1c5ce85fcbacbb8 100644
--- a/chrome/test/data/webui/settings/search_engines_page_test.js
+++ b/chrome/test/data/webui/settings/search_engines_page_test.js
@@ -88,22 +88,24 @@ cr.define('settings_search_engines_page', function() {
// Tests the dialog to add a new search engine. Specifically
// - paper-input elements are empty initially.
// - action button initially disabled.
- // - validation is triggered on 'focus'. 'change' is not teted because
- // MockInteractions does not currently provide a way to trigger such
- // events.
+ // - validation is triggered on 'input' event.
// - action button is enabled when all fields are valid.
// - action button triggers appropriate browser signal when tapped.
test('DialogAddSearchEngine', function() {
/**
- * Focuses the given paper-input element and checks that validation is
- * triggered.
+ * Triggers an 'input' event on the paper-input element and checks that
+ * validation is triggered.
* @param {string} inputId
* @return {!Promise}
*/
- var focusAndValidate = function(inputId) {
+ var inputAndValidate = function(inputId) {
+ var inputElement = dialog.$[inputId];
browserProxy.resetResolver('validateSearchEngineInput');
- MockInteractions.focus(dialog.$[inputId]);
- return browserProxy.whenCalled('validateSearchEngineInput');
+ inputElement.fire('input');
+ return inputElement.value != '' ?
+ // Expeting validation only on non-empty values.
+ browserProxy.whenCalled('validateSearchEngineInput') :
+ Promise.resolve();
};
assertEquals('', dialog.$.searchEngine.value);
@@ -112,20 +114,17 @@ cr.define('settings_search_engines_page', function() {
var actionButton = dialog.$.actionButton;
assertTrue(actionButton.disabled);
- return focusAndValidate('searchEngine').then(function() {
- return focusAndValidate('keyword');
+ return inputAndValidate('searchEngine').then(function() {
+ return inputAndValidate('keyword');
}).then(function() {
- return focusAndValidate('queryUrl');
+ return inputAndValidate('queryUrl');
}).then(function() {
// Manually set the text to a non-empty string for all fields.
dialog.$.searchEngine.value = 'foo';
dialog.$.keyword.value = 'bar';
dialog.$.queryUrl.value = 'baz';
- // MockInteractions does not provide a way to trigger a 'change' event
- // yet. Triggering the 'focus' event instead, to update the state of
- // the action button.
- return focusAndValidate('searchEngine');
+ return inputAndValidate('searchEngine');
}).then(function() {
// Assert that the action button has been enabled now that all input
// is valid and non-empty.
« no previous file with comments | « chrome/browser/resources/settings/search_engines_page/search_engine_dialog.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698