Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: chrome/browser/sync/test/integration/two_client_sessions_sync_test.cc

Issue 7966020: [Sync] Fix Session's handling of windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 11
12 using sessions_helper::CheckInitialState; 12 using sessions_helper::CheckInitialState;
13 using sessions_helper::GetLocalWindows; 13 using sessions_helper::GetLocalWindows;
14 using sessions_helper::GetSessionData; 14 using sessions_helper::GetSessionData;
15 using sessions_helper::OpenTabAndGetLocalWindows; 15 using sessions_helper::OpenTabAndGetLocalWindows;
16 using sessions_helper::ScopedWindowMap;
17 using sessions_helper::SyncedSessionVector;
16 using sessions_helper::WindowsMatch; 18 using sessions_helper::WindowsMatch;
17 19
18 class TwoClientSessionsSyncTest : public SyncTest { 20 class TwoClientSessionsSyncTest : public SyncTest {
19 public: 21 public:
20 TwoClientSessionsSyncTest() : SyncTest(TWO_CLIENT) {} 22 TwoClientSessionsSyncTest() : SyncTest(TWO_CLIENT) {}
21 virtual ~TwoClientSessionsSyncTest() {} 23 virtual ~TwoClientSessionsSyncTest() {}
22 24
23 private: 25 private:
24 DISALLOW_COPY_AND_ASSIGN(TwoClientSessionsSyncTest); 26 DISALLOW_COPY_AND_ASSIGN(TwoClientSessionsSyncTest);
25 }; 27 };
26 28
27 static const char* kValidPassphrase = "passphrase!"; 29 static const char* kValidPassphrase = "passphrase!";
28 static const char* kURL1 = "chrome://sync"; 30 static const char* kURL1 = "chrome://sync";
29 static const char* kURL2 = "chrome://version"; 31 static const char* kURL2 = "chrome://version";
30 32
31 // TODO(zea): Test each individual session command we care about separately. 33 // TODO(zea): Test each individual session command we care about separately.
32 // (as well as multi-window). We're currently only checking basic single-window/ 34 // (as well as multi-window). We're currently only checking basic single-window/
33 // single-tab functionality. 35 // single-tab functionality.
34 36
35 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, SingleClientChanged) { 37 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, SingleClientChanged) {
36 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 38 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
37 39
38 ASSERT_TRUE(CheckInitialState(0)); 40 ASSERT_TRUE(CheckInitialState(0));
39 ASSERT_TRUE(CheckInitialState(1)); 41 ASSERT_TRUE(CheckInitialState(1));
40 42
41 ScopedVector<SessionWindow> client0_windows; 43 ScopedWindowMap client0_windows;
42 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), client0_windows.get())); 44 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1),
45 client0_windows.get()));
43 46
44 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 47 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
45 48
46 // Get foreign session data from client 1. 49 // Get foreign session data from client 1.
47 SyncedSessionVector sessions1; 50 SyncedSessionVector sessions1;
48 ASSERT_TRUE(GetSessionData(1, &sessions1)); 51 ASSERT_TRUE(GetSessionData(1, &sessions1));
49 52
50 // Verify client 1's foreign session matches client 0 current window. 53 // Verify client 1's foreign session matches client 0 current window.
51 ASSERT_EQ(1U, sessions1.size()); 54 ASSERT_EQ(1U, sessions1.size());
52 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows.get())); 55 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.get()));
53 } 56 }
54 57
55 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, 58 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
56 SingleClientEnabledEncryption) { 59 SingleClientEnabledEncryption) {
57 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 60 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
58 61
59 ASSERT_TRUE(CheckInitialState(0)); 62 ASSERT_TRUE(CheckInitialState(0));
60 ASSERT_TRUE(CheckInitialState(1)); 63 ASSERT_TRUE(CheckInitialState(1));
61 64
62 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); 65 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS));
63 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 66 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
64 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); 67 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS));
65 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); 68 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS));
66 69
67 // Should enable encryption for all other types as well. Just check a subset. 70 // Should enable encryption for all other types as well. Just check a subset.
68 ASSERT_TRUE(IsEncrypted(1, syncable::PREFERENCES)); 71 ASSERT_TRUE(IsEncrypted(1, syncable::PREFERENCES));
69 ASSERT_TRUE(IsEncrypted(1, syncable::BOOKMARKS)); 72 ASSERT_TRUE(IsEncrypted(1, syncable::BOOKMARKS));
70 ASSERT_TRUE(IsEncrypted(1, syncable::APPS)); 73 ASSERT_TRUE(IsEncrypted(1, syncable::APPS));
71 } 74 }
72 75
73 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, 76 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
74 SingleClientEnabledEncryptionAndChanged) { 77 SingleClientEnabledEncryptionAndChanged) {
75 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 78 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
76 79
77 ASSERT_TRUE(CheckInitialState(0)); 80 ASSERT_TRUE(CheckInitialState(0));
78 ASSERT_TRUE(CheckInitialState(1)); 81 ASSERT_TRUE(CheckInitialState(1));
79 82
80 ScopedVector<SessionWindow> client0_windows; 83 ScopedWindowMap client0_windows;
81 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), client0_windows.get())); 84 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1),
85 client0_windows.get()));
82 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); 86 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS));
83 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 87 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
84 88
85 // Get foreign session data from client 1. 89 // Get foreign session data from client 1.
86 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); 90 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS));
87 SyncedSessionVector sessions1; 91 SyncedSessionVector sessions1;
88 ASSERT_TRUE(GetSessionData(1, &sessions1)); 92 ASSERT_TRUE(GetSessionData(1, &sessions1));
89 93
90 // Verify client 1's foreign session matches client 0 current window. 94 // Verify client 1's foreign session matches client 0 current window.
91 ASSERT_EQ(1U, sessions1.size()); 95 ASSERT_EQ(1U, sessions1.size());
92 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows.get())); 96 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.get()));
93 } 97 }
94 98
95 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, 99 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
96 BothClientsEnabledEncryption) { 100 BothClientsEnabledEncryption) {
97 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 101 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
98 102
99 ASSERT_TRUE(CheckInitialState(0)); 103 ASSERT_TRUE(CheckInitialState(0));
100 ASSERT_TRUE(CheckInitialState(1)); 104 ASSERT_TRUE(CheckInitialState(1));
101 105
102 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); 106 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS));
103 ASSERT_TRUE(EnableEncryption(1, syncable::SESSIONS)); 107 ASSERT_TRUE(EnableEncryption(1, syncable::SESSIONS));
104 ASSERT_TRUE(AwaitQuiescence()); 108 ASSERT_TRUE(AwaitQuiescence());
105 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); 109 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS));
106 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); 110 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS));
107 } 111 }
108 112
109 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, BothChanged) { 113 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, BothChanged) {
110 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 114 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
111 115
112 ASSERT_TRUE(CheckInitialState(0)); 116 ASSERT_TRUE(CheckInitialState(0));
113 ASSERT_TRUE(CheckInitialState(1)); 117 ASSERT_TRUE(CheckInitialState(1));
114 118
115 // Open tabs on both clients and retain window information. 119 // Open tabs on both clients and retain window information.
116 ScopedVector<SessionWindow> client0_windows; 120 ScopedWindowMap client0_windows;
117 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), client0_windows.get())); 121 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2),
118 ScopedVector<SessionWindow> client1_windows; 122 client0_windows.get()));
119 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), client1_windows.get())); 123 ScopedWindowMap client1_windows;
124 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1),
125 client1_windows.get()));
120 126
121 // Wait for sync. 127 // Wait for sync.
122 ASSERT_TRUE(AwaitQuiescence()); 128 ASSERT_TRUE(AwaitQuiescence());
123 129
124 // Get foreign session data from client 0 and 1. 130 // Get foreign session data from client 0 and 1.
125 SyncedSessionVector sessions0; 131 SyncedSessionVector sessions0;
126 SyncedSessionVector sessions1; 132 SyncedSessionVector sessions1;
127 ASSERT_TRUE(GetSessionData(0, &sessions0)); 133 ASSERT_TRUE(GetSessionData(0, &sessions0));
128 ASSERT_TRUE(GetSessionData(1, &sessions1)); 134 ASSERT_TRUE(GetSessionData(1, &sessions1));
129 135
130 // Verify client 1's foreign session matches client 0's current window and 136 // Verify client 1's foreign session matches client 0's current window and
131 // vice versa. 137 // vice versa.
132 ASSERT_EQ(1U, sessions0.size()); 138 ASSERT_EQ(1U, sessions0.size());
133 ASSERT_EQ(1U, sessions1.size()); 139 ASSERT_EQ(1U, sessions1.size());
134 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows.get())); 140 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.get()));
135 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, client1_windows.get())); 141 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, *client1_windows.get()));
136 } 142 }
137 143
138 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, 144 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
139 FirstChangesAndSetsPassphrase) { 145 FirstChangesAndSetsPassphrase) {
140 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 146 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
141 147
142 ASSERT_TRUE(CheckInitialState(0)); 148 ASSERT_TRUE(CheckInitialState(0));
143 ASSERT_TRUE(CheckInitialState(1)); 149 ASSERT_TRUE(CheckInitialState(1));
144 150
145 ScopedVector<SessionWindow> client0_windows; 151 ScopedWindowMap client0_windows;
146 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), client0_windows.get())); 152 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1),
153 client0_windows.get()));
147 154
148 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); 155 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS));
149 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); 156 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true);
150 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); 157 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted());
151 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 158 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
152 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); 159 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired());
153 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> 160 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
154 num_blocking_conflicting_updates); 161 num_blocking_conflicting_updates);
155 // We have 6 non-blocking conflicts due to the two meta nodes (one for each 162 // We have 6 non-blocking conflicts due to the two meta nodes (one for each
156 // client), the one tab node, and the three basic preference/themes. 163 // client), the one tab node, and the three basic preference/themes.
157 ASSERT_EQ(6, GetClient(1)->GetLastSessionSnapshot()-> 164 ASSERT_EQ(6, GetClient(1)->GetLastSessionSnapshot()->
158 num_conflicting_updates); // The encrypted nodes. 165 num_conflicting_updates); // The encrypted nodes.
159 166
160 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); 167 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true);
161 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); 168 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted());
162 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); 169 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS));
163 170
164 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); 171 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS));
165 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); 172 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS));
166 // Get foreign session data from client 0 and 1. 173 // Get foreign session data from client 0 and 1.
167 SyncedSessionVector sessions1; 174 SyncedSessionVector sessions1;
168 ASSERT_TRUE(GetSessionData(1, &sessions1)); 175 ASSERT_TRUE(GetSessionData(1, &sessions1));
169 176
170 // Verify client 1's foreign session matches client 0's current window and 177 // Verify client 1's foreign session matches client 0's current window and
171 // vice versa. 178 // vice versa.
172 ASSERT_EQ(1U, sessions1.size()); 179 ASSERT_EQ(1U, sessions1.size());
173 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows.get())); 180 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.get()));
174 } 181 }
175 182
176 // Flaky (number of conflicting nodes is off). http://crbug.com/89604. 183 // Flaky (number of conflicting nodes is off). http://crbug.com/89604.
177 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, 184 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
178 FLAKY_FirstChangesWhileSecondWaitingForPassphrase) { 185 FLAKY_FirstChangesWhileSecondWaitingForPassphrase) {
179 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 186 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
180 187
181 ASSERT_TRUE(CheckInitialState(0)); 188 ASSERT_TRUE(CheckInitialState(0));
182 ASSERT_TRUE(CheckInitialState(1)); 189 ASSERT_TRUE(CheckInitialState(1));
183 190
184 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); 191 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS));
185 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); 192 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true);
186 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); 193 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted());
187 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 194 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
188 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); 195 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired());
189 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> 196 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
190 num_blocking_conflicting_updates); 197 num_blocking_conflicting_updates);
191 // We have five non-blocking conflicts due to the two meta nodes (one for each 198 // We have five non-blocking conflicts due to the two meta nodes (one for each
192 // client), and the 3 basic preference/themes nodes. 199 // client), and the 3 basic preference/themes nodes.
193 ASSERT_EQ(5, GetClient(1)->GetLastSessionSnapshot()-> 200 ASSERT_EQ(5, GetClient(1)->GetLastSessionSnapshot()->
194 num_conflicting_updates); // The encrypted nodes. 201 num_conflicting_updates); // The encrypted nodes.
195 202
196 ScopedVector<SessionWindow> client0_windows; 203 ScopedWindowMap client0_windows;
197 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), client0_windows.get())); 204 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1),
205 client0_windows.get()));
198 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 206 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
199 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> 207 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
200 num_blocking_conflicting_updates); 208 num_blocking_conflicting_updates);
201 ASSERT_EQ(6, GetClient(1)->GetLastSessionSnapshot()-> 209 ASSERT_EQ(6, GetClient(1)->GetLastSessionSnapshot()->
202 num_conflicting_updates); // The encrypted nodes. 210 num_conflicting_updates); // The encrypted nodes.
203 211
204 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); 212 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true);
205 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); 213 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted());
206 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); 214 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS));
207 215
208 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); 216 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS));
209 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); 217 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS));
210 // Get foreign session data from client 0 and 1. 218 // Get foreign session data from client 0 and 1.
211 SyncedSessionVector sessions1; 219 SyncedSessionVector sessions1;
212 ASSERT_TRUE(GetSessionData(1, &sessions1)); 220 ASSERT_TRUE(GetSessionData(1, &sessions1));
213 221
214 // Verify client 1's foreign session matches client 0's current window and 222 // Verify client 1's foreign session matches client 0's current window and
215 // vice versa. 223 // vice versa.
216 ASSERT_EQ(1U, sessions1.size()); 224 ASSERT_EQ(1U, sessions1.size());
217 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows.get())); 225 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.get()));
218 } 226 }
219 227
220 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, 228 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
221 SecondChangesAfterEncrAndPassphraseChange) { 229 SecondChangesAfterEncrAndPassphraseChange) {
222 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 230 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
223 231
224 ASSERT_TRUE(CheckInitialState(0)); 232 ASSERT_TRUE(CheckInitialState(0));
225 ASSERT_TRUE(CheckInitialState(1)); 233 ASSERT_TRUE(CheckInitialState(1));
226 234
227 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); 235 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS));
228 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); 236 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true);
229 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); 237 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted());
230 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 238 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
231 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); 239 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired());
232 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> 240 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
233 num_blocking_conflicting_updates); 241 num_blocking_conflicting_updates);
234 // We have two non-blocking conflicts due to the two meta nodes (one for each 242 // We have two non-blocking conflicts due to the two meta nodes (one for each
235 // client), and the 3 basic preference/themes nodes.. 243 // client), and the 3 basic preference/themes nodes..
236 ASSERT_EQ(5, GetClient(1)->GetLastSessionSnapshot()-> 244 ASSERT_EQ(5, GetClient(1)->GetLastSessionSnapshot()->
237 num_conflicting_updates); // The encrypted nodes. 245 num_conflicting_updates); // The encrypted nodes.
238 246
239 // These changes are either made with the old passphrase or not encrypted at 247 // These changes are either made with the old passphrase or not encrypted at
240 // all depending on when client 0's changes are propagated. 248 // all depending on when client 0's changes are propagated.
241 ScopedVector<SessionWindow> client1_windows; 249 ScopedWindowMap client1_windows;
242 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), client1_windows.get())); 250 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1),
251 client1_windows.get()));
243 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); 252 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
244 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> 253 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
245 num_blocking_conflicting_updates); 254 num_blocking_conflicting_updates);
246 ASSERT_EQ(5, GetClient(1)->GetLastSessionSnapshot()-> 255 ASSERT_EQ(5, GetClient(1)->GetLastSessionSnapshot()->
247 num_conflicting_updates); // The same encrypted nodes. 256 num_conflicting_updates); // The same encrypted nodes.
248 257
249 // At this point we enter the passphrase, triggering a resync, in which the 258 // At this point we enter the passphrase, triggering a resync, in which the
250 // local changes of client 1 get overwritten for now. 259 // local changes of client 1 get overwritten for now.
251 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); 260 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true);
252 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); 261 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted());
(...skipping 11 matching lines...) Expand all
264 273
265 // Flaky. http://crbug.com/85294 274 // Flaky. http://crbug.com/85294
266 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, 275 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
267 FLAKY_SecondChangesBeforeEncrAndPassphraseChange) { 276 FLAKY_SecondChangesBeforeEncrAndPassphraseChange) {
268 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 277 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
269 278
270 ASSERT_TRUE(CheckInitialState(0)); 279 ASSERT_TRUE(CheckInitialState(0));
271 ASSERT_TRUE(CheckInitialState(1)); 280 ASSERT_TRUE(CheckInitialState(1));
272 281
273 // These changes are either made on client 1 without encryption. 282 // These changes are either made on client 1 without encryption.
274 ScopedVector<SessionWindow> client1_windows; 283 ScopedWindowMap client1_windows;
275 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), client1_windows.get())); 284 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1),
285 client1_windows.get()));
276 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); 286 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
277 287
278 // Turn encryption on client 0. Client 1's foreign will be encrypted with the 288 // Turn encryption on client 0. Client 1's foreign will be encrypted with the
279 // new passphrase and synced back. It will be unable to decrypt it yet. 289 // new passphrase and synced back. It will be unable to decrypt it yet.
280 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); 290 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS));
281 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); 291 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true);
282 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); 292 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted());
283 ASSERT_TRUE(AwaitQuiescence()); 293 ASSERT_TRUE(AwaitQuiescence());
284 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); 294 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired());
285 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> 295 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
(...skipping 10 matching lines...) Expand all
296 306
297 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); 307 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS));
298 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); 308 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS));
299 // Client 0's foreign data should match client 1's local data. Client 1's 309 // Client 0's foreign data should match client 1's local data. Client 1's
300 // foreign data is empty because client 0 did not open any tabs. 310 // foreign data is empty because client 0 did not open any tabs.
301 SyncedSessionVector sessions0; 311 SyncedSessionVector sessions0;
302 SyncedSessionVector sessions1; 312 SyncedSessionVector sessions1;
303 ASSERT_TRUE(GetSessionData(0, &sessions0)); 313 ASSERT_TRUE(GetSessionData(0, &sessions0));
304 ASSERT_FALSE(GetSessionData(1, &sessions1)); 314 ASSERT_FALSE(GetSessionData(1, &sessions1));
305 ASSERT_EQ(1U, sessions0.size()); 315 ASSERT_EQ(1U, sessions0.size());
306 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, client1_windows.get())); 316 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, *client1_windows.get()));
307 } 317 }
308 318
309 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, 319 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
310 BothChangeWithEncryptionAndPassphrase) { 320 BothChangeWithEncryptionAndPassphrase) {
311 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 321 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
312 322
313 ASSERT_TRUE(CheckInitialState(0)); 323 ASSERT_TRUE(CheckInitialState(0));
314 ASSERT_TRUE(CheckInitialState(1)); 324 ASSERT_TRUE(CheckInitialState(1));
315 325
316 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); 326 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true);
317 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); 327 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted());
318 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 328 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
319 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); 329 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired());
320 330
321 // 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
322 // them due to the missing passphrase. 332 // them due to the missing passphrase.
323 ScopedVector<SessionWindow> client0_windows; 333 ScopedWindowMap client0_windows;
324 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), client0_windows.get())); 334 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1),
335 client0_windows.get()));
325 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); 336 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS));
326 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 337 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
327 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> 338 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
328 num_blocking_conflicting_updates); 339 num_blocking_conflicting_updates);
329 // 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
330 // each client), the one tab node, and the 3 basic preference/themes nodes. 341 // each client), the one tab node, and the 3 basic preference/themes nodes.
331 ASSERT_EQ(6, GetClient(1)->GetLastSessionSnapshot()-> 342 ASSERT_EQ(6, GetClient(1)->GetLastSessionSnapshot()->
332 num_conflicting_updates); // The encrypted nodes. 343 num_conflicting_updates); // The encrypted nodes.
333 344
334 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); 345 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true);
335 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); 346 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted());
336 ASSERT_FALSE(GetClient(1)->service()->IsPassphraseRequired()); 347 ASSERT_FALSE(GetClient(1)->service()->IsPassphraseRequired());
337 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); 348 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS));
338 349
339 // Open windows on client 1, which should automatically be encrypted. 350 // Open windows on client 1, which should automatically be encrypted.
340 ScopedVector<SessionWindow> client1_windows; 351 ScopedWindowMap client1_windows;
341 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL2), client1_windows.get())); 352 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL2),
353 client1_windows.get()));
342 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); 354 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
343 355
344 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); 356 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS));
345 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); 357 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS));
346 // Get foreign session data from client 0 and 1. 358 // Get foreign session data from client 0 and 1.
347 SyncedSessionVector sessions0; 359 SyncedSessionVector sessions0;
348 SyncedSessionVector sessions1; 360 SyncedSessionVector sessions1;
349 ASSERT_TRUE(GetSessionData(0, &sessions0)); 361 ASSERT_TRUE(GetSessionData(0, &sessions0));
350 ASSERT_TRUE(GetSessionData(1, &sessions1)); 362 ASSERT_TRUE(GetSessionData(1, &sessions1));
351 363
352 // Verify client 1's foreign session matches client 0's current window and 364 // Verify client 1's foreign session matches client 0's current window and
353 // vice versa. 365 // vice versa.
354 ASSERT_EQ(1U, sessions0.size()); 366 ASSERT_EQ(1U, sessions0.size());
355 ASSERT_EQ(1U, sessions1.size()); 367 ASSERT_EQ(1U, sessions1.size());
356 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows.get())); 368 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.get()));
357 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, client1_windows.get())); 369 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, *client1_windows.get()));
358 } 370 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698