| 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 requiredOwnedAriaRoleMissingSelectors.forEach(function(selector) { |
| 53 this.accessibilityAuditConfig.ignoreSelectors( |
| 54 'requiredOwnedAriaRoleMissing', |
| 55 selector); |
| 56 }.bind(this)); |
| 57 |
| 58 // Enable when failure is resolved. |
| 59 // AX_ARIA_10: http://crbug.com/559266 |
| 60 this.accessibilityAuditConfig.ignoreSelectors( |
| 61 'unsupportedAriaAttribute', |
| 62 '#language-options-list'); |
| 63 |
| 64 // Enable when failure is resolved. |
| 65 // AX_TEXT_04: http://crbug.com/559271 |
| 66 this.accessibilityAuditConfig.ignoreSelectors( |
| 67 'linkWithUnclearPurpose', |
| 68 '#languagePage > .content-area > .language-options-header > A'); |
| 43 }, | 69 }, |
| 44 | 70 |
| 45 /** @override */ | 71 /** @override */ |
| 46 tearDown: function() { | 72 tearDown: function() { |
| 47 testing.Test.prototype.tearDown.call(this); | 73 testing.Test.prototype.tearDown.call(this); |
| 48 this.expectEnableSpellcheckCheckboxHidden(); | 74 this.expectEnableSpellcheckCheckboxHidden(); |
| 49 }, | 75 }, |
| 50 | 76 |
| 51 /** Make sure the 'Enable spell checking' checkbox is not visible. */ | 77 /** Make sure the 'Enable spell checking' checkbox is not visible. */ |
| 52 expectEnableSpellcheckCheckboxHidden: function() { | 78 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|. | 159 * Watch for a change to the preference |pref| and then call |callback|. |
| 134 * @param {string} pref The preference to listen for a change on. | 160 * @param {string} pref The preference to listen for a change on. |
| 135 * @param {function} callback The function to run after a listener event. | 161 * @param {function} callback The function to run after a listener event. |
| 136 */ | 162 */ |
| 137 addPreferenceListener: function(pref, callback) { | 163 addPreferenceListener: function(pref, callback) { |
| 138 options.Preferences.getInstance().addEventListener(pref, callback); | 164 options.Preferences.getInstance().addEventListener(pref, callback); |
| 139 }, | 165 }, |
| 140 | 166 |
| 141 /** @override */ | 167 /** @override */ |
| 142 setUp: function() { | 168 setUp: function() { |
| 143 testing.Test.prototype.setUp.call(this); | 169 OptionsBrowsertestBase.prototype.setUp.call(this); |
| 144 | 170 |
| 145 assertTrue(loadTimeData.getBoolean('enableMultilingualSpellChecker')); | 171 assertTrue(loadTimeData.getBoolean('enableMultilingualSpellChecker')); |
| 146 assertFalse(cr.isMac); | 172 assertFalse(cr.isMac); |
| 147 expectTrue($('spellcheck-language-button').hidden); | 173 expectTrue($('spellcheck-language-button').hidden); |
| 148 expectTrue($('edit-custom-dictionary-button').hidden); | 174 expectTrue($('edit-custom-dictionary-button').hidden); |
| 149 this.expectEnableSpellcheckCheckboxHidden(); | 175 this.expectEnableSpellcheckCheckboxHidden(); |
| 150 this.expectCurrentlySelected(''); | 176 this.expectCurrentlySelected(''); |
| 151 this.expectRegisteredDictionariesPref(''); | 177 this.expectRegisteredDictionariesPref(''); |
| 178 |
| 179 // Enable when failure is resolved. |
| 180 // AX_ARIA_10: http://crbug.com/559266 |
| 181 this.accessibilityAuditConfig.ignoreSelectors( |
| 182 'unsupportedAriaAttribute', |
| 183 '#language-options-list'); |
| 184 |
| 185 // Enable when failure is resolved. |
| 186 // AX_TEXT_04: http://crbug.com/559271 |
| 187 this.accessibilityAuditConfig.ignoreSelectors( |
| 188 'linkWithUnclearPurpose', |
| 189 '#languagePage > .content-area > .language-options-header > A'); |
| 152 }, | 190 }, |
| 153 }; | 191 }; |
| 154 | 192 |
| 155 // Make sure the case where no languages are selected is handled properly. | 193 // Make sure the case where no languages are selected is handled properly. |
| 156 TEST_F('MultilanguagePreferenceWebUIBrowserTest', 'SelectFromBlank', | 194 TEST_F('MultilanguagePreferenceWebUIBrowserTest', 'SelectFromBlank', |
| 157 function() { | 195 function() { |
| 158 expectTrue($('language-options-list').selectLanguageByCode('fr')); | 196 expectTrue($('language-options-list').selectLanguageByCode('fr')); |
| 159 expectFalse($('spellcheck-language-checkbox').checked, 'fr'); | 197 expectFalse($('spellcheck-language-checkbox').checked, 'fr'); |
| 160 expectTrue($('edit-custom-dictionary-button').hidden); | 198 expectTrue($('edit-custom-dictionary-button').hidden); |
| 161 | 199 |
| 162 // Add a preference change event listener which ensures that the preference is | 200 // 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. | 201 // updated correctly and that 'fr' is the only thing in the dictionary object. |
| 164 this.addPreferenceListener('spellcheck.dictionaries', function() { | 202 this.addPreferenceListener('spellcheck.dictionaries', function() { |
| 165 expectTrue($('spellcheck-language-checkbox').checked, 'fr'); | 203 expectTrue($('spellcheck-language-checkbox').checked, 'fr'); |
| 166 this.expectRegisteredDictionariesPref('fr'); | 204 this.expectRegisteredDictionariesPref('fr'); |
| 167 this.expectCurrentlySelected('fr'); | 205 this.expectCurrentlySelected('fr'); |
| 168 expectFalse($('edit-custom-dictionary-button').hidden); | 206 expectFalse($('edit-custom-dictionary-button').hidden); |
| 169 testDone(); | 207 testDone(); |
| 170 }.bind(this)); | 208 }.bind(this)); |
| 171 | 209 |
| 172 // Click 'fr' and trigger the preference listener. | 210 // Click 'fr' and trigger the preference listener. |
| 173 $('spellcheck-language-checkbox').click(); | 211 $('spellcheck-language-checkbox').click(); |
| 174 }); | 212 }); |
| OLD | NEW |