OLD | NEW |
(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 // Verify that the option to enable the spelling service is hidden when |
| 51 // multilingual spellchecking is enabled. |
| 52 TEST_F('MultilanguageOptionsWebUIBrowserTest', 'HideSpellingServiceCheckbox', |
| 53 function() { |
| 54 assertTrue(loadTimeData.getBoolean('enableMultilingualSpellChecker')); |
| 55 expectTrue($('spelling-enabled-container').hidden); |
| 56 testDone(); |
| 57 }); |
| 58 |
| 59 // Test that only certain languages can be selected and used for spellchecking. |
| 60 // prefs::kLanguagePreferredLanguages/prefs::kAcceptLanguages is set to |
| 61 // "fr,es,de,en" for the test. |
| 62 TEST_F('MultilanguageOptionsWebUIBrowserTest', 'ChangeSpellcheckLanguages', |
| 63 function() { |
| 64 var langOpts = LanguageOptions.getInstance(); |
| 65 var langs = Object.keys(langOpts.spellCheckLanguages_); |
| 66 |
| 67 // Make sure 'es' exists in the language list and is unchecked. |
| 68 expectTrue($('language-options-list').selectLanguageByCode('es')); |
| 69 LanguageOptions.updateSpellCheckLanguageControls('es'); |
| 70 expectFalse($('spellcheck-language-checkbox').checked, 'es'); |
| 71 |
| 72 // Click 'es' and ensure that its checkbox gets checked. |
| 73 $('spellcheck-language-checkbox').click(); |
| 74 expectTrue($('spellcheck-language-checkbox').checked, 'es'); |
| 75 |
| 76 // Make sure 'fr' stays checked. |
| 77 $('language-options-list').selectLanguageByCode('fr'); |
| 78 LanguageOptions.updateSpellCheckLanguageControls('fr'); |
| 79 expectTrue($('spellcheck-language-checkbox').checked); |
| 80 |
| 81 // Make sure 'fr' and 'es' are the only two languages being spellchecked with. |
| 82 langs = Object.keys(langOpts.spellCheckLanguages_); |
| 83 expectEquals(2, langs.length); |
| 84 expectEquals('fr', langs[0]); |
| 85 expectEquals('es', langs[1]); |
| 86 |
| 87 // Make sure 'fr' exists in the language list and is checked. |
| 88 expectTrue($('language-options-list').selectLanguageByCode('fr')); |
| 89 LanguageOptions.updateSpellCheckLanguageControls('fr'); |
| 90 expectTrue($('spellcheck-language-checkbox').checked); |
| 91 |
| 92 // Click 'fr' and ensure that its checkbox gets unchecked. |
| 93 $('spellcheck-language-checkbox').click(); |
| 94 expectFalse($('spellcheck-language-checkbox').checked); |
| 95 |
| 96 // Make sure 'es' stays checked. |
| 97 $('language-options-list').selectLanguageByCode('es'); |
| 98 LanguageOptions.updateSpellCheckLanguageControls('es'); |
| 99 expectTrue($('spellcheck-language-checkbox').checked); |
| 100 |
| 101 // Make sure es' is the only language being spellchecked with. |
| 102 langs = Object.keys(langOpts.spellCheckLanguages_); |
| 103 expectEquals(1, langs.length); |
| 104 expectEquals('es', langs[0]); |
| 105 }); |
| 106 |
| 107 // Make sure 'am' cannot be selected as a language and 'fr' stays selected. |
| 108 TEST_F('MultilanguageOptionsWebUIBrowserTest', 'NotAcceptLanguage', |
| 109 function() { |
| 110 var langOpts = LanguageOptions.getInstance(); |
| 111 var langs = Object.keys(langOpts.spellCheckLanguages_); |
| 112 |
| 113 // Try to select 'am' from the language list. |
| 114 expectFalse($('language-options-list').selectLanguageByCode('am')); |
| 115 |
| 116 // Make sure 'fr' is still the only thing selected. |
| 117 $('language-options-list').selectLanguageByCode('fr'); |
| 118 expectTrue($('spellcheck-language-checkbox').checked); |
| 119 expectEquals(1, langs.length); |
| 120 expectEquals('fr', langs[0]); |
| 121 }); |
| 122 |
| 123 // Make sure 'en' cannot be selected as a language and 'fr' stays selected. |
| 124 TEST_F('MultilanguageOptionsWebUIBrowserTest', 'UnusableLanguage', |
| 125 function() { |
| 126 var langOpts = LanguageOptions.getInstance(); |
| 127 var langs = Object.keys(langOpts.spellCheckLanguages_); |
| 128 |
| 129 // Try to select 'en' from the language list. |
| 130 expectTrue($('language-options-list').selectLanguageByCode('en')); |
| 131 LanguageOptions.updateSpellCheckLanguageControls('en'); |
| 132 expectTrue($('spellcheck-language-checkbox-container').hidden); |
| 133 expectFalse($('spellcheck-language-checkbox').checked); |
| 134 |
| 135 // Make sure 'fr' is still the only thing selected. |
| 136 expectEquals(1, langs.length); |
| 137 expectEquals('fr', langs[0]); |
| 138 }); |
OLD | NEW |