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

Unified Diff: chrome/browser/ui/webui/options/multilanguage_options_webui_browsertest.js

Issue 1156473007: Enables the user to select multiple languages for spellchecking (UI) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments, added browsertest, fixed failures. Created 5 years, 6 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
Index: chrome/browser/ui/webui/options/multilanguage_options_webui_browsertest.js
diff --git a/chrome/browser/ui/webui/options/multilanguage_options_webui_browsertest.js b/chrome/browser/ui/webui/options/multilanguage_options_webui_browsertest.js
new file mode 100644
index 0000000000000000000000000000000000000000..941d5aeb4d4f50e5e230b36d2fa658b21dac5730
--- /dev/null
+++ b/chrome/browser/ui/webui/options/multilanguage_options_webui_browsertest.js
@@ -0,0 +1,105 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
please use gerrit instead 2015/06/16 00:31:17 2015
Julius 2015/06/17 00:59:53 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+GEN('#include "chrome/browser/ui/webui/options/multilanguage_options_webui_browsertest.h"');
+
+/**
+ * Test C++ fixture for downloads WebUI testing.
+ * @constructor
+ * @extends {testing.Test}
+ */
+function MultilanguageOptionsWebUIBrowserTest() {}
please use gerrit instead 2015/06/16 00:31:17 Is this necessary?
Julius 2015/06/17 00:59:53 I renamed BaseMultilanguageOptionsWebUIBrowserTest
+
+/**
+ * Base fixture for Downloads WebUI testing.
please use gerrit instead 2015/06/16 00:31:17 This comment is wrong.
Julius 2015/06/17 00:59:53 Done.
+ * @extends {testing.Test}
+ * @constructor
+ */
+function BaseMultilanguageOptionsWebUIBrowserTest() {}
please use gerrit instead 2015/06/16 00:31:17 Will it work to call this MultilanguageOptionsWebU
Julius 2015/06/17 00:59:53 That generates compiler errors. The typedefCppFixt
+
+BaseMultilanguageOptionsWebUIBrowserTest.prototype = {
+ __proto__: testing.Test.prototype,
+
+ /**
+ * Browse to the downloads page & call our preLoad().
please use gerrit instead 2015/06/16 00:31:17 That's not the "downloads" page. Please update the
Julius 2015/06/17 00:59:53 Done.
+ */
+ browsePreload: 'chrome://settings-frame/languages/',
+
+ /** @override */
+ typedefCppFixture: 'MultilanguageOptionsWebUIBrowserTest',
+
+ /** @override */
+ runAccessibilityChecks: true,
+
+ /** @override */
+ accessibilityIssuesAreErrors: true,
+};
+
+// Test opening language options has correct location.
+TEST_F('BaseMultilanguageOptionsWebUIBrowserTest',
+ 'testOpenLanguageOptions',
+ function() {
+ expectEquals(this.browsePreload, document.location.href);
please use gerrit instead 2015/06/16 00:31:17 It's best to use literal expected values in tests,
Julius 2015/06/17 00:59:53 Done.
+});
+
+// Test that only certain languages can be selected and used for spellchecking.
please use gerrit instead 2015/06/16 00:31:17 Specify the value of prefs::kLanguagePreferredLang
Julius 2015/06/17 00:59:53 Done.
+TEST_F('BaseMultilanguageOptionsWebUIBrowserTest',
+ 'languageOptions',
+ function() {
+ expectTrue(loadTimeData.getBoolean('enableMultilingualSpellChecker'));
+ if (!cr.isMac) {
please use gerrit instead 2015/06/16 00:31:17 I agree with Dan that you should assert(!cr.isMac)
Julius 2015/06/17 00:59:53 Done.
+ expectTrue($('spellcheck-language-button').hidden);
+ var langOps = LanguageOptions.getInstance();
+ // Make sure the only language currently selected is 'en-US'.
+ expectEquals('en-US', loadTimeData.getString('currentUiLanguageCode'));
please use gerrit instead 2015/06/16 00:31:17 I don't think you can rely on the UI locale being
Julius 2015/06/17 00:59:53 Done.
+ expectTrue(langOps.spellCheckDictionaries_.hasOwnProperty('en-US'));
+ expectTrue($('language-options-list').selectLanguageByCode('en-US'));
+ expectTrue($('spellcheck-language-checkbox').checked);
+
+ // Click 'es' and ensure that its checkbox gets checked, 'en-US' stays,
+ // checked, and those are the only languages being used for spellchecking.
+ expectTrue($('language-options-list').selectLanguageByCode('es'));
+ LanguageOptions.updateSpellCheckLanguageControls('es');
+ expectFalse($('spellcheck-language-checkbox').checked, 'es');
+ $('spellcheck-language-checkbox').click();
+ expectTrue(langOps.spellCheckDictionaries_.hasOwnProperty('es'));
+ expectTrue($('spellcheck-language-checkbox').checked, 'es');
+ $('language-options-list').selectLanguageByCode('en-US');
+ LanguageOptions.updateSpellCheckLanguageControls('en-US');
+ expectTrue($('spellcheck-language-checkbox').checked);
+ expectTrue(langOps.spellCheckDictionaries_.hasOwnProperty('en-US'));
+ expectTrue(langOps.spellCheckDictionaries_.hasOwnProperty('es'));
+
+ // Check that 'am' cannot be selected as a language and make sure the other
+ // languages stay selected.
+ expectFalse($('language-options-list').selectLanguageByCode('am'));
+ $('language-options-list').selectLanguageByCode('en-US');
+ expectTrue($('spellcheck-language-checkbox').checked);
+ $('language-options-list').selectLanguageByCode('es');
+ expectTrue($('spellcheck-language-checkbox').checked, 'es');
+ expectTrue(langOps.spellCheckDictionaries_.hasOwnProperty('en-US'));
+ expectTrue(langOps.spellCheckDictionaries_.hasOwnProperty('es'));
+ expectFalse(langOps.spellCheckDictionaries_.hasOwnProperty('am'));
+
+ // Click 'en-US' and ensure that its checkbox gets unchecked, 'es' stays,
+ // checked, and that is the only language being used for spellchecking.
+ $('language-options-list').selectLanguageByCode('en-US');
+ LanguageOptions.updateSpellCheckLanguageControls('en-US');
+ expectTrue($('spellcheck-language-checkbox').checked);
+ $('spellcheck-language-checkbox').click();
+ expectFalse(langOps.spellCheckDictionaries_.hasOwnProperty('en-US'));
+ expectFalse($('spellcheck-language-checkbox').checked);
+ $('language-options-list').selectLanguageByCode('es');
+ LanguageOptions.updateSpellCheckLanguageControls('es');
+ expectTrue($('spellcheck-language-checkbox').checked, 'es');
+ expectTrue(langOps.spellCheckDictionaries_.hasOwnProperty('es'));
+
+ // Make sure 'en' cannot be used as a spellchecking language.
+ $('language-options-list').selectLanguageByCode('en');
+ LanguageOptions.updateSpellCheckLanguageControls('en');
+ expectTrue($('spellcheck-language-checkbox-container').hidden);
+ expectFalse($('spellcheck-language-checkbox').checked);
+ expectFalse(langOps.spellCheckDictionaries_.hasOwnProperty('en'));
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698