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/integration/sync_test.h" | 9 #include "chrome/browser/sync/test/integration/sync_test.h" |
10 #include "chrome/browser/sync/test/integration/sessions_helper.h" | 10 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), | 153 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), |
154 client0_windows.GetMutable())); | 154 client0_windows.GetMutable())); |
155 | 155 |
156 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 156 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
157 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); | 157 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); |
158 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); | 158 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); |
159 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 159 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
160 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 160 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
161 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 161 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
162 num_blocking_conflicting_updates); | 162 num_blocking_conflicting_updates); |
163 // We have 6 non-blocking conflicts due to the two meta nodes (one for each | 163 // We have 10 non-blocking conflicts due to the two meta nodes (one for each |
164 // client), the one tab node, and the six basic preference/themes/search | 164 // client), the one tab node, and the seven basic preference/themes/search |
165 // engines. | 165 // engines. |
166 ASSERT_EQ(9, GetClient(1)->GetLastSessionSnapshot()-> | 166 ASSERT_EQ(10, GetClient(1)->GetLastSessionSnapshot()-> |
Nicolas Zea
2011/11/04 23:08:06
bleh. Can we go ahead and add a helper method in s
SteveT
2011/11/07 21:48:56
All done, even though we unfortunately still have
| |
167 num_conflicting_updates); // The encrypted nodes. | 167 num_conflicting_updates); // The encrypted nodes. |
168 | 168 |
169 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); | 169 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); |
170 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); | 170 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); |
171 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); | 171 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); |
172 | 172 |
173 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); | 173 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); |
174 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); | 174 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); |
175 // Get foreign session data from client 0 and 1. | 175 // Get foreign session data from client 0 and 1. |
176 SyncedSessionVector sessions1; | 176 SyncedSessionVector sessions1; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 ASSERT_TRUE(CheckInitialState(1)); | 235 ASSERT_TRUE(CheckInitialState(1)); |
236 | 236 |
237 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 237 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
238 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); | 238 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); |
239 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); | 239 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); |
240 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 240 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
241 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 241 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
242 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 242 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
243 num_blocking_conflicting_updates); | 243 num_blocking_conflicting_updates); |
244 // We have two non-blocking conflicts due to the two meta nodes (one for each | 244 // We have two non-blocking conflicts due to the two meta nodes (one for each |
245 // client), and the 6 basic preference/themes/search engines nodes. | 245 // client), and the 7 basic preference/themes/search engines nodes. |
246 ASSERT_EQ(8, GetClient(1)->GetLastSessionSnapshot()-> | 246 ASSERT_EQ(9, GetClient(1)->GetLastSessionSnapshot()-> |
247 num_conflicting_updates); // The encrypted nodes. | 247 num_conflicting_updates); // The encrypted nodes. |
248 | 248 |
249 // These changes are either made with the old passphrase or not encrypted at | 249 // These changes are either made with the old passphrase or not encrypted at |
250 // all depending on when client 0's changes are propagated. | 250 // all depending on when client 0's changes are propagated. |
251 ScopedWindowMap client1_windows; | 251 ScopedWindowMap client1_windows; |
252 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), | 252 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), |
253 client1_windows.GetMutable())); | 253 client1_windows.GetMutable())); |
254 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 254 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
255 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 255 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
256 num_blocking_conflicting_updates); | 256 num_blocking_conflicting_updates); |
257 ASSERT_EQ(8, GetClient(1)->GetLastSessionSnapshot()-> | 257 ASSERT_EQ(9, GetClient(1)->GetLastSessionSnapshot()-> |
258 num_conflicting_updates); // The same encrypted nodes. | 258 num_conflicting_updates); // The same encrypted nodes. |
259 | 259 |
260 // At this point we enter the passphrase, triggering a resync, in which the | 260 // At this point we enter the passphrase, triggering a resync, in which the |
261 // local changes of client 1 get overwritten for now. | 261 // local changes of client 1 get overwritten for now. |
262 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); | 262 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); |
263 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); | 263 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); |
264 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); | 264 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); |
265 | 265 |
266 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); | 266 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); |
267 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); | 267 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 // These changes will sync over to client 1, who will be unable to decrypt | 334 // These changes will sync over to client 1, who will be unable to decrypt |
335 // them due to the missing passphrase. | 335 // them due to the missing passphrase. |
336 ScopedWindowMap client0_windows; | 336 ScopedWindowMap client0_windows; |
337 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), | 337 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), |
338 client0_windows.GetMutable())); | 338 client0_windows.GetMutable())); |
339 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 339 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
340 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 340 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
341 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 341 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
342 num_blocking_conflicting_updates); | 342 num_blocking_conflicting_updates); |
343 // We have three non-blocking conflicts due to the two meta nodes (one for | 343 // We have three non-blocking conflicts due to the two meta nodes (one for |
344 // each client), the one tab node, and the 6 basic preference/themes/search | 344 // each client), the one tab node, and the 7 basic preference/themes/search |
345 // engines nodes. | 345 // engines nodes. |
346 ASSERT_EQ(9, GetClient(1)->GetLastSessionSnapshot()-> | 346 ASSERT_EQ(10, GetClient(1)->GetLastSessionSnapshot()-> |
347 num_conflicting_updates); // The encrypted nodes. | 347 num_conflicting_updates); // The encrypted nodes. |
348 | 348 |
349 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); | 349 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); |
350 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); | 350 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); |
351 ASSERT_FALSE(GetClient(1)->service()->IsPassphraseRequired()); | 351 ASSERT_FALSE(GetClient(1)->service()->IsPassphraseRequired()); |
352 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); | 352 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); |
353 | 353 |
354 // Open windows on client 1, which should automatically be encrypted. | 354 // Open windows on client 1, which should automatically be encrypted. |
355 ScopedWindowMap client1_windows; | 355 ScopedWindowMap client1_windows; |
356 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL2), | 356 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL2), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 ASSERT_FALSE(GetSessionData(1, &sessions1)); | 423 ASSERT_FALSE(GetSessionData(1, &sessions1)); |
424 | 424 |
425 // Client 0 becomes active again with a new tab. | 425 // Client 0 becomes active again with a new tab. |
426 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), | 426 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), |
427 client0_windows.GetMutable())); | 427 client0_windows.GetMutable())); |
428 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 428 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
429 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 429 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
430 ASSERT_EQ(1U, sessions1.size()); | 430 ASSERT_EQ(1U, sessions1.size()); |
431 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); | 431 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); |
432 } | 432 } |
OLD | NEW |