| OLD | NEW |
| 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/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/test/integration/passwords_helper.h" | 8 #include "chrome/browser/sync/test/integration/passwords_helper.h" |
| 9 #include "chrome/browser/sync/test/integration/sessions_helper.h" | 9 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
| 10 #include "chrome/browser/sync/test/integration/sync_test.h" | 10 #include "chrome/browser/sync/test/integration/sync_test.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); | 59 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); |
| 60 } | 60 } |
| 61 | 61 |
| 62 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, | 62 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, |
| 63 SingleClientEnabledEncryption) { | 63 SingleClientEnabledEncryption) { |
| 64 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 64 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 65 | 65 |
| 66 ASSERT_TRUE(CheckInitialState(0)); | 66 ASSERT_TRUE(CheckInitialState(0)); |
| 67 ASSERT_TRUE(CheckInitialState(1)); | 67 ASSERT_TRUE(CheckInitialState(1)); |
| 68 | 68 |
| 69 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 69 ASSERT_TRUE(EnableEncryption(0, syncer::SESSIONS)); |
| 70 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 70 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 71 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); | 71 ASSERT_TRUE(IsEncrypted(0, syncer::SESSIONS)); |
| 72 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); | 72 ASSERT_TRUE(IsEncrypted(1, syncer::SESSIONS)); |
| 73 | 73 |
| 74 // Should enable encryption for all other types as well. Just check a subset. | 74 // Should enable encryption for all other types as well. Just check a subset. |
| 75 ASSERT_TRUE(IsEncrypted(1, syncable::PREFERENCES)); | 75 ASSERT_TRUE(IsEncrypted(1, syncer::PREFERENCES)); |
| 76 ASSERT_TRUE(IsEncrypted(1, syncable::BOOKMARKS)); | 76 ASSERT_TRUE(IsEncrypted(1, syncer::BOOKMARKS)); |
| 77 ASSERT_TRUE(IsEncrypted(1, syncable::APPS)); | 77 ASSERT_TRUE(IsEncrypted(1, syncer::APPS)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, | 80 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, |
| 81 SingleClientEnabledEncryptionAndChanged) { | 81 SingleClientEnabledEncryptionAndChanged) { |
| 82 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 82 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 83 | 83 |
| 84 ASSERT_TRUE(CheckInitialState(0)); | 84 ASSERT_TRUE(CheckInitialState(0)); |
| 85 ASSERT_TRUE(CheckInitialState(1)); | 85 ASSERT_TRUE(CheckInitialState(1)); |
| 86 | 86 |
| 87 ScopedWindowMap client0_windows; | 87 ScopedWindowMap client0_windows; |
| 88 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), | 88 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), |
| 89 client0_windows.GetMutable())); | 89 client0_windows.GetMutable())); |
| 90 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 90 ASSERT_TRUE(EnableEncryption(0, syncer::SESSIONS)); |
| 91 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 91 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 92 | 92 |
| 93 // Get foreign session data from client 1. | 93 // Get foreign session data from client 1. |
| 94 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); | 94 ASSERT_TRUE(IsEncrypted(1, syncer::SESSIONS)); |
| 95 SyncedSessionVector sessions1; | 95 SyncedSessionVector sessions1; |
| 96 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 96 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
| 97 | 97 |
| 98 // Verify client 1's foreign session matches client 0 current window. | 98 // Verify client 1's foreign session matches client 0 current window. |
| 99 ASSERT_EQ(1U, sessions1.size()); | 99 ASSERT_EQ(1U, sessions1.size()); |
| 100 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); | 100 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); |
| 101 } | 101 } |
| 102 | 102 |
| 103 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, | 103 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, |
| 104 BothClientsEnabledEncryption) { | 104 BothClientsEnabledEncryption) { |
| 105 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 105 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 106 | 106 |
| 107 ASSERT_TRUE(CheckInitialState(0)); | 107 ASSERT_TRUE(CheckInitialState(0)); |
| 108 ASSERT_TRUE(CheckInitialState(1)); | 108 ASSERT_TRUE(CheckInitialState(1)); |
| 109 | 109 |
| 110 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 110 ASSERT_TRUE(EnableEncryption(0, syncer::SESSIONS)); |
| 111 ASSERT_TRUE(EnableEncryption(1, syncable::SESSIONS)); | 111 ASSERT_TRUE(EnableEncryption(1, syncer::SESSIONS)); |
| 112 ASSERT_TRUE(AwaitQuiescence()); | 112 ASSERT_TRUE(AwaitQuiescence()); |
| 113 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); | 113 ASSERT_TRUE(IsEncrypted(0, syncer::SESSIONS)); |
| 114 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); | 114 ASSERT_TRUE(IsEncrypted(1, syncer::SESSIONS)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, BothChanged) { | 117 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, BothChanged) { |
| 118 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 118 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 119 | 119 |
| 120 ASSERT_TRUE(CheckInitialState(0)); | 120 ASSERT_TRUE(CheckInitialState(0)); |
| 121 ASSERT_TRUE(CheckInitialState(1)); | 121 ASSERT_TRUE(CheckInitialState(1)); |
| 122 | 122 |
| 123 // Open tabs on both clients and retain window information. | 123 // Open tabs on both clients and retain window information. |
| 124 ScopedWindowMap client0_windows; | 124 ScopedWindowMap client0_windows; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 ASSERT_FALSE(GetSessionData(1, &sessions1)); | 195 ASSERT_FALSE(GetSessionData(1, &sessions1)); |
| 196 | 196 |
| 197 // Client 0 becomes active again with a new tab. | 197 // Client 0 becomes active again with a new tab. |
| 198 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), | 198 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), |
| 199 client0_windows.GetMutable())); | 199 client0_windows.GetMutable())); |
| 200 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 200 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 201 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 201 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
| 202 ASSERT_EQ(1U, sessions1.size()); | 202 ASSERT_EQ(1U, sessions1.size()); |
| 203 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); | 203 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); |
| 204 } | 204 } |
| OLD | NEW |