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

Side by Side Diff: chrome/browser/sync/test/integration/two_client_passwords_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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/hash.h" 10 #include "base/hash.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/rand_util.h" 12 #include "base/rand_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/sync/test/integration/passwords_helper.h" 15 #include "chrome/browser/sync/test/integration/passwords_helper.h"
16 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 16 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
17 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" 17 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
18 #include "chrome/browser/sync/test/integration/sync_test.h" 18 #include "chrome/browser/sync/test/integration/sync_test.h"
19 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" 19 #include "components/sync/engine/cycle/sync_cycle_snapshot.h"
20 #include "components/sync/engine/model_safe_worker.h" 20 #include "components/sync/engine/model_safe_worker.h"
21 21
22 using passwords_helper::AddLogin; 22 using passwords_helper::AddLogin;
23 using passwords_helper::AllProfilesContainSamePasswordForms; 23 using passwords_helper::AllProfilesContainSamePasswordForms;
24 using passwords_helper::AllProfilesContainSamePasswordFormsAsVerifier; 24 using passwords_helper::AllProfilesContainSamePasswordFormsAsVerifier;
25 using passwords_helper::AwaitAllProfilesContainSamePasswordForms;
26 using passwords_helper::AwaitProfileContainsSamePasswordFormsAsVerifier;
27 using passwords_helper::CreateTestPasswordForm; 25 using passwords_helper::CreateTestPasswordForm;
28 using passwords_helper::GetPasswordCount; 26 using passwords_helper::GetPasswordCount;
29 using passwords_helper::GetPasswordStore; 27 using passwords_helper::GetPasswordStore;
30 using passwords_helper::GetVerifierPasswordCount; 28 using passwords_helper::GetVerifierPasswordCount;
31 using passwords_helper::GetVerifierPasswordStore; 29 using passwords_helper::GetVerifierPasswordStore;
32 using passwords_helper::RemoveLogin; 30 using passwords_helper::RemoveLogin;
33 using passwords_helper::RemoveLogins; 31 using passwords_helper::RemoveLogins;
34 using passwords_helper::UpdateLogin; 32 using passwords_helper::UpdateLogin;
35 using sync_integration_test_util::AwaitPassphraseAccepted;
36 using sync_integration_test_util::AwaitPassphraseRequired;
37 33
38 using autofill::PasswordForm; 34 using autofill::PasswordForm;
39 35
40 static const char* kValidPassphrase = "passphrase!"; 36 static const char* kValidPassphrase = "passphrase!";
41 37
42 class TwoClientPasswordsSyncTest : public SyncTest { 38 class TwoClientPasswordsSyncTest : public SyncTest {
43 public: 39 public:
44 TwoClientPasswordsSyncTest() : SyncTest(TWO_CLIENT) {} 40 TwoClientPasswordsSyncTest() : SyncTest(TWO_CLIENT) {}
45 ~TwoClientPasswordsSyncTest() override {} 41 ~TwoClientPasswordsSyncTest() override {}
46 42
47 bool TestUsesSelfNotifications() override { return false; } 43 bool TestUsesSelfNotifications() override { return false; }
48 44
49 private: 45 private:
50 DISALLOW_COPY_AND_ASSIGN(TwoClientPasswordsSyncTest); 46 DISALLOW_COPY_AND_ASSIGN(TwoClientPasswordsSyncTest);
51 }; 47 };
52 48
53 // TCM ID - 3732277 49 // TCM ID - 3732277
54 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, E2E_ENABLED(Add)) { 50 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, E2E_ENABLED(Add)) {
55 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 51 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
56 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); 52 ASSERT_TRUE(SamePasswordFormsChecker().Wait());
57 53
58 PasswordForm form = CreateTestPasswordForm(0); 54 PasswordForm form = CreateTestPasswordForm(0);
59 AddLogin(GetPasswordStore(0), form); 55 AddLogin(GetPasswordStore(0), form);
60 ASSERT_EQ(1, GetPasswordCount(0)); 56 ASSERT_EQ(1, GetPasswordCount(0));
61 57
62 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); 58 ASSERT_TRUE(SamePasswordFormsChecker().Wait());
63 ASSERT_EQ(1, GetPasswordCount(1)); 59 ASSERT_EQ(1, GetPasswordCount(1));
64 } 60 }
65 61
66 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, E2E_ENABLED(Race)) { 62 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, E2E_ENABLED(Race)) {
67 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 63 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
68 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); 64 ASSERT_TRUE(AllProfilesContainSamePasswordForms());
69 65
70 PasswordForm form0 = CreateTestPasswordForm(0); 66 PasswordForm form0 = CreateTestPasswordForm(0);
71 AddLogin(GetPasswordStore(0), form0); 67 AddLogin(GetPasswordStore(0), form0);
72 68
73 PasswordForm form1 = form0; 69 PasswordForm form1 = form0;
74 form1.password_value = base::ASCIIToUTF16("new_password"); 70 form1.password_value = base::ASCIIToUTF16("new_password");
75 AddLogin(GetPasswordStore(1), form1); 71 AddLogin(GetPasswordStore(1), form1);
76 72
77 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); 73 ASSERT_TRUE(SamePasswordFormsChecker().Wait());
78 } 74 }
79 75
80 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, 76 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest,
81 E2E_ENABLED(SetPassphraseAndAddPassword)) { 77 E2E_ENABLED(SetPassphraseAndAddPassword)) {
82 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 78 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
83 79
84 GetSyncService(0)->SetEncryptionPassphrase( 80 GetSyncService(0)->SetEncryptionPassphrase(
85 kValidPassphrase, browser_sync::ProfileSyncService::EXPLICIT); 81 kValidPassphrase, browser_sync::ProfileSyncService::EXPLICIT);
86 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService(0))); 82 ASSERT_TRUE(PassphraseAcceptedChecker(GetSyncService(0)).Wait());
87 83
88 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService(1))); 84 ASSERT_TRUE(PassphraseRequiredChecker(GetSyncService(1)).Wait());
89 ASSERT_TRUE(GetSyncService(1)->SetDecryptionPassphrase(kValidPassphrase)); 85 ASSERT_TRUE(GetSyncService(1)->SetDecryptionPassphrase(kValidPassphrase));
90 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService(1))); 86 ASSERT_TRUE(PassphraseAcceptedChecker(GetSyncService(1)).Wait());
91 87
92 PasswordForm form = CreateTestPasswordForm(0); 88 PasswordForm form = CreateTestPasswordForm(0);
93 AddLogin(GetPasswordStore(0), form); 89 AddLogin(GetPasswordStore(0), form);
94 ASSERT_EQ(1, GetPasswordCount(0)); 90 ASSERT_EQ(1, GetPasswordCount(0));
95 91
96 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); 92 ASSERT_TRUE(SamePasswordFormsChecker().Wait());
97 } 93 }
98 94
99 // TCM ID - 4603879 95 // TCM ID - 4603879
100 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Update) { 96 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Update) {
101 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 97 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
102 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); 98 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
103 99
104 PasswordForm form = CreateTestPasswordForm(0); 100 PasswordForm form = CreateTestPasswordForm(0);
105 AddLogin(GetVerifierPasswordStore(), form); 101 AddLogin(GetVerifierPasswordStore(), form);
106 AddLogin(GetPasswordStore(0), form); 102 AddLogin(GetPasswordStore(0), form);
107 103
108 // Wait for client 0 to commit and client 1 to receive the update. 104 // Wait for client 0 to commit and client 1 to receive the update.
109 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(1)); 105 ASSERT_TRUE(SamePasswordFormsAsVerifierChecker(1).Wait());
110 106
111 form.password_value = base::ASCIIToUTF16("new_password"); 107 form.password_value = base::ASCIIToUTF16("new_password");
112 UpdateLogin(GetVerifierPasswordStore(), form); 108 UpdateLogin(GetVerifierPasswordStore(), form);
113 UpdateLogin(GetPasswordStore(1), form); 109 UpdateLogin(GetPasswordStore(1), form);
114 ASSERT_EQ(1, GetVerifierPasswordCount()); 110 ASSERT_EQ(1, GetVerifierPasswordCount());
115 111
116 // Wait for client 1 to commit and client 0 to receive the update. 112 // Wait for client 1 to commit and client 0 to receive the update.
117 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(0)); 113 ASSERT_TRUE(SamePasswordFormsAsVerifierChecker(0).Wait());
118 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); 114 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
119 } 115 }
120 116
121 // TCM ID - 3719309 117 // TCM ID - 3719309
122 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Delete) { 118 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, Delete) {
123 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 119 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
124 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); 120 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
125 121
126 PasswordForm form0 = CreateTestPasswordForm(0); 122 PasswordForm form0 = CreateTestPasswordForm(0);
127 AddLogin(GetVerifierPasswordStore(), form0); 123 AddLogin(GetVerifierPasswordStore(), form0);
128 AddLogin(GetPasswordStore(0), form0); 124 AddLogin(GetPasswordStore(0), form0);
129 PasswordForm form1 = CreateTestPasswordForm(1); 125 PasswordForm form1 = CreateTestPasswordForm(1);
130 AddLogin(GetVerifierPasswordStore(), form1); 126 AddLogin(GetVerifierPasswordStore(), form1);
131 AddLogin(GetPasswordStore(0), form1); 127 AddLogin(GetPasswordStore(0), form1);
132 128
133 // Wait for client 0 to commit and client 1 to receive the update. 129 // Wait for client 0 to commit and client 1 to receive the update.
134 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(1)); 130 ASSERT_TRUE(SamePasswordFormsAsVerifierChecker(1).Wait());
135 131
136 RemoveLogin(GetPasswordStore(1), form0); 132 RemoveLogin(GetPasswordStore(1), form0);
137 RemoveLogin(GetVerifierPasswordStore(), form0); 133 RemoveLogin(GetVerifierPasswordStore(), form0);
138 ASSERT_EQ(1, GetVerifierPasswordCount()); 134 ASSERT_EQ(1, GetVerifierPasswordCount());
139 135
140 // Wait for deletion from client 1 to propagate. 136 // Wait for deletion from client 1 to propagate.
141 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(0)); 137 ASSERT_TRUE(SamePasswordFormsAsVerifierChecker(0).Wait());
142 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); 138 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
143 } 139 }
144 140
145 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, 141 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest,
146 SetPassphraseAndThenSetupSync) { 142 SetPassphraseAndThenSetupSync) {
147 ASSERT_TRUE(SetupClients()); 143 ASSERT_TRUE(SetupClients());
148 144
149 ASSERT_TRUE(GetClient(0)->SetupSync()); 145 ASSERT_TRUE(GetClient(0)->SetupSync());
150 GetSyncService(0)->SetEncryptionPassphrase( 146 GetSyncService(0)->SetEncryptionPassphrase(
151 kValidPassphrase, browser_sync::ProfileSyncService::EXPLICIT); 147 kValidPassphrase, browser_sync::ProfileSyncService::EXPLICIT);
152 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService(0))); 148 ASSERT_TRUE(PassphraseAcceptedChecker(GetSyncService(0)).Wait());
153 149
154 // When client 1 hits a passphrase required state, we can infer that 150 // When client 1 hits a passphrase required state, we can infer that
155 // client 0's passphrase has been committed. to the server. 151 // client 0's passphrase has been committed. to the server.
156 ASSERT_FALSE(GetClient(1)->SetupSync()); 152 ASSERT_FALSE(GetClient(1)->SetupSync());
157 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService(1))); 153 ASSERT_TRUE(PassphraseRequiredChecker(GetSyncService(1)).Wait());
158 154
159 // Get client 1 out of the passphrase required state. 155 // Get client 1 out of the passphrase required state.
160 ASSERT_TRUE(GetSyncService(1)->SetDecryptionPassphrase(kValidPassphrase)); 156 ASSERT_TRUE(GetSyncService(1)->SetDecryptionPassphrase(kValidPassphrase));
161 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService(1))); 157 ASSERT_TRUE(PassphraseAcceptedChecker(GetSyncService(1)).Wait());
162 158
163 // We must mark the setup complete now, since we just entered the passphrase 159 // We must mark the setup complete now, since we just entered the passphrase
164 // and the previous SetupSync() call failed. 160 // and the previous SetupSync() call failed.
165 GetClient(1)->FinishSyncSetup(); 161 GetClient(1)->FinishSyncSetup();
166 162
167 // Move around some passwords to make sure it's all working. 163 // Move around some passwords to make sure it's all working.
168 PasswordForm form0 = CreateTestPasswordForm(0); 164 PasswordForm form0 = CreateTestPasswordForm(0);
169 AddLogin(GetPasswordStore(0), form0); 165 AddLogin(GetPasswordStore(0), form0);
170 166
171 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); 167 ASSERT_TRUE(SamePasswordFormsChecker().Wait());
172 } 168 }
173 169
174 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, E2E_ONLY(Delete)) { 170 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, E2E_ONLY(Delete)) {
175 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 171 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
176 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); 172 ASSERT_TRUE(AllProfilesContainSamePasswordForms());
177 173
178 PasswordForm form0 = CreateTestPasswordForm(base::Hash(base::GenerateGUID())); 174 PasswordForm form0 = CreateTestPasswordForm(base::Hash(base::GenerateGUID()));
179 PasswordForm form1 = CreateTestPasswordForm(base::Hash(base::GenerateGUID())); 175 PasswordForm form1 = CreateTestPasswordForm(base::Hash(base::GenerateGUID()));
180 AddLogin(GetPasswordStore(0), form0); 176 AddLogin(GetPasswordStore(0), form0);
181 AddLogin(GetPasswordStore(0), form1); 177 AddLogin(GetPasswordStore(0), form1);
182 178
183 const int init_password_count = GetPasswordCount(0); 179 const int init_password_count = GetPasswordCount(0);
184 180
185 // Wait for client 0 to commit and client 1 to receive the update. 181 // Wait for client 0 to commit and client 1 to receive the update.
186 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); 182 ASSERT_TRUE(SamePasswordFormsChecker().Wait());
187 ASSERT_EQ(init_password_count, GetPasswordCount(1)); 183 ASSERT_EQ(init_password_count, GetPasswordCount(1));
188 184
189 RemoveLogin(GetPasswordStore(1), form0); 185 RemoveLogin(GetPasswordStore(1), form0);
190 186
191 // Wait for deletion from client 1 to propagate. 187 // Wait for deletion from client 1 to propagate.
192 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); 188 ASSERT_TRUE(SamePasswordFormsChecker().Wait());
193 ASSERT_EQ(init_password_count - 1, GetPasswordCount(0)); 189 ASSERT_EQ(init_password_count - 1, GetPasswordCount(0));
194 190
195 RemoveLogin(GetPasswordStore(1), form1); 191 RemoveLogin(GetPasswordStore(1), form1);
196 192
197 // Wait for deletion from client 1 to propagate. 193 // Wait for deletion from client 1 to propagate.
198 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); 194 ASSERT_TRUE(SamePasswordFormsChecker().Wait());
199 ASSERT_EQ(init_password_count - 2, GetPasswordCount(0)); 195 ASSERT_EQ(init_password_count - 2, GetPasswordCount(0));
200 } 196 }
201 197
202 // TCM ID - 7573511 198 // TCM ID - 7573511
203 // Flaky on Mac and Windows: http://crbug.com/111399 199 // Flaky on Mac and Windows: http://crbug.com/111399
204 #if defined(OS_WIN) || defined(OS_MACOSX) 200 #if defined(OS_WIN) || defined(OS_MACOSX)
205 #define MAYBE_DeleteAll DISABLED_DeleteAll 201 #define MAYBE_DeleteAll DISABLED_DeleteAll
206 #else 202 #else
207 #define MAYBE_DeleteAll DeleteAll 203 #define MAYBE_DeleteAll DeleteAll
208 #endif 204 #endif
209 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, MAYBE_DeleteAll) { 205 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, MAYBE_DeleteAll) {
210 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 206 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
211 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); 207 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
212 208
213 PasswordForm form0 = CreateTestPasswordForm(0); 209 PasswordForm form0 = CreateTestPasswordForm(0);
214 AddLogin(GetVerifierPasswordStore(), form0); 210 AddLogin(GetVerifierPasswordStore(), form0);
215 AddLogin(GetPasswordStore(0), form0); 211 AddLogin(GetPasswordStore(0), form0);
216 PasswordForm form1 = CreateTestPasswordForm(1); 212 PasswordForm form1 = CreateTestPasswordForm(1);
217 AddLogin(GetVerifierPasswordStore(), form1); 213 AddLogin(GetVerifierPasswordStore(), form1);
218 AddLogin(GetPasswordStore(0), form1); 214 AddLogin(GetPasswordStore(0), form1);
219 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(1)); 215 ASSERT_TRUE(SamePasswordFormsAsVerifierChecker(1).Wait());
220 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); 216 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
221 217
222 RemoveLogins(GetPasswordStore(1)); 218 RemoveLogins(GetPasswordStore(1));
223 RemoveLogins(GetVerifierPasswordStore()); 219 RemoveLogins(GetVerifierPasswordStore());
224 ASSERT_TRUE(AwaitProfileContainsSamePasswordFormsAsVerifier(0)); 220 ASSERT_TRUE(SamePasswordFormsAsVerifierChecker(0).Wait());
225 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier()); 221 ASSERT_TRUE(AllProfilesContainSamePasswordFormsAsVerifier());
226 ASSERT_EQ(0, GetVerifierPasswordCount()); 222 ASSERT_EQ(0, GetVerifierPasswordCount());
227 } 223 }
228 224
229 // TCM ID - 3694311 225 // TCM ID - 3694311
230 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, E2E_ENABLED(Merge)) { 226 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, E2E_ENABLED(Merge)) {
231 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 227 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
232 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); 228 ASSERT_TRUE(AllProfilesContainSamePasswordForms());
233 229
234 PasswordForm form0 = CreateTestPasswordForm(0); 230 PasswordForm form0 = CreateTestPasswordForm(0);
235 AddLogin(GetPasswordStore(0), form0); 231 AddLogin(GetPasswordStore(0), form0);
236 PasswordForm form1 = CreateTestPasswordForm(1); 232 PasswordForm form1 = CreateTestPasswordForm(1);
237 AddLogin(GetPasswordStore(1), form1); 233 AddLogin(GetPasswordStore(1), form1);
238 PasswordForm form2 = CreateTestPasswordForm(2); 234 PasswordForm form2 = CreateTestPasswordForm(2);
239 AddLogin(GetPasswordStore(1), form2); 235 AddLogin(GetPasswordStore(1), form2);
240 236
241 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); 237 ASSERT_TRUE(SamePasswordFormsChecker().Wait());
242 ASSERT_EQ(3, GetPasswordCount(0)); 238 ASSERT_EQ(3, GetPasswordCount(0));
243 } 239 }
244 240
245 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, E2E_ONLY(TwoClientAddPass)) { 241 IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, E2E_ONLY(TwoClientAddPass)) {
246 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 242 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
247 // All profiles should sync same passwords. 243 // All profiles should sync same passwords.
248 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()) << 244 ASSERT_TRUE(SamePasswordFormsChecker().Wait())
249 "Initial password forms did not match for all profiles"; 245 << "Initial password forms did not match for all profiles";
250 const int init_password_count = GetPasswordCount(0); 246 const int init_password_count = GetPasswordCount(0);
251 247
252 // Add one new password per profile. A unique form is created for each to 248 // Add one new password per profile. A unique form is created for each to
253 // prevent them from overwriting each other. 249 // prevent them from overwriting each other.
254 for (int i = 0; i < num_clients(); ++i) { 250 for (int i = 0; i < num_clients(); ++i) {
255 AddLogin(GetPasswordStore(i), CreateTestPasswordForm(base::RandInt( 251 AddLogin(GetPasswordStore(i), CreateTestPasswordForm(base::RandInt(
256 0, std::numeric_limits<int32_t>::max()))); 252 0, std::numeric_limits<int32_t>::max())));
257 } 253 }
258 254
259 // Blocks and waits for password forms in all profiles to match. 255 // Blocks and waits for password forms in all profiles to match.
260 ASSERT_TRUE(AwaitAllProfilesContainSamePasswordForms()); 256 ASSERT_TRUE(SamePasswordFormsChecker().Wait());
261 257
262 // Check that total number of passwords is as expected. 258 // Check that total number of passwords is as expected.
263 for (int i = 0; i < num_clients(); ++i) { 259 for (int i = 0; i < num_clients(); ++i) {
264 ASSERT_EQ(GetPasswordCount(i), init_password_count + num_clients()) << 260 ASSERT_EQ(GetPasswordCount(i), init_password_count + num_clients()) <<
265 "Total password count is wrong."; 261 "Total password count is wrong.";
266 } 262 }
267 } 263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698