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

Side by Side 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: Fixed some bugs and handled the spelling service. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 GEN('#include "chrome/browser/ui/webui/options/multilanguage_options_webui_brows ertest.h"');
6
7 /**
8 * Test C++ fixture for Language Options WebUI testing.
9 * @constructor
10 * @extends {testing.Test}
11 */
12 function MultilanguageOptionsWebUIBrowserTest() {}
13
14 MultilanguageOptionsWebUIBrowserTest.prototype = {
15 __proto__: testing.Test.prototype,
16
17 /**
18 * Browse to the language options page & call our preLoad().
19 */
20 browsePreload: 'chrome://settings-frame/languages/',
21
22 /** @override */
23 typedefCppFixture: 'MultilanguageOptionsWebUIBrowserTest',
24
25 /** @override */
26 accessibilityIssuesAreErrors: true,
27
28 /** @override */
29 setUp: function() {
30 testing.Test.prototype.setUp.call(this);
31
32 assertTrue(loadTimeData.getBoolean('enableMultilingualSpellChecker'));
33 assertFalse(cr.isMac);
34 expectTrue($('spellcheck-language-button').hidden);
35
36 // Make sure the only language currently selected is 'fr'.
37 var langOpts = LanguageOptions.getInstance();
38 var langs = Object.keys(langOpts.spellCheckLanguages_);
39 expectEquals(1, langs.length);
40 expectEquals('fr', langs[0]);
41 },
42 };
43
44 // Test opening language options has correct location.
45 TEST_F('MultilanguageOptionsWebUIBrowserTest', 'testOpenLanguageOptions',
46 function() {
47 expectEquals('chrome://settings-frame/languages/', document.location.href);
48 });
49
50 // Test that only certain languages can be selected and used for spellchecking.
51 // prefs::kLanguagePreferredLanguages/prefs::kAcceptLanguages is set to
52 // "fr,es,de,en" for the test.
53 TEST_F('MultilanguageOptionsWebUIBrowserTest', 'changeSpellcheckLanguages',
54 function() {
55 var langOpts = LanguageOptions.getInstance();
56 var langs = Object.keys(langOpts.spellCheckLanguages_);
57
58 // Make sure 'es' exists in the language list and is unchecked.
59 expectTrue($('language-options-list').selectLanguageByCode('es'));
60 LanguageOptions.updateSpellCheckLanguageControls('es');
61 expectFalse($('spellcheck-language-checkbox').checked, 'es');
62
63 // Click 'es' and ensure that its checkbox gets checked.
64 $('spellcheck-language-checkbox').click();
65 expectTrue($('spellcheck-language-checkbox').checked, 'es');
66
67 // Make sure 'fr' stays checked.
68 $('language-options-list').selectLanguageByCode('fr');
69 LanguageOptions.updateSpellCheckLanguageControls('fr');
70 expectTrue($('spellcheck-language-checkbox').checked);
71
72 // Make sure 'fr' and 'es' are the only two languages being spellchecked with.
73 langs = Object.keys(langOpts.spellCheckLanguages_);
74 expectEquals(2, langs.length);
75 expectEquals('fr', langs[0]);
76 expectEquals('es', langs[1]);
77
78 // Make sure 'fr' exists in the language list and is checked.
79 expectTrue($('language-options-list').selectLanguageByCode('fr'));
80 LanguageOptions.updateSpellCheckLanguageControls('fr');
81 expectTrue($('spellcheck-language-checkbox').checked);
82
83 // Click 'fr' and ensure that its checkbox gets unchecked.
84 $('spellcheck-language-checkbox').click();
85 expectFalse($('spellcheck-language-checkbox').checked);
86
87 // Make sure 'es' stays checked.
88 $('language-options-list').selectLanguageByCode('es');
89 LanguageOptions.updateSpellCheckLanguageControls('es');
90 expectTrue($('spellcheck-language-checkbox').checked);
91
92 // Make sure es' is the only language being spellchecked with.
93 langs = Object.keys(langOpts.spellCheckLanguages_);
94 expectEquals(1, langs.length);
95 expectEquals('es', langs[0]);
96 });
97
98 // Make sure 'am' cannot be selected as a language and 'fr' stays selected.
99 TEST_F('MultilanguageOptionsWebUIBrowserTest', 'notAcceptLanguage',
100 function() {
101 var langOpts = LanguageOptions.getInstance();
102 var langs = Object.keys(langOpts.spellCheckLanguages_);
103
104 // Try to select 'am' from the language list.
105 expectFalse($('language-options-list').selectLanguageByCode('am'));
106
107 // Make sure 'fr' is still the only thing selected.
108 $('language-options-list').selectLanguageByCode('fr');
109 expectTrue($('spellcheck-language-checkbox').checked);
110 expectEquals(1, langs.length);
111 expectEquals('fr', langs[0]);
112 });
113
114 // Make sure 'en' cannot be selected as a language and 'fr' stays selected.
115 TEST_F('MultilanguageOptionsWebUIBrowserTest', 'unusableLanguage',
116 function() {
117 var langOpts = LanguageOptions.getInstance();
118 var langs = Object.keys(langOpts.spellCheckLanguages_);
119
120 // Try to select 'en' from the language list.
121 expectTrue($('language-options-list').selectLanguageByCode('en'));
122 LanguageOptions.updateSpellCheckLanguageControls('en');
123 expectTrue($('spellcheck-language-checkbox-container').hidden);
124 expectFalse($('spellcheck-language-checkbox').checked);
125
126 // Make sure 'fr' is still the only thing selected.
127 expectEquals(1, langs.length);
128 expectEquals('fr', langs[0]);
129 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698