Chromium Code Reviews| 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 /** | 5 /** |
| 6 * TestFixture for EditDictionaryOverlay WebUI testing. | 6 * TestFixture for EditDictionaryOverlay WebUI testing. |
| 7 * @extends {testing.Test} | 7 * @extends {testing.Test} |
| 8 * @constructor | 8 * @constructor |
| 9 **/ | 9 **/ |
| 10 function EditDictionaryWebUITest() {} | 10 function EditDictionaryWebUITest() {} |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 el.value = value; | 66 el.value = value; |
| 67 cr.dispatchSimpleEvent(el, 'search'); | 67 cr.dispatchSimpleEvent(el, 'search'); |
| 68 }; | 68 }; |
| 69 var searchField = $('language-dictionary-overlay-search-field'); | 69 var searchField = $('language-dictionary-overlay-search-field'); |
| 70 fakeSearchEvent(searchField, 'foo'); | 70 fakeSearchEvent(searchField, 'foo'); |
| 71 expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length); | 71 expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length); |
| 72 | 72 |
| 73 fakeSearchEvent(searchField, ''); | 73 fakeSearchEvent(searchField, ''); |
| 74 expectEquals(3, EditDictionaryOverlay.getWordListForTesting().items.length); | 74 expectEquals(3, EditDictionaryOverlay.getWordListForTesting().items.length); |
| 75 }); | 75 }); |
| 76 | |
| 77 TEST_F('EditDictionaryWebUITest', 'testAddNotification', function() { | |
|
James Hawkins
2013/01/18 21:07:46
nit: Document specifically what each test is testi
please use gerrit instead
2013/01/18 23:34:53
Done.
| |
| 78 // Begin with an empty dictionary. | |
| 79 EditDictionaryOverlay.setWordList([]); | |
| 80 expectEquals(1, EditDictionaryOverlay.getWordListForTesting().items.length); | |
| 81 | |
| 82 // User adds word 'foo'. | |
| 83 EditDictionaryOverlay.getWordListForTesting().addDictionaryWord_('foo'); | |
| 84 expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length); | |
| 85 | |
| 86 // Backend notifies UI that the word 'foo' has been added. UI ignores this | |
| 87 // notification, because the word is displayed immediately after user added | |
| 88 // it. | |
| 89 EditDictionaryOverlay.updateWords(['foo'], []); | |
| 90 expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length); | |
| 91 | |
| 92 // Backend notifies UI that the words 'bar' and 'baz' were added. UI shows | |
| 93 // these new words. | |
| 94 EditDictionaryOverlay.updateWords(['bar', 'baz'], []); | |
| 95 expectEquals(4, EditDictionaryOverlay.getWordListForTesting().items.length); | |
| 96 }); | |
| 97 | |
| 98 TEST_F('EditDictionaryWebUITest', 'testRemoveNotification', function() { | |
| 99 // Begin with a dictionary with words 'foo', 'bar', 'baz', and 'baz'. The | |
| 100 // second instance of 'baz' appears because the user added the word twice. | |
| 101 // The backend keeps only one copy of the word. | |
| 102 EditDictionaryOverlay.setWordList(['foo', 'bar', 'baz', 'baz']); | |
| 103 expectEquals(5, EditDictionaryOverlay.getWordListForTesting().items.length); | |
| 104 | |
| 105 // User deletes the second instance of 'baz'. | |
| 106 EditDictionaryOverlay.getWordListForTesting().deleteItemAtIndex(3); | |
| 107 expectEquals(4, EditDictionaryOverlay.getWordListForTesting().items.length); | |
| 108 | |
| 109 // Backend notifies UI that the word 'baz' has been removed. UI ignores this | |
| 110 // notification. | |
| 111 EditDictionaryOverlay.updateWords([], ['baz']); | |
| 112 expectEquals(4, EditDictionaryOverlay.getWordListForTesting().items.length); | |
| 113 | |
| 114 // Backend notifies UI that words 'foo' and 'bar' have been removed. UI | |
| 115 // removes these words. | |
| 116 EditDictionaryOverlay.updateWords([], ['foo', 'bar']); | |
| 117 expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length); | |
| 118 }); | |
| OLD | NEW |