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

Side by Side Diff: chrome/browser/sync/test/integration/two_client_dictionary_sync_test.cc

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 7 years, 11 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/profile_sync_service_harness.h"
6 #include "chrome/browser/sync/test/integration/dictionary_helper.h"
7 #include "chrome/browser/sync/test/integration/sync_test.h"
8
9 class TwoClientDictionarySyncTest : public SyncTest {
10 public:
11 TwoClientDictionarySyncTest() : SyncTest(TWO_CLIENT) {}
12 virtual ~TwoClientDictionarySyncTest() {}
13
14 virtual void AddOptionalTypesToCommandLine(CommandLine* cl) OVERRIDE {
15 dictionary_helper::EnableDictionarySync(cl);
16 }
17
18 private:
19 DISALLOW_COPY_AND_ASSIGN(TwoClientDictionarySyncTest);
20 };
21
22 IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest, Sanity) {
23 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
24 dictionary_helper::LoadDictionaries();
25 ASSERT_TRUE(dictionary_helper::DictionariesMatch());
26
27 std::vector<std::string> words;
28 words.push_back("foo");
29 words.push_back("bar");
30 ASSERT_EQ(num_clients(), static_cast<int>(words.size()));
31
32 for (int i = 0; i < num_clients(); ++i) {
33 ASSERT_TRUE(dictionary_helper::AddWord(i, words[i]));
34 ASSERT_TRUE(GetClient(i)->AwaitMutualSyncCycleCompletion(
35 GetClient((i + 1) % 2)));
36 }
37 ASSERT_TRUE(dictionary_helper::DictionariesMatch());
38 ASSERT_EQ(words.size(), dictionary_helper::GetDictionarySize(0));
39
40 for (int i = 0; i < num_clients(); ++i) {
41 ASSERT_TRUE(dictionary_helper::RemoveWord(i, words[i]));
42 ASSERT_TRUE(GetClient(i)->AwaitMutualSyncCycleCompletion(
43 GetClient((i + 1) % 2)));
44 }
45 ASSERT_TRUE(dictionary_helper::DictionariesMatch());
46 ASSERT_EQ(0UL, dictionary_helper::GetDictionarySize(0));
47
48 DisableVerifier();
49 for (int i = 0; i < num_clients(); ++i)
50 ASSERT_TRUE(dictionary_helper::AddWord(i, words[i]));
51 ASSERT_TRUE(AwaitQuiescence());
52 ASSERT_TRUE(dictionary_helper::DictionariesMatch());
53 ASSERT_EQ(words.size(), dictionary_helper::GetDictionarySize(0));
54
55 MessageLoop::current()->RunUntilIdle();
56 }
57
58 IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest, SimultaneousAdd) {
59 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
60 dictionary_helper::LoadDictionaries();
61 ASSERT_TRUE(dictionary_helper::DictionariesMatch());
62
63 for (int i = 0; i < num_clients(); ++i)
64 dictionary_helper::AddWord(i, "foo");
65 ASSERT_TRUE(AwaitQuiescence());
66 ASSERT_TRUE(dictionary_helper::DictionariesMatch());
67 ASSERT_EQ(1UL, dictionary_helper::GetDictionarySize(0));
68
69 MessageLoop::current()->RunUntilIdle();
70 }
71
72 IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest, SimultaneousRemove) {
73 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
74 dictionary_helper::LoadDictionaries();
75 ASSERT_TRUE(dictionary_helper::DictionariesMatch());
76
77 for (int i = 0; i < num_clients(); ++i)
78 dictionary_helper::AddWord(i, "foo");
79 ASSERT_TRUE(AwaitQuiescence());
80 ASSERT_TRUE(dictionary_helper::DictionariesMatch());
81 ASSERT_EQ(1UL, dictionary_helper::GetDictionarySize(0));
82
83 for (int i = 0; i < num_clients(); ++i)
84 dictionary_helper::RemoveWord(i, "foo");
85 ASSERT_TRUE(AwaitQuiescence());
86 ASSERT_TRUE(dictionary_helper::DictionariesMatch());
87 ASSERT_EQ(0UL, dictionary_helper::GetDictionarySize(0));
88
89 MessageLoop::current()->RunUntilIdle();
90 }
91
92 IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest, RemoveOnAAddOnB) {
93 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
94 dictionary_helper::LoadDictionaries();
95 ASSERT_TRUE(dictionary_helper::DictionariesMatch());
96
97 std::string word = "foo";
98 // Add on client A
99 ASSERT_TRUE(dictionary_helper::AddWord(0, word));
100 // Remove on client A
101 ASSERT_TRUE(dictionary_helper::RemoveWord(0, word));
102 // Add on client B
103 ASSERT_TRUE(dictionary_helper::AddWord(1, word));
104 ASSERT_TRUE(AwaitQuiescence());
105 ASSERT_TRUE(dictionary_helper::DictionariesMatch());
106 ASSERT_EQ(1UL, dictionary_helper::GetDictionarySize(0));
107
108 MessageLoop::current()->RunUntilIdle();
109 }
110
111 IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest, DisableSync) {
112 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
113 dictionary_helper::LoadDictionaries();
114 ASSERT_TRUE(dictionary_helper::DictionariesMatch());
115
116 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes());
117 ASSERT_TRUE(dictionary_helper::AddWord(0, "foo"));
118 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Added a word"));
119 ASSERT_TRUE(dictionary_helper::DictionaryMatchesVerifier(0));
120 ASSERT_FALSE(dictionary_helper::DictionaryMatchesVerifier(1));
121
122 MessageLoop::current()->RunUntilIdle();
123 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698