| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 GEN_INCLUDE(['options_browsertest_base.js']); |
| 5 GEN('#include "chrome/browser/ui/webui/options/' + | 6 GEN('#include "chrome/browser/ui/webui/options/' + |
| 6 'multilanguage_options_browsertest.h"'); | 7 'multilanguage_options_browsertest.h"'); |
| 7 | 8 |
| 8 /** | 9 /** |
| 9 * Test C++ fixture for Language Options WebUI testing. | 10 * Test C++ fixture for Language Options WebUI testing. |
| 10 * @constructor | 11 * @constructor |
| 11 * @extends {testing.Test} | 12 * @extends {testing.Test} |
| 12 */ | 13 */ |
| 13 function MultilanguageOptionsWebUIBrowserTest() {} | 14 function MultilanguageOptionsWebUIBrowserTest() {} |
| 14 | 15 |
| 15 MultilanguageOptionsWebUIBrowserTest.prototype = { | 16 MultilanguageOptionsWebUIBrowserTest.prototype = { |
| 16 __proto__: testing.Test.prototype, | 17 __proto__: OptionsBrowsertestBase.prototype, |
| 17 | 18 |
| 18 /** @override */ | 19 /** @override */ |
| 19 browsePreload: 'chrome://settings-frame/languages', | 20 browsePreload: 'chrome://settings-frame/languages', |
| 20 | 21 |
| 21 /** @override */ | 22 /** @override */ |
| 22 typedefCppFixture: 'MultilanguageOptionsBrowserTest', | 23 typedefCppFixture: 'MultilanguageOptionsBrowserTest', |
| 23 | 24 |
| 24 /** @override */ | 25 /** @override */ |
| 25 accessibilityIssuesAreErrors: true, | 26 accessibilityIssuesAreErrors: true, |
| 26 | 27 |
| 27 /** @param {string} expected Sorted currently selected languages. */ | 28 /** @param {string} expected Sorted currently selected languages. */ |
| 28 expectCurrentlySelected: function(expected) { | 29 expectCurrentlySelected: function(expected) { |
| 29 var languages = LanguageOptions.getInstance().spellCheckLanguages_; | 30 var languages = LanguageOptions.getInstance().spellCheckLanguages_; |
| 30 expectEquals(expected, Object.keys(languages).sort().join()); | 31 expectEquals(expected, Object.keys(languages).sort().join()); |
| 31 }, | 32 }, |
| 32 | 33 |
| 33 /** @override */ | 34 /** @override */ |
| 34 setUp: function() { | 35 setUp: function() { |
| 35 testing.Test.prototype.setUp.call(this); | 36 OptionsBrowsertestBase.prototype.setUp.call(this); |
| 36 | 37 |
| 37 assertTrue(loadTimeData.getBoolean('enableMultilingualSpellChecker')); | 38 assertTrue(loadTimeData.getBoolean('enableMultilingualSpellChecker')); |
| 38 assertFalse(cr.isMac); | 39 assertFalse(cr.isMac); |
| 39 expectTrue($('spellcheck-language-button').hidden); | 40 expectTrue($('spellcheck-language-button').hidden); |
| 40 expectFalse($('edit-custom-dictionary-button').hidden); | 41 expectFalse($('edit-custom-dictionary-button').hidden); |
| 41 this.expectEnableSpellcheckCheckboxHidden(); | 42 this.expectEnableSpellcheckCheckboxHidden(); |
| 42 this.expectCurrentlySelected('fr'); | 43 this.expectCurrentlySelected('fr'); |
| 44 |
| 45 var requiredOwnedAriaRoleMissingSelectors = [ |
| 46 '#default-search-engine-list', |
| 47 '#other-search-engine-list', |
| 48 ]; |
| 49 |
| 50 // Enable when failure is resolved. |
| 51 // AX_ARIA_08: http://crbug.com/559320 |
| 52 this.accessibilityAuditConfig.ignoreSelectors( |
| 53 'requiredOwnedAriaRoleMissing', |
| 54 requiredOwnedAriaRoleMissingSelectors); |
| 55 |
| 56 // Enable when failure is resolved. |
| 57 // AX_ARIA_10: http://crbug.com/559266 |
| 58 this.accessibilityAuditConfig.ignoreSelectors( |
| 59 'unsupportedAriaAttribute', |
| 60 '#language-options-list'); |
| 61 |
| 62 // Enable when failure is resolved. |
| 63 // AX_TEXT_04: http://crbug.com/559271 |
| 64 this.accessibilityAuditConfig.ignoreSelectors( |
| 65 'linkWithUnclearPurpose', |
| 66 '#languagePage > .content-area > .language-options-header > A'); |
| 43 }, | 67 }, |
| 44 | 68 |
| 45 /** @override */ | 69 /** @override */ |
| 46 tearDown: function() { | 70 tearDown: function() { |
| 47 testing.Test.prototype.tearDown.call(this); | 71 testing.Test.prototype.tearDown.call(this); |
| 48 this.expectEnableSpellcheckCheckboxHidden(); | 72 this.expectEnableSpellcheckCheckboxHidden(); |
| 49 }, | 73 }, |
| 50 | 74 |
| 51 /** Make sure the 'Enable spell checking' checkbox is not visible. */ | 75 /** Make sure the 'Enable spell checking' checkbox is not visible. */ |
| 52 expectEnableSpellcheckCheckboxHidden: function() { | 76 expectEnableSpellcheckCheckboxHidden: function() { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 * Watch for a change to the preference |pref| and then call |callback|. | 157 * Watch for a change to the preference |pref| and then call |callback|. |
| 134 * @param {string} pref The preference to listen for a change on. | 158 * @param {string} pref The preference to listen for a change on. |
| 135 * @param {function} callback The function to run after a listener event. | 159 * @param {function} callback The function to run after a listener event. |
| 136 */ | 160 */ |
| 137 addPreferenceListener: function(pref, callback) { | 161 addPreferenceListener: function(pref, callback) { |
| 138 options.Preferences.getInstance().addEventListener(pref, callback); | 162 options.Preferences.getInstance().addEventListener(pref, callback); |
| 139 }, | 163 }, |
| 140 | 164 |
| 141 /** @override */ | 165 /** @override */ |
| 142 setUp: function() { | 166 setUp: function() { |
| 143 testing.Test.prototype.setUp.call(this); | 167 OptionsBrowsertestBase.prototype.setUp.call(this); |
| 144 | 168 |
| 145 assertTrue(loadTimeData.getBoolean('enableMultilingualSpellChecker')); | 169 assertTrue(loadTimeData.getBoolean('enableMultilingualSpellChecker')); |
| 146 assertFalse(cr.isMac); | 170 assertFalse(cr.isMac); |
| 147 expectTrue($('spellcheck-language-button').hidden); | 171 expectTrue($('spellcheck-language-button').hidden); |
| 148 expectTrue($('edit-custom-dictionary-button').hidden); | 172 expectTrue($('edit-custom-dictionary-button').hidden); |
| 149 this.expectEnableSpellcheckCheckboxHidden(); | 173 this.expectEnableSpellcheckCheckboxHidden(); |
| 150 this.expectCurrentlySelected(''); | 174 this.expectCurrentlySelected(''); |
| 151 this.expectRegisteredDictionariesPref(''); | 175 this.expectRegisteredDictionariesPref(''); |
| 176 |
| 177 // Enable when failure is resolved. |
| 178 // AX_ARIA_10: http://crbug.com/559266 |
| 179 this.accessibilityAuditConfig.ignoreSelectors( |
| 180 'unsupportedAriaAttribute', |
| 181 '#language-options-list'); |
| 182 |
| 183 // Enable when failure is resolved. |
| 184 // AX_TEXT_04: http://crbug.com/559271 |
| 185 this.accessibilityAuditConfig.ignoreSelectors( |
| 186 'linkWithUnclearPurpose', |
| 187 '#languagePage > .content-area > .language-options-header > A'); |
| 152 }, | 188 }, |
| 153 }; | 189 }; |
| 154 | 190 |
| 155 // Make sure the case where no languages are selected is handled properly. | 191 // Make sure the case where no languages are selected is handled properly. |
| 156 TEST_F('MultilanguagePreferenceWebUIBrowserTest', 'SelectFromBlank', | 192 TEST_F('MultilanguagePreferenceWebUIBrowserTest', 'SelectFromBlank', |
| 157 function() { | 193 function() { |
| 158 expectTrue($('language-options-list').selectLanguageByCode('fr')); | 194 expectTrue($('language-options-list').selectLanguageByCode('fr')); |
| 159 expectFalse($('spellcheck-language-checkbox').checked, 'fr'); | 195 expectFalse($('spellcheck-language-checkbox').checked, 'fr'); |
| 160 expectTrue($('edit-custom-dictionary-button').hidden); | 196 expectTrue($('edit-custom-dictionary-button').hidden); |
| 161 | 197 |
| 162 // Add a preference change event listener which ensures that the preference is | 198 // Add a preference change event listener which ensures that the preference is |
| 163 // updated correctly and that 'fr' is the only thing in the dictionary object. | 199 // updated correctly and that 'fr' is the only thing in the dictionary object. |
| 164 this.addPreferenceListener('spellcheck.dictionaries', function() { | 200 this.addPreferenceListener('spellcheck.dictionaries', function() { |
| 165 expectTrue($('spellcheck-language-checkbox').checked, 'fr'); | 201 expectTrue($('spellcheck-language-checkbox').checked, 'fr'); |
| 166 this.expectRegisteredDictionariesPref('fr'); | 202 this.expectRegisteredDictionariesPref('fr'); |
| 167 this.expectCurrentlySelected('fr'); | 203 this.expectCurrentlySelected('fr'); |
| 168 expectFalse($('edit-custom-dictionary-button').hidden); | 204 expectFalse($('edit-custom-dictionary-button').hidden); |
| 169 testDone(); | 205 testDone(); |
| 170 }.bind(this)); | 206 }.bind(this)); |
| 171 | 207 |
| 172 // Click 'fr' and trigger the preference listener. | 208 // Click 'fr' and trigger the preference listener. |
| 173 $('spellcheck-language-checkbox').click(); | 209 $('spellcheck-language-checkbox').click(); |
| 174 }); | 210 }); |
| OLD | NEW |