| Index: chrome/browser/ui/webui/options/edit_dictionary_browsertest.js
|
| diff --git a/chrome/browser/ui/webui/options/edit_dictionary_browsertest.js b/chrome/browser/ui/webui/options/edit_dictionary_browsertest.js
|
| index 0e1522149982debd094ed4bc2b05e5f0b4f740db..f79e8d52690545406501a9c3abfe4e48e44f3586 100644
|
| --- a/chrome/browser/ui/webui/options/edit_dictionary_browsertest.js
|
| +++ b/chrome/browser/ui/webui/options/edit_dictionary_browsertest.js
|
| @@ -73,3 +73,46 @@ TEST_F('EditDictionaryWebUITest', 'testSearch', function() {
|
| fakeSearchEvent(searchField, '');
|
| expectEquals(3, EditDictionaryOverlay.getWordListForTesting().items.length);
|
| });
|
| +
|
| +TEST_F('EditDictionaryWebUITest', 'testAddNotification', function() {
|
| + // Begin with an empty dictionary.
|
| + EditDictionaryOverlay.setWordList([]);
|
| + expectEquals(1, EditDictionaryOverlay.getWordListForTesting().items.length);
|
| +
|
| + // User adds word 'foo'.
|
| + EditDictionaryOverlay.getWordListForTesting().addDictionaryWord_('foo');
|
| + expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length);
|
| +
|
| + // Backend notifies UI that the word 'foo' has been added. UI ignores this
|
| + // notification, because the word is displayed immediately after user added
|
| + // it.
|
| + EditDictionaryOverlay.updateWords(['foo'], []);
|
| + expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length);
|
| +
|
| + // Backend notifies UI that the words 'bar' and 'baz' were added. UI shows
|
| + // these new words.
|
| + EditDictionaryOverlay.updateWords(['bar', 'baz'], []);
|
| + expectEquals(4, EditDictionaryOverlay.getWordListForTesting().items.length);
|
| +});
|
| +
|
| +TEST_F('EditDictionaryWebUITest', 'testRemoveNotification', function() {
|
| + // Begin with a dictionary with words 'foo', 'bar', 'baz', and 'baz'. The
|
| + // second instance of 'baz' appears because the user added the word twice.
|
| + // The backend keeps only one copy of the word.
|
| + EditDictionaryOverlay.setWordList(['foo', 'bar', 'baz', 'baz']);
|
| + expectEquals(5, EditDictionaryOverlay.getWordListForTesting().items.length);
|
| +
|
| + // User deletes the second instance of 'baz'.
|
| + EditDictionaryOverlay.getWordListForTesting().deleteItemAtIndex(3);
|
| + expectEquals(4, EditDictionaryOverlay.getWordListForTesting().items.length);
|
| +
|
| + // Backend notifies UI that the word 'baz' has been removed. UI ignores this
|
| + // notification.
|
| + EditDictionaryOverlay.updateWords([], ['baz']);
|
| + expectEquals(4, EditDictionaryOverlay.getWordListForTesting().items.length);
|
| +
|
| + // Backend notifies UI that words 'foo' and 'bar' have been removed. UI
|
| + // removes these words.
|
| + EditDictionaryOverlay.updateWords([], ['foo', 'bar']);
|
| + expectEquals(2, EditDictionaryOverlay.getWordListForTesting().items.length);
|
| +});
|
|
|