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

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

Issue 2379433002: [Sync] Refactoring of sync integration test checkers to remove boilerplate await methods. (Closed)
Patch Set: Rebase Created 4 years, 2 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
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 #include "base/macros.h" 5 #include "base/macros.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/search_engines/template_url_service_factory.h" 7 #include "chrome/browser/search_engines/template_url_service_factory.h"
8 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 8 #include "chrome/browser/sync/test/integration/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_datatype_helper.h" 10 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
11 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
12 #include "chrome/browser/sync/test/integration/sync_test.h" 11 #include "chrome/browser/sync/test/integration/sync_test.h"
12 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h "
13 #include "components/search_engines/template_url.h" 13 #include "components/search_engines/template_url.h"
14 #include "components/search_engines/template_url_service.h" 14 #include "components/search_engines/template_url_service.h"
15 15
16 using base::ASCIIToUTF16; 16 using base::ASCIIToUTF16;
17 using sync_integration_test_util::AwaitCommitActivityCompletion;
18 17
19 class TwoClientSearchEnginesSyncTest : public SyncTest { 18 class TwoClientSearchEnginesSyncTest : public SyncTest {
20 public: 19 public:
21 TwoClientSearchEnginesSyncTest() : SyncTest(TWO_CLIENT) {} 20 TwoClientSearchEnginesSyncTest() : SyncTest(TWO_CLIENT) {}
22 ~TwoClientSearchEnginesSyncTest() override {} 21 ~TwoClientSearchEnginesSyncTest() override {}
23 22
24 private: 23 private:
25 DISALLOW_COPY_AND_ASSIGN(TwoClientSearchEnginesSyncTest); 24 DISALLOW_COPY_AND_ASSIGN(TwoClientSearchEnginesSyncTest);
26 }; 25 };
27 26
28 // TCM ID - 8898628. 27 // TCM ID - 8898628.
29 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, E2E_ENABLED(Add)) { 28 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, E2E_ENABLED(Add)) {
30 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 29 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
31 ASSERT_TRUE(search_engines_helper::AllServicesMatch()); 30 ASSERT_TRUE(search_engines_helper::AllServicesMatch());
32 31
33 // Note that a random seed is needed due to the E2E nature of the tests, and 32 // Note that a random seed is needed due to the E2E nature of the tests, and
34 // the synced data persisting in the server across tests. 33 // the synced data persisting in the server across tests.
35 int search_engine_seed = base::Time::Now().ToInternalValue(); 34 int search_engine_seed = base::Time::Now().ToInternalValue();
36 search_engines_helper::AddSearchEngine(0, search_engine_seed); 35 search_engines_helper::AddSearchEngine(0, search_engine_seed);
37 ASSERT_TRUE(search_engines_helper::HasSearchEngine(0, search_engine_seed)); 36 ASSERT_TRUE(search_engines_helper::HasSearchEngine(0, search_engine_seed));
38 37
39 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 38 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
40 ASSERT_TRUE(search_engines_helper::HasSearchEngine(1, search_engine_seed)); 39 ASSERT_TRUE(search_engines_helper::HasSearchEngine(1, search_engine_seed));
41 } 40 }
42 41
43 // TCM ID - 8898660. 42 // TCM ID - 8898660.
44 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, E2E_ENABLED(Delete)) { 43 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, E2E_ENABLED(Delete)) {
45 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 44 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
46 ASSERT_TRUE(search_engines_helper::AllServicesMatch()); 45 ASSERT_TRUE(search_engines_helper::AllServicesMatch());
47 46
48 // Note that a random seed is needed due to the E2E nature of the tests, and 47 // Note that a random seed is needed due to the E2E nature of the tests, and
49 // the synced data persisting in the server across tests. 48 // the synced data persisting in the server across tests.
50 int search_engine_seed = base::Time::Now().ToInternalValue(); 49 int search_engine_seed = base::Time::Now().ToInternalValue();
51 search_engines_helper::AddSearchEngine(0, search_engine_seed); 50 search_engines_helper::AddSearchEngine(0, search_engine_seed);
52 ASSERT_TRUE(search_engines_helper::HasSearchEngine(0, search_engine_seed)); 51 ASSERT_TRUE(search_engines_helper::HasSearchEngine(0, search_engine_seed));
53 52
54 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 53 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
55 ASSERT_TRUE(search_engines_helper::HasSearchEngine(1, search_engine_seed)); 54 ASSERT_TRUE(search_engines_helper::HasSearchEngine(1, search_engine_seed));
56 55
57 search_engines_helper::DeleteSearchEngineBySeed(0, search_engine_seed); 56 search_engines_helper::DeleteSearchEngineBySeed(0, search_engine_seed);
58 57
59 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 58 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
60 ASSERT_FALSE(search_engines_helper::HasSearchEngine(1, search_engine_seed)); 59 ASSERT_FALSE(search_engines_helper::HasSearchEngine(1, search_engine_seed));
61 } 60 }
62 61
63 // TCM ID - 8912240. 62 // TCM ID - 8912240.
64 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, 63 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest,
65 E2E_ENABLED(AddMultiple)) { 64 E2E_ENABLED(AddMultiple)) {
66 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 65 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
67 ASSERT_TRUE(search_engines_helper::AllServicesMatch()); 66 ASSERT_TRUE(search_engines_helper::AllServicesMatch());
68 67
69 // Add a few entries. 68 // Add a few entries.
70 for (int i = 0; i < 3; ++i) 69 for (int i = 0; i < 3; ++i)
71 search_engines_helper::AddSearchEngine(0, i); 70 search_engines_helper::AddSearchEngine(0, i);
72 71
73 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 72 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
74 } 73 }
75 74
76 // TCM ID - 9011135. 75 // TCM ID - 9011135.
77 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, Duplicates) { 76 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, Duplicates) {
78 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 77 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
79 ASSERT_TRUE(search_engines_helper::AllServicesMatch()); 78 ASSERT_TRUE(search_engines_helper::AllServicesMatch());
80 79
81 // Add two entries with the same Name and URL (but different keywords). 80 // Add two entries with the same Name and URL (but different keywords).
82 // Note that we have to change the GUID of the duplicate. 81 // Note that we have to change the GUID of the duplicate.
83 search_engines_helper::AddSearchEngine(0, 0); 82 search_engines_helper::AddSearchEngine(0, 0);
84 Profile* profile = sync_datatype_helper::test()->GetProfile(0); 83 Profile* profile = sync_datatype_helper::test()->GetProfile(0);
85 TemplateURLServiceFactory::GetForProfile(profile)->Add( 84 TemplateURLServiceFactory::GetForProfile(profile)->Add(
86 search_engines_helper::CreateTestTemplateURL(profile, 0, 85 search_engines_helper::CreateTestTemplateURL(profile, 0,
87 ASCIIToUTF16("somethingelse"), "newguid")); 86 ASCIIToUTF16("somethingelse"), "newguid"));
88 search_engines_helper::GetVerifierService()->Add( 87 search_engines_helper::GetVerifierService()->Add(
89 search_engines_helper::CreateTestTemplateURL(profile, 0, 88 search_engines_helper::CreateTestTemplateURL(profile, 0,
90 ASCIIToUTF16("somethingelse"), "newguid")); 89 ASCIIToUTF16("somethingelse"), "newguid"));
91 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 90 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
92 } 91 }
93 92
94 // TCM ID - 9004201. 93 // TCM ID - 9004201.
95 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, 94 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest,
96 E2E_ENABLED(UpdateKeyword)) { 95 E2E_ENABLED(UpdateKeyword)) {
97 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 96 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
98 ASSERT_TRUE(search_engines_helper::AllServicesMatch()); 97 ASSERT_TRUE(search_engines_helper::AllServicesMatch());
99 98
100 search_engines_helper::AddSearchEngine(0, 0); 99 search_engines_helper::AddSearchEngine(0, 0);
101 100
102 // Change the keyword. 101 // Change the keyword.
103 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 102 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
104 103
105 search_engines_helper::EditSearchEngine(0, ASCIIToUTF16("test0"), 104 search_engines_helper::EditSearchEngine(0, ASCIIToUTF16("test0"),
106 ASCIIToUTF16("test0"), ASCIIToUTF16("newkeyword"), 105 ASCIIToUTF16("test0"), ASCIIToUTF16("newkeyword"),
107 "http://www.test0.com/"); 106 "http://www.test0.com/");
108 107
109 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 108 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
110 } 109 }
111 110
112 // TCM ID - 8894859. 111 // TCM ID - 8894859.
113 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, E2E_ENABLED(UpdateUrl)) { 112 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, E2E_ENABLED(UpdateUrl)) {
114 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 113 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
115 ASSERT_TRUE(search_engines_helper::AllServicesMatch()); 114 ASSERT_TRUE(search_engines_helper::AllServicesMatch());
116 115
117 search_engines_helper::AddSearchEngine(0, 0); 116 search_engines_helper::AddSearchEngine(0, 0);
118 117
119 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 118 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
120 119
121 // Change the URL. 120 // Change the URL.
122 search_engines_helper::EditSearchEngine(0, ASCIIToUTF16("test0"), 121 search_engines_helper::EditSearchEngine(0, ASCIIToUTF16("test0"),
123 ASCIIToUTF16("test0"), ASCIIToUTF16("test0"), 122 ASCIIToUTF16("test0"), ASCIIToUTF16("test0"),
124 "http://www.wikipedia.org/q=%s"); 123 "http://www.wikipedia.org/q=%s");
125 124
126 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 125 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
127 } 126 }
128 127
129 // TCM ID - 8910490. 128 // TCM ID - 8910490.
130 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, 129 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest,
131 E2E_ENABLED(UpdateName)) { 130 E2E_ENABLED(UpdateName)) {
132 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 131 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
133 ASSERT_TRUE(search_engines_helper::AllServicesMatch()); 132 ASSERT_TRUE(search_engines_helper::AllServicesMatch());
134 133
135 search_engines_helper::AddSearchEngine(0, 0); 134 search_engines_helper::AddSearchEngine(0, 0);
136 135
137 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 136 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
138 137
139 // Change the short name. 138 // Change the short name.
140 search_engines_helper::EditSearchEngine(0, ASCIIToUTF16("test0"), 139 search_engines_helper::EditSearchEngine(0, ASCIIToUTF16("test0"),
141 ASCIIToUTF16("New Name"), ASCIIToUTF16("test0"), "http://www.test0.com/"); 140 ASCIIToUTF16("New Name"), ASCIIToUTF16("test0"), "http://www.test0.com/");
142 141
143 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 142 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
144 } 143 }
145 144
146 // TCM ID - 9004196. 145 // TCM ID - 9004196.
147 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, ConflictKeyword) { 146 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, ConflictKeyword) {
148 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 147 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
149 DisableVerifier(); 148 DisableVerifier();
150 ASSERT_TRUE(search_engines_helper::AllServicesMatch()); 149 ASSERT_TRUE(search_engines_helper::AllServicesMatch());
151 150
152 // Add a different search engine to each client, but make their keywords 151 // Add a different search engine to each client, but make their keywords
153 // conflict. 152 // conflict.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 ASSERT_TRUE(search_engines_helper::AllServicesMatch()); 189 ASSERT_TRUE(search_engines_helper::AllServicesMatch());
191 } 190 }
192 191
193 // TCM ID - 8906436. 192 // TCM ID - 8906436.
194 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, DisableSync) { 193 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, DisableSync) {
195 ASSERT_TRUE(SetupSync()); 194 ASSERT_TRUE(SetupSync());
196 ASSERT_TRUE(search_engines_helper::AllServicesMatch()); 195 ASSERT_TRUE(search_engines_helper::AllServicesMatch());
197 196
198 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes()); 197 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes());
199 search_engines_helper::AddSearchEngine(0, 0); 198 search_engines_helper::AddSearchEngine(0, 0);
200 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); 199 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait());
201 ASSERT_TRUE(search_engines_helper::ServiceMatchesVerifier(0)); 200 ASSERT_TRUE(search_engines_helper::ServiceMatchesVerifier(0));
202 ASSERT_FALSE(search_engines_helper::ServiceMatchesVerifier(1)); 201 ASSERT_FALSE(search_engines_helper::ServiceMatchesVerifier(1));
203 202
204 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes()); 203 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes());
205 ASSERT_TRUE(AwaitQuiescence()); 204 ASSERT_TRUE(AwaitQuiescence());
206 ASSERT_TRUE(search_engines_helper::AllServicesMatch()); 205 ASSERT_TRUE(search_engines_helper::AllServicesMatch());
207 } 206 }
208 207
209 // TCM ID - 8891809. 208 // TCM ID - 8891809.
210 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, 209 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest,
211 E2E_ENABLED(SyncDefault)) { 210 E2E_ENABLED(SyncDefault)) {
212 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 211 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
213 ASSERT_TRUE(search_engines_helper::AllServicesMatch()); 212 ASSERT_TRUE(search_engines_helper::AllServicesMatch());
214 213
215 search_engines_helper::AddSearchEngine(0, 0); 214 search_engines_helper::AddSearchEngine(0, 0);
216 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 215 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
217 216
218 // Change the default to the new search engine, sync, and ensure that it 217 // Change the default to the new search engine, sync, and ensure that it
219 // changed in the second client. AllServicesMatch does a default search 218 // changed in the second client. AllServicesMatch does a default search
220 // provider check. 219 // provider check.
221 search_engines_helper::ChangeDefaultSearchProvider(0, 0); 220 search_engines_helper::ChangeDefaultSearchProvider(0, 0);
222 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 221 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
223 } 222 }
224 223
225 // Ensure that we can change the search engine and immediately delete it 224 // Ensure that we can change the search engine and immediately delete it
226 // without putting the clients out of sync. 225 // without putting the clients out of sync.
227 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, 226 IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest,
228 E2E_ENABLED(DeleteSyncedDefault)) { 227 E2E_ENABLED(DeleteSyncedDefault)) {
229 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 228 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
230 ASSERT_TRUE(search_engines_helper::AllServicesMatch()); 229 ASSERT_TRUE(search_engines_helper::AllServicesMatch());
231 230
232 search_engines_helper::AddSearchEngine(0, 0); 231 search_engines_helper::AddSearchEngine(0, 0);
233 search_engines_helper::AddSearchEngine(0, 1); 232 search_engines_helper::AddSearchEngine(0, 1);
234 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 233 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
235 234
236 search_engines_helper::ChangeDefaultSearchProvider(0, 0); 235 search_engines_helper::ChangeDefaultSearchProvider(0, 0);
237 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 236 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
238 237
239 // Change the default on the first client and delete the old default. 238 // Change the default on the first client and delete the old default.
240 search_engines_helper::ChangeDefaultSearchProvider(0, 1); 239 search_engines_helper::ChangeDefaultSearchProvider(0, 1);
241 search_engines_helper::DeleteSearchEngineBySeed(0, 0); 240 search_engines_helper::DeleteSearchEngineBySeed(0, 0);
242 ASSERT_TRUE(search_engines_helper::AwaitAllServicesMatch()); 241 ASSERT_TRUE(SearchEnginesMatchChecker().Wait());
243 } 242 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698