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 two meta nodes (one for each client), the one tab node, plus the |
164 // client), the one tab node, and the six basic preference/themes/search | 164 // basic preference/themes/search engines items. |
165 // engines. | 165 ASSERT_EQ(NumberOfDefaultItems() + 3, GetClient(1)->GetLastSessionSnapshot()-> |
166 ASSERT_EQ(9, GetClient(1)->GetLastSessionSnapshot()-> | |
167 num_conflicting_updates); // The encrypted nodes. | 166 num_conflicting_updates); // The encrypted nodes. |
168 | 167 |
169 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); | 168 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); |
170 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); | 169 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); |
171 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); | 170 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); |
172 | 171 |
173 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); | 172 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); |
174 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); | 173 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); |
175 // Get foreign session data from client 0 and 1. | 174 // Get foreign session data from client 0 and 1. |
176 SyncedSessionVector sessions1; | 175 SyncedSessionVector sessions1; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 ASSERT_TRUE(CheckInitialState(1)); | 234 ASSERT_TRUE(CheckInitialState(1)); |
236 | 235 |
237 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 236 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
238 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); | 237 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); |
239 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); | 238 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); |
240 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 239 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
241 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 240 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
242 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 241 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
243 num_blocking_conflicting_updates); | 242 num_blocking_conflicting_updates); |
244 // We have two non-blocking conflicts due to the two meta nodes (one for each | 243 // 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. | 244 // client), plus the basic preference/themes/search engines nodes. |
246 ASSERT_EQ(8, GetClient(1)->GetLastSessionSnapshot()-> | 245 ASSERT_EQ(NumberOfDefaultItems() + 2, GetClient(1)->GetLastSessionSnapshot()-> |
247 num_conflicting_updates); // The encrypted nodes. | 246 num_conflicting_updates); // The encrypted nodes. |
248 | 247 |
249 // These changes are either made with the old passphrase or not encrypted at | 248 // These changes are either made with the old passphrase or not encrypted at |
250 // all depending on when client 0's changes are propagated. | 249 // all depending on when client 0's changes are propagated. |
251 ScopedWindowMap client1_windows; | 250 ScopedWindowMap client1_windows; |
252 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), | 251 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), |
253 client1_windows.GetMutable())); | 252 client1_windows.GetMutable())); |
254 | 253 |
255 // At this point we enter the passphrase, triggering a resync, in which the | 254 // At this point we enter the passphrase, triggering a resync, in which the |
256 // local changes of client 1 get overwritten for now. | 255 // local changes of client 1 get overwritten for now. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 // These changes will sync over to client 1, who will be unable to decrypt | 331 // These changes will sync over to client 1, who will be unable to decrypt |
333 // them due to the missing passphrase. | 332 // them due to the missing passphrase. |
334 ScopedWindowMap client0_windows; | 333 ScopedWindowMap client0_windows; |
335 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), | 334 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), |
336 client0_windows.GetMutable())); | 335 client0_windows.GetMutable())); |
337 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 336 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
338 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 337 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
339 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 338 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> |
340 num_blocking_conflicting_updates); | 339 num_blocking_conflicting_updates); |
341 // We have three non-blocking conflicts due to the two meta nodes (one for | 340 // We have three non-blocking conflicts due to the two meta nodes (one for |
342 // each client), the one tab node, and the 6 basic preference/themes/search | 341 // each client), the one tab node, plus the basic preference/themes/search |
343 // engines nodes. | 342 // engines nodes. |
344 ASSERT_EQ(9, GetClient(1)->GetLastSessionSnapshot()-> | 343 ASSERT_EQ(NumberOfDefaultItems() + 3, GetClient(1)->GetLastSessionSnapshot()-> |
345 num_conflicting_updates); // The encrypted nodes. | 344 num_conflicting_updates); // The encrypted nodes. |
346 | 345 |
347 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); | 346 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); |
348 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); | 347 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); |
349 ASSERT_FALSE(GetClient(1)->service()->IsPassphraseRequired()); | 348 ASSERT_FALSE(GetClient(1)->service()->IsPassphraseRequired()); |
350 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); | 349 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); |
351 | 350 |
352 // Open windows on client 1, which should automatically be encrypted. | 351 // Open windows on client 1, which should automatically be encrypted. |
353 ScopedWindowMap client1_windows; | 352 ScopedWindowMap client1_windows; |
354 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL2), | 353 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL2), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 ASSERT_FALSE(GetSessionData(1, &sessions1)); | 420 ASSERT_FALSE(GetSessionData(1, &sessions1)); |
422 | 421 |
423 // Client 0 becomes active again with a new tab. | 422 // Client 0 becomes active again with a new tab. |
424 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), | 423 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), |
425 client0_windows.GetMutable())); | 424 client0_windows.GetMutable())); |
426 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 425 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
427 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 426 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
428 ASSERT_EQ(1U, sessions1.size()); | 427 ASSERT_EQ(1U, sessions1.size()); |
429 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); | 428 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); |
430 } | 429 } |
OLD | NEW |