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