1 // Copyright (c) 2012 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.
6 * TestFixture for testing messages of dictionary download progress in language
8 * @extends {testing.Test}
11 function LanguagesOptionsDictionaryDownloadWebUITest() {}
13 LanguagesOptionsDictionaryDownloadWebUITest.prototype = {
14 __proto__: testing.Test.prototype,
17 * Browse to languages options.
19 browsePreload: 'chrome://settings-frame/languages',
22 * Register a mock dictionary handler.
25 this.makeAndRegisterMockHandler(['retryDictionaryDownload']);
26 this.mockHandler.stubs().retryDictionaryDownload().
27 will(callFunction(function() {
28 options.LanguageOptions.onDictionaryDownloadBegin('en-US');
33 // Verify that dictionary download success shows 'This language is used for
34 // spellchecking' message.
35 TEST_F('LanguagesOptionsDictionaryDownloadWebUITest',
36 'testdictionaryDownloadSuccess',
38 options.LanguageOptions.onDictionaryDownloadSuccess('en-US');
39 expectFalse($('spellcheck-language-message').hidden);
40 expectTrue($('language-options-dictionary-downloading-message').hidden);
41 expectTrue($('language-options-dictionary-download-failed-message').hidden);
43 $('language-options-dictionary-download-fail-help-message').hidden);
46 // Verify that dictionary download in progress shows 'Downloading spell check
48 TEST_F('LanguagesOptionsDictionaryDownloadWebUITest',
49 'testdictionaryDownloadProgress',
51 options.LanguageOptions.onDictionaryDownloadBegin('en-US');
52 expectTrue($('spellcheck-language-message').hidden);
53 expectFalse($('language-options-dictionary-downloading-message').hidden);
54 expectTrue($('language-options-dictionary-download-failed-message').hidden);
56 $('language-options-dictionary-download-fail-help-message').hidden);
59 // Verify that failure in dictionary download shows 'Dictionary download failed'
61 TEST_F('LanguagesOptionsDictionaryDownloadWebUITest',
62 'testdictionaryDownloadFailed',
64 // Clear the failure counter:
65 options.LanguageOptions.onDictionaryDownloadSuccess('en-US');
67 // First failure shows a short error message.
68 options.LanguageOptions.onDictionaryDownloadFailure('en-US');
69 expectTrue($('spellcheck-language-message').hidden);
70 expectTrue($('language-options-dictionary-downloading-message').hidden);
71 expectFalse($('language-options-dictionary-download-failed-message').hidden);
73 $('language-options-dictionary-download-fail-help-message').hidden);
75 // Second and all following failures show a longer error message.
76 options.LanguageOptions.onDictionaryDownloadFailure('en-US');
77 expectTrue($('spellcheck-language-message').hidden);
78 expectTrue($('language-options-dictionary-downloading-message').hidden);
79 expectFalse($('language-options-dictionary-download-failed-message').hidden);
81 $('language-options-dictionary-download-fail-help-message').hidden);
83 options.LanguageOptions.onDictionaryDownloadFailure('en-US');
84 expectTrue($('spellcheck-language-message').hidden);
85 expectTrue($('language-options-dictionary-downloading-message').hidden);
86 expectFalse($('language-options-dictionary-download-failed-message').hidden);
88 $('language-options-dictionary-download-fail-help-message').hidden);
91 // Verify that clicking the retry button calls the handler.
92 TEST_F('LanguagesOptionsDictionaryDownloadWebUITest',
93 'testdictionaryDownloadRetry',
95 this.mockHandler.expects(once()).retryDictionaryDownload().
96 will(callFunction(function() {
97 options.LanguageOptions.onDictionaryDownloadBegin('en-US');
99 options.LanguageOptions.onDictionaryDownloadFailure('en-US');
100 $('dictionary-download-retry-button').click();