Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: chrome/browser/ui/webui/options/edit_dictionary_browsertest.js

Issue 11445002: Sync user's custom spellcheck dictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add browser tests for dictionary change notifications in settings Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+});

Powered by Google App Engine
This is Rietveld 408576698