OLD | NEW |
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/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
6 #include "chrome/browser/sessions/session_service.h" | 6 #include "chrome/browser/sessions/session_service.h" |
7 #include "chrome/browser/sync/profile_sync_service_harness.h" | 7 #include "chrome/browser/sync/profile_sync_service_harness.h" |
8 #include "chrome/browser/sync/sessions/session_state.h" | 8 #include "chrome/browser/sync/sessions/session_state.h" |
9 #include "chrome/browser/sync/test/live_sync/live_sync_test.h" | 9 #include "chrome/browser/sync/test/live_sync/live_sync_test.h" |
10 #include "chrome/browser/sync/test/live_sync/sessions_helper.h" | 10 #include "chrome/browser/sync/test/live_sync/sessions_helper.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 FirstChangesAndSetsPassphrase) { | 134 FirstChangesAndSetsPassphrase) { |
135 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 135 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
136 | 136 |
137 ASSERT_TRUE(CheckInitialState(0)); | 137 ASSERT_TRUE(CheckInitialState(0)); |
138 ASSERT_TRUE(CheckInitialState(1)); | 138 ASSERT_TRUE(CheckInitialState(1)); |
139 | 139 |
140 ScopedVector<SessionWindow> client0_windows; | 140 ScopedVector<SessionWindow> client0_windows; |
141 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), client0_windows.get())); | 141 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), client0_windows.get())); |
142 | 142 |
143 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 143 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
144 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true, true); | 144 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); |
145 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); | 145 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); |
146 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 146 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
147 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 147 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
148 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 148 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
149 num_blocking_conflicting_updates); | 149 num_blocking_conflicting_updates); |
150 // We have 3 non-blocking conflicts due to the two meta nodes (one for each | 150 // We have 3 non-blocking conflicts due to the two meta nodes (one for each |
151 // client, and the one tab node). | 151 // client, and the one tab node). |
152 ASSERT_EQ(3, GetClient(1)->GetLastSessionSnapshot()-> | 152 ASSERT_EQ(3, GetClient(1)->GetLastSessionSnapshot()-> |
153 num_conflicting_updates); // The encrypted nodes. | 153 num_conflicting_updates); // The encrypted nodes. |
154 | 154 |
155 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true, true); | 155 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); |
156 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); | 156 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); |
157 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); | 157 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); |
158 | 158 |
159 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); | 159 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); |
160 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); | 160 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); |
161 // Get foreign session data from client 0 and 1. | 161 // Get foreign session data from client 0 and 1. |
162 SyncedSessionVector sessions1; | 162 SyncedSessionVector sessions1; |
163 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 163 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
164 | 164 |
165 // Verify client 1's foreign session matches client 0's current window and | 165 // Verify client 1's foreign session matches client 0's current window and |
166 // vice versa. | 166 // vice versa. |
167 ASSERT_EQ(1U, sessions1.size()); | 167 ASSERT_EQ(1U, sessions1.size()); |
168 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows.get())); | 168 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows.get())); |
169 } | 169 } |
170 | 170 |
171 // Flaky (number of conflicting nodes is off). http://crbug.com/89604. | 171 // Flaky (number of conflicting nodes is off). http://crbug.com/89604. |
172 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, | 172 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, |
173 FLAKY_FirstChangesWhileSecondWaitingForPassphrase) { | 173 FLAKY_FirstChangesWhileSecondWaitingForPassphrase) { |
174 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 174 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
175 | 175 |
176 ASSERT_TRUE(CheckInitialState(0)); | 176 ASSERT_TRUE(CheckInitialState(0)); |
177 ASSERT_TRUE(CheckInitialState(1)); | 177 ASSERT_TRUE(CheckInitialState(1)); |
178 | 178 |
179 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 179 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
180 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true, true); | 180 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); |
181 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); | 181 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); |
182 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 182 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
183 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 183 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
184 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 184 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
185 num_blocking_conflicting_updates); | 185 num_blocking_conflicting_updates); |
186 // We have two non-blocking conflicts due to the two meta nodes (one for each | 186 // We have two non-blocking conflicts due to the two meta nodes (one for each |
187 // client). | 187 // client). |
188 ASSERT_EQ(2, GetClient(1)->GetLastSessionSnapshot()-> | 188 ASSERT_EQ(2, GetClient(1)->GetLastSessionSnapshot()-> |
189 num_conflicting_updates); // The encrypted nodes. | 189 num_conflicting_updates); // The encrypted nodes. |
190 | 190 |
191 ScopedVector<SessionWindow> client0_windows; | 191 ScopedVector<SessionWindow> client0_windows; |
192 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), client0_windows.get())); | 192 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), client0_windows.get())); |
193 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 193 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
194 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 194 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
195 num_blocking_conflicting_updates); | 195 num_blocking_conflicting_updates); |
196 ASSERT_EQ(3, GetClient(1)->GetLastSessionSnapshot()-> | 196 ASSERT_EQ(3, GetClient(1)->GetLastSessionSnapshot()-> |
197 num_conflicting_updates); // The encrypted nodes. | 197 num_conflicting_updates); // The encrypted nodes. |
198 | 198 |
199 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true, true); | 199 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); |
200 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); | 200 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); |
201 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); | 201 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); |
202 | 202 |
203 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); | 203 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); |
204 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); | 204 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); |
205 // Get foreign session data from client 0 and 1. | 205 // Get foreign session data from client 0 and 1. |
206 SyncedSessionVector sessions1; | 206 SyncedSessionVector sessions1; |
207 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 207 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
208 | 208 |
209 // Verify client 1's foreign session matches client 0's current window and | 209 // Verify client 1's foreign session matches client 0's current window and |
210 // vice versa. | 210 // vice versa. |
211 ASSERT_EQ(1U, sessions1.size()); | 211 ASSERT_EQ(1U, sessions1.size()); |
212 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows.get())); | 212 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows.get())); |
213 } | 213 } |
214 | 214 |
215 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, | 215 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, |
216 SecondChangesAfterEncrAndPassphraseChange) { | 216 SecondChangesAfterEncrAndPassphraseChange) { |
217 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 217 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
218 | 218 |
219 ASSERT_TRUE(CheckInitialState(0)); | 219 ASSERT_TRUE(CheckInitialState(0)); |
220 ASSERT_TRUE(CheckInitialState(1)); | 220 ASSERT_TRUE(CheckInitialState(1)); |
221 | 221 |
222 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 222 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
223 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true, true); | 223 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); |
224 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); | 224 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); |
225 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 225 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
226 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 226 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
227 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 227 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
228 num_blocking_conflicting_updates); | 228 num_blocking_conflicting_updates); |
229 // We have two non-blocking conflicts due to the two meta nodes (one for each | 229 // We have two non-blocking conflicts due to the two meta nodes (one for each |
230 // client). | 230 // client). |
231 ASSERT_EQ(2, GetClient(1)->GetLastSessionSnapshot()-> | 231 ASSERT_EQ(2, GetClient(1)->GetLastSessionSnapshot()-> |
232 num_conflicting_updates); // The encrypted nodes. | 232 num_conflicting_updates); // The encrypted nodes. |
233 | 233 |
234 // These changes are either made with the old passphrase or not encrypted at | 234 // These changes are either made with the old passphrase or not encrypted at |
235 // all depending on when client 0's changes are propagated. | 235 // all depending on when client 0's changes are propagated. |
236 ScopedVector<SessionWindow> client1_windows; | 236 ScopedVector<SessionWindow> client1_windows; |
237 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), client1_windows.get())); | 237 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), client1_windows.get())); |
238 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 238 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
239 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 239 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
240 num_blocking_conflicting_updates); | 240 num_blocking_conflicting_updates); |
241 ASSERT_EQ(2, GetClient(1)->GetLastSessionSnapshot()-> | 241 ASSERT_EQ(2, GetClient(1)->GetLastSessionSnapshot()-> |
242 num_conflicting_updates); // The same encrypted nodes. | 242 num_conflicting_updates); // The same encrypted nodes. |
243 | 243 |
244 // At this point we enter the passphrase, triggering a resync, in which the | 244 // At this point we enter the passphrase, triggering a resync, in which the |
245 // local changes of client 1 get overwritten for now. | 245 // local changes of client 1 get overwritten for now. |
246 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true, true); | 246 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); |
247 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); | 247 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); |
248 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); | 248 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); |
249 | 249 |
250 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); | 250 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); |
251 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); | 251 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); |
252 // The session data from client 1 got overwritten. As a result, client 0 | 252 // The session data from client 1 got overwritten. As a result, client 0 |
253 // should have no foreign session data. | 253 // should have no foreign session data. |
254 SyncedSessionVector sessions0; | 254 SyncedSessionVector sessions0; |
255 SyncedSessionVector sessions1; | 255 SyncedSessionVector sessions1; |
256 ASSERT_FALSE(GetSessionData(0, &sessions0)); | 256 ASSERT_FALSE(GetSessionData(0, &sessions0)); |
257 ASSERT_FALSE(GetSessionData(1, &sessions1)); | 257 ASSERT_FALSE(GetSessionData(1, &sessions1)); |
258 } | 258 } |
259 | 259 |
260 // Flaky. http://crbug.com/85294 | 260 // Flaky. http://crbug.com/85294 |
261 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, | 261 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, |
262 FLAKY_SecondChangesBeforeEncrAndPassphraseChange) { | 262 FLAKY_SecondChangesBeforeEncrAndPassphraseChange) { |
263 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 263 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
264 | 264 |
265 ASSERT_TRUE(CheckInitialState(0)); | 265 ASSERT_TRUE(CheckInitialState(0)); |
266 ASSERT_TRUE(CheckInitialState(1)); | 266 ASSERT_TRUE(CheckInitialState(1)); |
267 | 267 |
268 // These changes are either made on client 1 without encryption. | 268 // These changes are either made on client 1 without encryption. |
269 ScopedVector<SessionWindow> client1_windows; | 269 ScopedVector<SessionWindow> client1_windows; |
270 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), client1_windows.get())); | 270 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), client1_windows.get())); |
271 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 271 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
272 | 272 |
273 // Turn encryption on client 0. Client 1's foreign will be encrypted with the | 273 // Turn encryption on client 0. Client 1's foreign will be encrypted with the |
274 // new passphrase and synced back. It will be unable to decrypt it yet. | 274 // new passphrase and synced back. It will be unable to decrypt it yet. |
275 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 275 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
276 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true, true); | 276 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); |
277 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); | 277 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); |
278 ASSERT_TRUE(AwaitQuiescence()); | 278 ASSERT_TRUE(AwaitQuiescence()); |
279 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 279 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
280 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 280 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
281 num_blocking_conflicting_updates); | 281 num_blocking_conflicting_updates); |
282 // We have three non-blocking conflicts due to the two meta nodes (one for | 282 // We have three non-blocking conflicts due to the two meta nodes (one for |
283 // each client) and the one tab node. | 283 // each client) and the one tab node. |
284 ASSERT_GE(3, GetClient(1)->GetLastSessionSnapshot()-> | 284 ASSERT_GE(3, GetClient(1)->GetLastSessionSnapshot()-> |
285 num_conflicting_updates); // The encrypted nodes. | 285 num_conflicting_updates); // The encrypted nodes. |
286 | 286 |
287 // At this point we enter the passphrase, triggering a resync. | 287 // At this point we enter the passphrase, triggering a resync. |
288 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true, true); | 288 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); |
289 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); | 289 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); |
290 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); | 290 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); |
291 | 291 |
292 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); | 292 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); |
293 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); | 293 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); |
294 // Client 0's foreign data should match client 1's local data. Client 1's | 294 // Client 0's foreign data should match client 1's local data. Client 1's |
295 // foreign data is empty because client 0 did not open any tabs. | 295 // foreign data is empty because client 0 did not open any tabs. |
296 SyncedSessionVector sessions0; | 296 SyncedSessionVector sessions0; |
297 SyncedSessionVector sessions1; | 297 SyncedSessionVector sessions1; |
298 ASSERT_TRUE(GetSessionData(0, &sessions0)); | 298 ASSERT_TRUE(GetSessionData(0, &sessions0)); |
299 ASSERT_FALSE(GetSessionData(1, &sessions1)); | 299 ASSERT_FALSE(GetSessionData(1, &sessions1)); |
300 ASSERT_EQ(1U, sessions0.size()); | 300 ASSERT_EQ(1U, sessions0.size()); |
301 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, client1_windows.get())); | 301 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, client1_windows.get())); |
302 } | 302 } |
303 | 303 |
304 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, | 304 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, |
305 BothChangeWithEncryptionAndPassphrase) { | 305 BothChangeWithEncryptionAndPassphrase) { |
306 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 306 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
307 | 307 |
308 ASSERT_TRUE(CheckInitialState(0)); | 308 ASSERT_TRUE(CheckInitialState(0)); |
309 ASSERT_TRUE(CheckInitialState(1)); | 309 ASSERT_TRUE(CheckInitialState(1)); |
310 | 310 |
311 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true, true); | 311 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); |
312 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); | 312 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); |
313 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 313 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
314 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 314 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
315 | 315 |
316 // These changes will sync over to client 1, who will be unable to decrypt | 316 // These changes will sync over to client 1, who will be unable to decrypt |
317 // them due to the missing passphrase. | 317 // them due to the missing passphrase. |
318 ScopedVector<SessionWindow> client0_windows; | 318 ScopedVector<SessionWindow> client0_windows; |
319 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), client0_windows.get())); | 319 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), client0_windows.get())); |
320 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 320 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
321 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 321 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
322 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 322 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
323 num_blocking_conflicting_updates); | 323 num_blocking_conflicting_updates); |
324 // We have three non-blocking conflicts due to the two meta nodes (one for | 324 // We have three non-blocking conflicts due to the two meta nodes (one for |
325 // each client) and the one tab node. | 325 // each client) and the one tab node. |
326 ASSERT_EQ(3, GetClient(1)->GetLastSessionSnapshot()-> | 326 ASSERT_EQ(3, GetClient(1)->GetLastSessionSnapshot()-> |
327 num_conflicting_updates); // The encrypted nodes. | 327 num_conflicting_updates); // The encrypted nodes. |
328 | 328 |
329 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true, true); | 329 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); |
330 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); | 330 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); |
331 ASSERT_FALSE(GetClient(1)->service()->IsPassphraseRequired()); | 331 ASSERT_FALSE(GetClient(1)->service()->IsPassphraseRequired()); |
332 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); | 332 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); |
333 | 333 |
334 // Open windows on client 1, which should automatically be encrypted. | 334 // Open windows on client 1, which should automatically be encrypted. |
335 ScopedVector<SessionWindow> client1_windows; | 335 ScopedVector<SessionWindow> client1_windows; |
336 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL2), client1_windows.get())); | 336 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL2), client1_windows.get())); |
337 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 337 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
338 | 338 |
339 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); | 339 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); |
340 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); | 340 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); |
341 // Get foreign session data from client 0 and 1. | 341 // Get foreign session data from client 0 and 1. |
342 SyncedSessionVector sessions0; | 342 SyncedSessionVector sessions0; |
343 SyncedSessionVector sessions1; | 343 SyncedSessionVector sessions1; |
344 ASSERT_TRUE(GetSessionData(0, &sessions0)); | 344 ASSERT_TRUE(GetSessionData(0, &sessions0)); |
345 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 345 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
346 | 346 |
347 // Verify client 1's foreign session matches client 0's current window and | 347 // Verify client 1's foreign session matches client 0's current window and |
348 // vice versa. | 348 // vice versa. |
349 ASSERT_EQ(1U, sessions0.size()); | 349 ASSERT_EQ(1U, sessions0.size()); |
350 ASSERT_EQ(1U, sessions1.size()); | 350 ASSERT_EQ(1U, sessions1.size()); |
351 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows.get())); | 351 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows.get())); |
352 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, client1_windows.get())); | 352 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, client1_windows.get())); |
353 } | 353 } |
OLD | NEW |