| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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(['options_browsertest_base.js']); |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * TestFixture for EditDictionaryOverlay WebUI testing. | 8 * TestFixture for EditDictionaryOverlay WebUI testing. |
| 9 * @extends {testing.Test} | 9 * @extends {testing.Test} |
| 10 * @constructor | 10 * @constructor |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 // Enable when failure is resolved. | 54 // Enable when failure is resolved. |
| 55 // AX_ARIA_10: http://crbug.com/570559 | 55 // AX_ARIA_10: http://crbug.com/570559 |
| 56 this.accessibilityAuditConfig.ignoreSelectors( | 56 this.accessibilityAuditConfig.ignoreSelectors( |
| 57 'unsupportedAriaAttribute', | 57 'unsupportedAriaAttribute', |
| 58 unsupportedAriaAttributeSelectors); | 58 unsupportedAriaAttributeSelectors); |
| 59 }, | 59 }, |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // Verify that users can add and remove words in the dictionary. | 62 // Verify that users can add and remove words in the dictionary. |
| 63 // TODO(crbug.com/657514) Flakes on linux and chromeos too. | |
| 64 GEN('#if defined(OS_LINUX) || defined(OS_CHROMEOS)'); | |
| 65 GEN('#define MAYBE_testAddRemoveWords ' + | |
| 66 'DISABLED_testAddRemoveWords'); | |
| 67 GEN('#else'); | |
| 68 GEN('#define MAYBE_testAddRemoveWords testAddRemoveWords'); | |
| 69 GEN('#endif'); | |
| 70 TEST_F('EditDictionaryWebUITest', 'testAddRemoveWords', function() { | 63 TEST_F('EditDictionaryWebUITest', 'testAddRemoveWords', function() { |
| 71 var testWord = 'foo'; | 64 var testWord = 'foo'; |
| 72 $('language-dictionary-overlay-word-list').querySelector('input').value = | 65 $('language-dictionary-overlay-word-list').querySelector('input').value = |
| 73 testWord; | 66 testWord; |
| 74 | 67 |
| 75 this.mockHandler.expects(once()).addDictionaryWord([testWord]). | 68 this.mockHandler.expects(once()).addDictionaryWord([testWord]). |
| 76 will(callFunction(function() { | 69 will(callFunction(function() { |
| 77 EditDictionaryOverlay.setWordList([testWord]); | 70 EditDictionaryOverlay.setWordList([testWord]); |
| 78 })); | 71 })); |
| 79 var addWordItem = EditDictionaryOverlay.getWordListForTesting().items[0]; | 72 var addWordItem = EditDictionaryOverlay.getWordListForTesting().items[0]; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 searchField.dispatchEvent(new KeyboardEvent('keydown', { | 107 searchField.dispatchEvent(new KeyboardEvent('keydown', { |
| 115 'bubbles': true, | 108 'bubbles': true, |
| 116 'cancelable': true, | 109 'cancelable': true, |
| 117 'key': 'Enter' | 110 'key': 'Enter' |
| 118 })); | 111 })); |
| 119 assertTrue(editDictionaryPage.visible); | 112 assertTrue(editDictionaryPage.visible); |
| 120 }); | 113 }); |
| 121 | 114 |
| 122 // Verify that dictionary shows newly added words that arrived in a | 115 // Verify that dictionary shows newly added words that arrived in a |
| 123 // notification, but ignores duplicate add notifications. | 116 // notification, but ignores duplicate add notifications. |
| 124 // TODO(crbug.com/657514) Flakes on linux and chromeos. | 117 TEST_F('EditDictionaryWebUITest', 'testAddNotification', function() { |
| 125 GEN('#if defined(OS_LINUX) || defined(OS_CHROMEOS)'); | |
| 126 GEN('#define MAYBE_testAddNotification ' + | |
| 127 'DISABLED_testAddNotification'); | |
| 128 GEN('#else'); | |
| 129 GEN('#define MAYBE_testAddNotification testAddNotification'); | |
| 130 GEN('#endif'); | |
| 131 TEST_F('EditDictionaryWebUITest', 'MAYBE_testAddNotification', function() { | |
| 132 // Begin with an empty dictionary. | 118 // Begin with an empty dictionary. |
| 133 EditDictionaryOverlay.setWordList([]); | 119 EditDictionaryOverlay.setWordList([]); |
| 134 expectEquals(1, EditDictionaryOverlay.getWordListForTesting().items.length); | 120 expectEquals(1, EditDictionaryOverlay.getWordListForTesting().items.length); |
| 135 | 121 |
| 136 // User adds word 'foo'. | 122 // User adds word 'foo'. |
| 137 EditDictionaryOverlay.getWordListForTesting().addDictionaryWord_('foo'); | 123 EditDictionaryOverlay.getWordListForTesting().addDictionaryWord_('foo'); |
| 138 expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length); | 124 expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length); |
| 139 | 125 |
| 140 // Backend notifies UI that the word 'foo' has been added. UI ignores this | 126 // Backend notifies UI that the word 'foo' has been added. UI ignores this |
| 141 // notification, because the word is displayed immediately after user added | 127 // notification, because the word is displayed immediately after user added |
| 142 // it. | 128 // it. |
| 143 EditDictionaryOverlay.updateWords(['foo'], []); | 129 EditDictionaryOverlay.updateWords(['foo'], []); |
| 144 expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length); | 130 expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length); |
| 145 | 131 |
| 146 // Backend notifies UI that the words 'bar' and 'baz' were added. UI shows | 132 // Backend notifies UI that the words 'bar' and 'baz' were added. UI shows |
| 147 // these new words. | 133 // these new words. |
| 148 EditDictionaryOverlay.updateWords(['bar', 'baz'], []); | 134 EditDictionaryOverlay.updateWords(['bar', 'baz'], []); |
| 149 expectEquals(4, EditDictionaryOverlay.getWordListForTesting().items.length); | 135 expectEquals(4, EditDictionaryOverlay.getWordListForTesting().items.length); |
| 150 }); | 136 }); |
| 151 | 137 |
| 152 // Verify that dictionary hides newly removed words that arrived in a | 138 // Verify that dictionary hides newly removed words that arrived in a |
| 153 // notification, but ignores duplicate remove notifications. | 139 // notification, but ignores duplicate remove notifications. |
| 154 // TODO(crbug.com/631940): Flaky on Win 7. | 140 // TODO(crbug.com/631940): Flaky on Win 7. |
| 155 // TODO(crbug.com/657514) Flakes on linux and chromeos too. | 141 GEN('#if defined(OS_WIN)'); |
| 156 GEN('#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS)'); | |
| 157 GEN('#define MAYBE_testRemoveNotification DISABLED_testRemoveNotification'); | 142 GEN('#define MAYBE_testRemoveNotification DISABLED_testRemoveNotification'); |
| 158 GEN('#else'); | 143 GEN('#else'); |
| 159 GEN('#define MAYBE_testRemoveNotification testRemoveNotification'); | 144 GEN('#define MAYBE_testRemoveNotification testRemoveNotification'); |
| 160 GEN('#endif // defined(OS_WIN)'); | 145 GEN('#endif // defined(OS_WIN)'); |
| 161 TEST_F('EditDictionaryWebUITest', 'MAYBE_testRemoveNotification', function() { | 146 TEST_F('EditDictionaryWebUITest', 'MAYBE_testRemoveNotification', function() { |
| 162 // Begin with a dictionary with words 'foo', 'bar', 'baz', and 'baz'. The | 147 // Begin with a dictionary with words 'foo', 'bar', 'baz', and 'baz'. The |
| 163 // second instance of 'baz' appears because the user added the word twice. | 148 // second instance of 'baz' appears because the user added the word twice. |
| 164 // The backend keeps only one copy of the word. | 149 // The backend keeps only one copy of the word. |
| 165 EditDictionaryOverlay.setWordList(['foo', 'bar', 'baz', 'baz']); | 150 EditDictionaryOverlay.setWordList(['foo', 'bar', 'baz', 'baz']); |
| 166 expectEquals(5, EditDictionaryOverlay.getWordListForTesting().items.length); | 151 expectEquals(5, EditDictionaryOverlay.getWordListForTesting().items.length); |
| 167 | 152 |
| 168 // User deletes the second instance of 'baz'. | 153 // User deletes the second instance of 'baz'. |
| 169 EditDictionaryOverlay.getWordListForTesting().deleteItemAtIndex(3); | 154 EditDictionaryOverlay.getWordListForTesting().deleteItemAtIndex(3); |
| 170 expectEquals(4, EditDictionaryOverlay.getWordListForTesting().items.length); | 155 expectEquals(4, EditDictionaryOverlay.getWordListForTesting().items.length); |
| 171 | 156 |
| 172 // Backend notifies UI that the word 'baz' has been removed. UI ignores this | 157 // Backend notifies UI that the word 'baz' has been removed. UI ignores this |
| 173 // notification. | 158 // notification. |
| 174 EditDictionaryOverlay.updateWords([], ['baz']); | 159 EditDictionaryOverlay.updateWords([], ['baz']); |
| 175 expectEquals(4, EditDictionaryOverlay.getWordListForTesting().items.length); | 160 expectEquals(4, EditDictionaryOverlay.getWordListForTesting().items.length); |
| 176 | 161 |
| 177 // Backend notifies UI that words 'foo' and 'bar' have been removed. UI | 162 // Backend notifies UI that words 'foo' and 'bar' have been removed. UI |
| 178 // removes these words. | 163 // removes these words. |
| 179 EditDictionaryOverlay.updateWords([], ['foo', 'bar']); | 164 EditDictionaryOverlay.updateWords([], ['foo', 'bar']); |
| 180 expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length); | 165 expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length); |
| 181 }); | 166 }); |
| OLD | NEW |