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

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

Issue 8571005: Add four new sync integration tests for custom search engines. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial upload. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 #include "base/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/search_engines/template_url.h" 6 #include "chrome/browser/search_engines/template_url.h"
7 #include "chrome/browser/search_engines/template_url_service.h" 7 #include "chrome/browser/search_engines/template_url_service.h"
8 #include "chrome/browser/sync/profile_sync_service_harness.h" 8 #include "chrome/browser/sync/profile_sync_service_harness.h"
9 #include "chrome/browser/sync/test/integration/search_engines_helper.h" 9 #include "chrome/browser/sync/test/integration/search_engines_helper.h"
10 #include "chrome/browser/sync/test/integration/sync_test.h" 10 #include "chrome/browser/sync/test/integration/sync_test.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 // Add a few entries. 48 // Add a few entries.
49 for (int i = 0; i < 3; ++i) { 49 for (int i = 0; i < 3; ++i) {
50 AddSearchEngine(0, i); 50 AddSearchEngine(0, i);
51 } 51 }
52 52
53 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 53 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
54 ASSERT_TRUE(AllServicesMatch()); 54 ASSERT_TRUE(AllServicesMatch());
55 } 55 }
56 56
57 // TCM ID - 9011135.
58 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, Duplicates) {
59 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
60 ASSERT_TRUE(AllServicesMatch());
61
62 // Add two entries with the same Name and URL (but different keywords).
63 // Note that we have to change the GUID of the duplicate.
64 AddSearchEngine(0, 0);
65
66 TemplateURL* dupe = CreateTestTemplateURL(0);
67 dupe->set_keyword(ASCIIToUTF16("somethingelse"));
68 dupe->set_sync_guid("newguid");
69 GetServiceForProfile(0)->Add(dupe);
70
71 TemplateURL* verifier_dupe = CreateTestTemplateURL(0);
72 verifier_dupe->set_keyword(ASCIIToUTF16("somethingelse"));
73 verifier_dupe->set_sync_guid("newguid");
74 GetVerifierService()->Add(verifier_dupe);
75
76 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
77 ASSERT_TRUE(AllServicesMatch());
78 }
79
57 // TCM ID - 9004201. 80 // TCM ID - 9004201.
58 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, UpdateKeyword) { 81 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, UpdateKeyword) {
59 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 82 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
60 ASSERT_TRUE(AllServicesMatch()); 83 ASSERT_TRUE(AllServicesMatch());
61 84
62 AddSearchEngine(0, 0); 85 AddSearchEngine(0, 0);
63 86
64 // Change the keyword. 87 // Change the keyword.
65 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 88 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
66 ASSERT_TRUE(AllServicesMatch()); 89 ASSERT_TRUE(AllServicesMatch());
67 90
68 EditSearchEngine(0, "test0", "newkeyword", "test0", "http://www.test0.com/"); 91 EditSearchEngine(0, "test0", "test0", "newkeyword", "http://www.test0.com/");
69 92
70 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 93 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
71 ASSERT_TRUE(AllServicesMatch()); 94 ASSERT_TRUE(AllServicesMatch());
72 } 95 }
73 96
74 // TCM ID - 8894859. 97 // TCM ID - 8894859.
75 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, UpdateUrl) { 98 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, UpdateUrl) {
76 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 99 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
77 ASSERT_TRUE(AllServicesMatch()); 100 ASSERT_TRUE(AllServicesMatch());
78 101
79 AddSearchEngine(0, 0); 102 AddSearchEngine(0, 0);
80 103
81 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 104 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
82 ASSERT_TRUE(AllServicesMatch()); 105 ASSERT_TRUE(AllServicesMatch());
83 106
84 // Change the URL. 107 // Change the URL.
85 EditSearchEngine(0, "test0", "test0", "test0", 108 EditSearchEngine(0, "test0", "test0", "test0",
86 "http://www.wikipedia.org/q=%s"); 109 "http://www.wikipedia.org/q=%s");
87 110
88 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 111 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
89 ASSERT_TRUE(AllServicesMatch()); 112 ASSERT_TRUE(AllServicesMatch());
90 } 113 }
91 114
115 // TCM ID - 8910490.
116 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, UpdateName) {
117 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
118 ASSERT_TRUE(AllServicesMatch());
119
120 AddSearchEngine(0, 0);
121
122 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
123 ASSERT_TRUE(AllServicesMatch());
124
125 // Change the short name.
126 EditSearchEngine(0, "test0", "New Name", "test0", "http://www.test0.com/");
127
128 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
129 ASSERT_TRUE(AllServicesMatch());
130 }
131
92 // TCM ID - 8898660. 132 // TCM ID - 8898660.
93 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, Delete) { 133 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, Delete) {
94 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 134 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
95 ASSERT_TRUE(AllServicesMatch()); 135 ASSERT_TRUE(AllServicesMatch());
96 136
97 AddSearchEngine(0, 0); 137 AddSearchEngine(0, 0);
98 138
99 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 139 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
100 ASSERT_TRUE(AllServicesMatch()); 140 ASSERT_TRUE(AllServicesMatch());
101 141
102 DeleteSearchEngineBySeed(0, 0); 142 DeleteSearchEngineBySeed(0, 0);
103 143
104 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 144 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
105 ASSERT_TRUE(AllServicesMatch()); 145 ASSERT_TRUE(AllServicesMatch());
106 } 146 }
107 147
148 // TCM ID - 9004196.
149 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, ConflictKeyword) {
150 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
151 ASSERT_TRUE(AllServicesMatch());
152
153 // Add a different search engine to each client, but make their keywords
154 // conflict.
155 AddSearchEngine(0, 0);
156 AddSearchEngine(1, 1);
157 const TemplateURL* turl = GetServiceForProfile(1)->
158 GetTemplateURLForKeyword(ASCIIToUTF16("test1"));
159 EXPECT_TRUE(turl);
160 GetServiceForProfile(1)->ResetTemplateURL(turl,
161 turl->short_name(),
162 ASCIIToUTF16("test0"),
163 turl->url()->url());
164
165 // And we expect both to change the search engine created first to the new,
166 // uniquified keyword.
167 EditSearchEngine(-1, "test0", "test0", "test0.com", "http://www.test0.com/");
Raghu Simha 2011/11/16 01:14:41 In general, for tests that involve intentional com
SteveT 2011/11/16 15:43:32 That makes way more sense. Thanks for pointing thi
168 EditSearchEngine(-1, "test1", "test1", "test0", "http://www.test1.com/");
169
170 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
171 ASSERT_TRUE(AllServicesMatch());
172 }
173
174 // TCM ID - 9004187.
175 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, MergeMultiple) {
176 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
177 ASSERT_TRUE(AllServicesMatch());
178
179 // Set up some different search engines on each client, with some interesting
180 // conflicts.
181 // client0: { SE0, SE1, SE2 }
182 for (int i = 0; i < 3; ++i) {
183 AddSearchEngine(0, i);
184 }
185
186 // client1: { SE0, SE2, SE3, SE0 + different URL }
187 // Note that we do not use AddSearchEngine here as we don't want to set up the
188 // verifier just yet.
189 GetServiceForProfile(1)->Add(CreateTestTemplateURL(0));
190 GetServiceForProfile(1)->Add(CreateTestTemplateURL(2));
191 GetServiceForProfile(1)->Add(CreateTestTemplateURL(3));
192 TemplateURL* turl = CreateTestTemplateURL(0);
193 turl->SetURL("http://www.somethingelse.com/", 0, 0);
194 turl->set_keyword(ASCIIToUTF16("somethingelse.com"));
195 turl->set_sync_guid("somethingelse");
196 GetServiceForProfile(1)->Add(turl);
197
198 // verifier: { SE0, SE1, SE2, SE3, SE0 + different URL }
199 // We just have to add 3 and the new 0 since we've added 0-2 above.
200 GetVerifierService()->Add(CreateTestTemplateURL(3));
Raghu Simha 2011/11/16 01:14:41 Same comment as above -- no need to update the ver
SteveT 2011/11/16 15:43:32 Done.
201 turl = CreateTestTemplateURL(0);
202 turl->SetURL("http://www.somethingelse.com/", 0, 0);
203 turl->set_keyword(ASCIIToUTF16("somethingelse.com"));
204 turl->set_sync_guid("somethingelse");
205 GetVerifierService()->Add(turl);
206
207 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
208 ASSERT_TRUE(AllServicesMatch());
209 }
210
108 // TCM ID - 8906436. 211 // TCM ID - 8906436.
109 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, DisableSync) { 212 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, DisableSync) {
110 ASSERT_TRUE(SetupSync()); 213 ASSERT_TRUE(SetupSync());
111 ASSERT_TRUE(AllServicesMatch()); 214 ASSERT_TRUE(AllServicesMatch());
112 215
113 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes()); 216 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes());
114 AddSearchEngine(0, 0); 217 AddSearchEngine(0, 0);
115 ASSERT_TRUE( 218 ASSERT_TRUE(
116 GetClient(0)->AwaitFullSyncCompletion("Added a search engine.")); 219 GetClient(0)->AwaitFullSyncCompletion("Added a search engine."));
117 ASSERT_TRUE(ServiceMatchesVerifier(0)); 220 ASSERT_TRUE(ServiceMatchesVerifier(0));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 256 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
154 ASSERT_TRUE(AllServicesMatch()); 257 ASSERT_TRUE(AllServicesMatch());
155 258
156 // Change the default on the first client and delete the old default. 259 // Change the default on the first client and delete the old default.
157 ChangeDefaultSearchProvider(0, 1); 260 ChangeDefaultSearchProvider(0, 1);
158 DeleteSearchEngineBySeed(0, 0); 261 DeleteSearchEngineBySeed(0, 0);
159 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 262 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
160 263
161 ASSERT_TRUE(AllServicesMatch()); 264 ASSERT_TRUE(AllServicesMatch());
162 } 265 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698