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 19 matching lines...) Expand all Loading... |
30 DISALLOW_COPY_AND_ASSIGN(TwoClientSessionsSyncTest); | 30 DISALLOW_COPY_AND_ASSIGN(TwoClientSessionsSyncTest); |
31 }; | 31 }; |
32 | 32 |
33 static const char* kURL1 = "http://127.0.0.1/bubba1"; | 33 static const char* kURL1 = "http://127.0.0.1/bubba1"; |
34 static const char* kURL2 = "http://127.0.0.1/bubba2"; | 34 static const char* kURL2 = "http://127.0.0.1/bubba2"; |
35 | 35 |
36 // TODO(zea): Test each individual session command we care about separately. | 36 // TODO(zea): Test each individual session command we care about separately. |
37 // (as well as multi-window). We're currently only checking basic single-window/ | 37 // (as well as multi-window). We're currently only checking basic single-window/ |
38 // single-tab functionality. | 38 // single-tab functionality. |
39 | 39 |
| 40 // Fails on Win, see http://crbug.com/232313 |
| 41 #if defined(OS_WIN) |
| 42 #define MAYBE_SingleClientChanged DISABLED_SingleClientChanged |
| 43 #define MAYBE_SingleClientEnabledEncryptionAndChanged DISABLED_SingleClientEnabl
edEncryptionAndChanged |
| 44 #define MAYBE_BothChanged DISABLED_BothChanged |
| 45 #define MAYBE_DeleteIdleSession DISABLED_DeleteIdleSession |
| 46 #define MAYBE_DeleteActiveSession DISABLED_DeleteActiveSession |
| 47 #else |
| 48 #define MAYBE_SingleClientChanged SingleClientChanged |
| 49 #define MAYBE_SingleClientEnabledEncryptionAndChanged SingleClientEnabledEncrypt
ionAndChanged |
| 50 #define MAYBE_BothChanged BothChanged |
| 51 #define MAYBE_DeleteIdleSession DeleteIdleSession |
| 52 #define MAYBE_DeleteActiveSession DeleteActiveSession |
| 53 #endif |
| 54 |
| 55 |
40 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, | 56 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, |
41 SingleClientChanged) { | 57 MAYBE_SingleClientChanged) { |
42 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 58 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
43 | 59 |
44 ASSERT_TRUE(CheckInitialState(0)); | 60 ASSERT_TRUE(CheckInitialState(0)); |
45 ASSERT_TRUE(CheckInitialState(1)); | 61 ASSERT_TRUE(CheckInitialState(1)); |
46 | 62 |
47 ScopedWindowMap client0_windows; | 63 ScopedWindowMap client0_windows; |
48 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), | 64 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), |
49 client0_windows.GetMutable())); | 65 client0_windows.GetMutable())); |
50 | 66 |
51 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 67 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
(...skipping 19 matching lines...) Expand all Loading... |
71 ASSERT_TRUE(IsEncrypted(0, syncer::SESSIONS)); | 87 ASSERT_TRUE(IsEncrypted(0, syncer::SESSIONS)); |
72 ASSERT_TRUE(IsEncrypted(1, syncer::SESSIONS)); | 88 ASSERT_TRUE(IsEncrypted(1, syncer::SESSIONS)); |
73 | 89 |
74 // Should enable encryption for all other types as well. Just check a subset. | 90 // Should enable encryption for all other types as well. Just check a subset. |
75 ASSERT_TRUE(IsEncrypted(1, syncer::PREFERENCES)); | 91 ASSERT_TRUE(IsEncrypted(1, syncer::PREFERENCES)); |
76 ASSERT_TRUE(IsEncrypted(1, syncer::BOOKMARKS)); | 92 ASSERT_TRUE(IsEncrypted(1, syncer::BOOKMARKS)); |
77 ASSERT_TRUE(IsEncrypted(1, syncer::APPS)); | 93 ASSERT_TRUE(IsEncrypted(1, syncer::APPS)); |
78 } | 94 } |
79 | 95 |
80 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, | 96 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, |
81 SingleClientEnabledEncryptionAndChanged) { | 97 MAYBE_SingleClientEnabledEncryptionAndChanged) { |
82 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 98 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
83 | 99 |
84 ASSERT_TRUE(CheckInitialState(0)); | 100 ASSERT_TRUE(CheckInitialState(0)); |
85 ASSERT_TRUE(CheckInitialState(1)); | 101 ASSERT_TRUE(CheckInitialState(1)); |
86 | 102 |
87 ScopedWindowMap client0_windows; | 103 ScopedWindowMap client0_windows; |
88 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), | 104 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), |
89 client0_windows.GetMutable())); | 105 client0_windows.GetMutable())); |
90 ASSERT_TRUE(EnableEncryption(0, syncer::SESSIONS)); | 106 ASSERT_TRUE(EnableEncryption(0, syncer::SESSIONS)); |
91 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 107 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
(...skipping 15 matching lines...) Expand all Loading... |
107 ASSERT_TRUE(CheckInitialState(0)); | 123 ASSERT_TRUE(CheckInitialState(0)); |
108 ASSERT_TRUE(CheckInitialState(1)); | 124 ASSERT_TRUE(CheckInitialState(1)); |
109 | 125 |
110 ASSERT_TRUE(EnableEncryption(0, syncer::SESSIONS)); | 126 ASSERT_TRUE(EnableEncryption(0, syncer::SESSIONS)); |
111 ASSERT_TRUE(EnableEncryption(1, syncer::SESSIONS)); | 127 ASSERT_TRUE(EnableEncryption(1, syncer::SESSIONS)); |
112 ASSERT_TRUE(AwaitQuiescence()); | 128 ASSERT_TRUE(AwaitQuiescence()); |
113 ASSERT_TRUE(IsEncrypted(0, syncer::SESSIONS)); | 129 ASSERT_TRUE(IsEncrypted(0, syncer::SESSIONS)); |
114 ASSERT_TRUE(IsEncrypted(1, syncer::SESSIONS)); | 130 ASSERT_TRUE(IsEncrypted(1, syncer::SESSIONS)); |
115 } | 131 } |
116 | 132 |
117 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, BothChanged) { | 133 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, MAYBE_BothChanged) { |
118 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 134 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
119 | 135 |
120 ASSERT_TRUE(CheckInitialState(0)); | 136 ASSERT_TRUE(CheckInitialState(0)); |
121 ASSERT_TRUE(CheckInitialState(1)); | 137 ASSERT_TRUE(CheckInitialState(1)); |
122 | 138 |
123 // Open tabs on both clients and retain window information. | 139 // Open tabs on both clients and retain window information. |
124 ScopedWindowMap client0_windows; | 140 ScopedWindowMap client0_windows; |
125 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), | 141 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), |
126 client0_windows.GetMutable())); | 142 client0_windows.GetMutable())); |
127 ScopedWindowMap client1_windows; | 143 ScopedWindowMap client1_windows; |
(...skipping 10 matching lines...) Expand all Loading... |
138 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 154 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
139 | 155 |
140 // Verify client 1's foreign session matches client 0's current window and | 156 // Verify client 1's foreign session matches client 0's current window and |
141 // vice versa. | 157 // vice versa. |
142 ASSERT_EQ(1U, sessions0.size()); | 158 ASSERT_EQ(1U, sessions0.size()); |
143 ASSERT_EQ(1U, sessions1.size()); | 159 ASSERT_EQ(1U, sessions1.size()); |
144 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); | 160 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); |
145 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, *client1_windows.Get())); | 161 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, *client1_windows.Get())); |
146 } | 162 } |
147 | 163 |
148 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, DeleteIdleSession) { | 164 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, MAYBE_DeleteIdleSession) { |
149 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 165 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
150 | 166 |
151 ASSERT_TRUE(CheckInitialState(0)); | 167 ASSERT_TRUE(CheckInitialState(0)); |
152 ASSERT_TRUE(CheckInitialState(1)); | 168 ASSERT_TRUE(CheckInitialState(1)); |
153 | 169 |
154 // Client 0 opened some tabs then went idle. | 170 // Client 0 opened some tabs then went idle. |
155 ScopedWindowMap client0_windows; | 171 ScopedWindowMap client0_windows; |
156 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), | 172 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), |
157 client0_windows.GetMutable())); | 173 client0_windows.GetMutable())); |
158 | 174 |
159 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 175 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
160 | 176 |
161 // Get foreign session data from client 1. | 177 // Get foreign session data from client 1. |
162 SyncedSessionVector sessions1; | 178 SyncedSessionVector sessions1; |
163 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 179 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
164 | 180 |
165 // Verify client 1's foreign session matches client 0 current window. | 181 // Verify client 1's foreign session matches client 0 current window. |
166 ASSERT_EQ(1U, sessions1.size()); | 182 ASSERT_EQ(1U, sessions1.size()); |
167 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); | 183 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); |
168 | 184 |
169 // Client 1 now deletes client 0's tabs. This frees the memory of sessions1. | 185 // Client 1 now deletes client 0's tabs. This frees the memory of sessions1. |
170 DeleteForeignSession(1, sessions1[0]->session_tag); | 186 DeleteForeignSession(1, sessions1[0]->session_tag); |
171 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 187 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
172 ASSERT_FALSE(GetSessionData(1, &sessions1)); | 188 ASSERT_FALSE(GetSessionData(1, &sessions1)); |
173 } | 189 } |
174 | 190 |
175 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, DeleteActiveSession) { | 191 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, MAYBE_DeleteActiveSession) { |
176 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 192 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
177 | 193 |
178 ASSERT_TRUE(CheckInitialState(0)); | 194 ASSERT_TRUE(CheckInitialState(0)); |
179 ASSERT_TRUE(CheckInitialState(1)); | 195 ASSERT_TRUE(CheckInitialState(1)); |
180 | 196 |
181 // Client 0 opened some tabs then went idle. | 197 // Client 0 opened some tabs then went idle. |
182 ScopedWindowMap client0_windows; | 198 ScopedWindowMap client0_windows; |
183 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), | 199 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), |
184 client0_windows.GetMutable())); | 200 client0_windows.GetMutable())); |
185 | 201 |
186 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 202 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
187 SyncedSessionVector sessions1; | 203 SyncedSessionVector sessions1; |
188 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 204 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
189 ASSERT_EQ(1U, sessions1.size()); | 205 ASSERT_EQ(1U, sessions1.size()); |
190 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); | 206 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); |
191 | 207 |
192 // Client 1 now deletes client 0's tabs. This frees the memory of sessions1. | 208 // Client 1 now deletes client 0's tabs. This frees the memory of sessions1. |
193 DeleteForeignSession(1, sessions1[0]->session_tag); | 209 DeleteForeignSession(1, sessions1[0]->session_tag); |
194 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 210 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
195 ASSERT_FALSE(GetSessionData(1, &sessions1)); | 211 ASSERT_FALSE(GetSessionData(1, &sessions1)); |
196 | 212 |
197 // Client 0 becomes active again with a new tab. | 213 // Client 0 becomes active again with a new tab. |
198 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), | 214 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), |
199 client0_windows.GetMutable())); | 215 client0_windows.GetMutable())); |
200 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 216 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
201 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 217 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
202 ASSERT_EQ(1U, sessions1.size()); | 218 ASSERT_EQ(1U, sessions1.size()); |
203 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); | 219 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); |
204 } | 220 } |
OLD | NEW |