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

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

Issue 2722953002: Revert of [sync] Add Sessions integration tests (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/macros.h" 5 #include "base/macros.h"
6 #include "base/test/histogram_tester.h" 6 #include "base/test/histogram_tester.h"
7 #include "chrome/browser/sessions/session_service.h" 7 #include "chrome/browser/sessions/session_service.h"
8 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 8 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
9 #include "chrome/browser/sync/test/integration/session_hierarchy_match_checker.h "
10 #include "chrome/browser/sync/test/integration/sessions_helper.h" 9 #include "chrome/browser/sync/test/integration/sessions_helper.h"
11 #include "chrome/browser/sync/test/integration/sync_test.h" 10 #include "chrome/browser/sync/test/integration/sync_test.h"
12 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" 11 #include "chrome/browser/sync/test/integration/typed_urls_helper.h"
13 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h " 12 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h "
14 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
16 #include "components/browser_sync/profile_sync_service.h" 15 #include "components/browser_sync/profile_sync_service.h"
17 #include "components/history/core/browser/history_types.h" 16 #include "components/history/core/browser/history_types.h"
18 #include "components/sessions/core/session_types.h" 17 #include "components/sessions/core/session_types.h"
19 #include "components/sync/base/time.h" 18 #include "components/sync/base/time.h"
20 #include "components/sync/driver/sync_driver_switches.h" 19 #include "components/sync/driver/sync_driver_switches.h"
20 #include "components/sync/test/fake_server/fake_server_verifier.h"
21 #include "components/sync/test/fake_server/sessions_hierarchy.h" 21 #include "components/sync/test/fake_server/sessions_hierarchy.h"
22 22
23 #if defined(OS_CHROMEOS) 23 #if defined(OS_CHROMEOS)
24 #include "chromeos/chromeos_switches.h" 24 #include "chromeos/chromeos_switches.h"
25 #endif 25 #endif
26 26
27 using base::HistogramBase; 27 using base::HistogramBase;
28 using base::HistogramSamples; 28 using base::HistogramSamples;
29 using base::HistogramTester; 29 using base::HistogramTester;
30 using fake_server::SessionsHierarchy; 30 using fake_server::SessionsHierarchy;
31 using sessions_helper::CheckInitialState; 31 using sessions_helper::CheckInitialState;
32 using sessions_helper::GetLocalWindows; 32 using sessions_helper::GetLocalWindows;
33 using sessions_helper::GetSessionData; 33 using sessions_helper::GetSessionData;
34 using sessions_helper::ModelAssociatorHasTabWithUrl; 34 using sessions_helper::ModelAssociatorHasTabWithUrl;
35 using sessions_helper::MoveTab; 35 using sessions_helper::OpenTabAndGetLocalWindows;
36 using sessions_helper::NavigateTab;
37 using sessions_helper::NavigateTabBack;
38 using sessions_helper::NavigateTabForward;
39 using sessions_helper::OpenTab;
40 using sessions_helper::OpenTabAtIndex;
41 using sessions_helper::ScopedWindowMap; 36 using sessions_helper::ScopedWindowMap;
42 using sessions_helper::SessionWindowMap; 37 using sessions_helper::SessionWindowMap;
43 using sessions_helper::SyncedSessionVector; 38 using sessions_helper::SyncedSessionVector;
44 using sessions_helper::WaitForTabsToLoad; 39 using sessions_helper::WaitForTabsToLoad;
45 using sessions_helper::WindowsMatch; 40 using sessions_helper::WindowsMatch;
46 using typed_urls_helper::GetUrlFromClient; 41 using typed_urls_helper::GetUrlFromClient;
47 42
48 namespace { 43 namespace {
49 44
50 void ExpectUniqueSampleGE(const HistogramTester& histogram_tester, 45 void ExpectUniqueSampleGE(const HistogramTester& histogram_tester,
(...skipping 28 matching lines...) Expand all
79 #if defined(OS_CHROMEOS) 74 #if defined(OS_CHROMEOS)
80 // kIgnoreUserProfileMappingForTests will let UserManager always return 75 // kIgnoreUserProfileMappingForTests will let UserManager always return
81 // active user. If this switch is not set, sync test's profile will not 76 // active user. If this switch is not set, sync test's profile will not
82 // match UserManager's active user, then UserManager won't return active 77 // match UserManager's active user, then UserManager won't return active
83 // user to our tests. 78 // user to our tests.
84 if (!cl->HasSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests)) 79 if (!cl->HasSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests))
85 cl->AppendSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests); 80 cl->AppendSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests);
86 #endif 81 #endif
87 } 82 }
88 83
89 void ExpectNavigationChain(const std::vector<GURL>& urls) {
90 ScopedWindowMap windows;
91 ASSERT_TRUE(GetLocalWindows(0, &windows));
92 ASSERT_EQ(windows.begin()->second->tabs.size(), 1u);
93 sessions::SessionTab* tab = windows.begin()->second->tabs[0].get();
94
95 int index = 0;
96 EXPECT_EQ(urls.size(), tab->navigations.size());
97 for (auto it = tab->navigations.begin(); it != tab->navigations.end();
98 ++it, ++index) {
99 EXPECT_EQ(urls[index], it->virtual_url());
100 }
101 }
102
103 // Block until the expected hierarchy is recorded on the FakeServer for
104 // profile 0. This will time out if the hierarchy is never
105 // recorded.
106 void WaitForHierarchyOnServer(
107 const fake_server::SessionsHierarchy& hierarchy) {
108 SessionHierarchyMatchChecker checker(hierarchy, GetSyncService(0),
109 GetFakeServer());
110 EXPECT_TRUE(checker.Wait());
111 }
112
113 // Shortcut to call WaitForHierarchyOnServer for only |url| in a single
114 // window.
115 void WaitForURLOnServer(const GURL& url) {
116 WaitForHierarchyOnServer({{url.spec()}});
117 }
118
119 private: 84 private:
120 DISALLOW_COPY_AND_ASSIGN(SingleClientSessionsSyncTest); 85 DISALLOW_COPY_AND_ASSIGN(SingleClientSessionsSyncTest);
121 }; 86 };
122 87
123 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, Sanity) { 88 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, Sanity) {
124 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 89 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
125 90
126 ASSERT_TRUE(CheckInitialState(0)); 91 ASSERT_TRUE(CheckInitialState(0));
127 92
128 // Add a new session to client 0 and wait for it to sync. 93 // Add a new session to client 0 and wait for it to sync.
129 ScopedWindowMap old_windows; 94 ScopedWindowMap old_windows;
130 GURL url = GURL("http://127.0.0.1/bubba"); 95 GURL url = GURL("http://127.0.0.1/bubba");
131 ASSERT_TRUE(OpenTab(0, url)); 96 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows));
132 ASSERT_TRUE(GetLocalWindows(0, &old_windows));
133 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); 97 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait());
134 98
135 // Get foreign session data from client 0. 99 // Get foreign session data from client 0.
136 SyncedSessionVector sessions; 100 SyncedSessionVector sessions;
137 ASSERT_FALSE(GetSessionData(0, &sessions)); 101 ASSERT_FALSE(GetSessionData(0, &sessions));
138 ASSERT_EQ(0U, sessions.size()); 102 ASSERT_EQ(0U, sessions.size());
139 103
140 // Verify client didn't change. 104 // Verify client didn't change.
141 ScopedWindowMap new_windows; 105 ScopedWindowMap new_windows;
142 ASSERT_TRUE(GetLocalWindows(0, &new_windows)); 106 ASSERT_TRUE(GetLocalWindows(0, &new_windows));
143 ASSERT_TRUE(WindowsMatch(old_windows, new_windows)); 107 ASSERT_TRUE(WindowsMatch(old_windows, new_windows));
144 108
145 WaitForURLOnServer(url); 109 fake_server::FakeServerVerifier fake_server_verifier(GetFakeServer());
110 SessionsHierarchy expected_sessions;
111 expected_sessions.AddWindow(url.spec());
112 ASSERT_TRUE(fake_server_verifier.VerifySessions(expected_sessions));
146 } 113 }
147 114
148 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, NoSessions) { 115 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, NoSessions) {
149 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 116 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
150 117
151 WaitForHierarchyOnServer(SessionsHierarchy()); 118 fake_server::FakeServerVerifier fake_server_verifier(GetFakeServer());
119 SessionsHierarchy expected_sessions;
120 ASSERT_TRUE(fake_server_verifier.VerifySessions(expected_sessions));
152 } 121 }
153 122
154 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ChromeHistory) { 123 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ChromeHistory) {
155 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 124 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
156 125
157 ASSERT_TRUE(CheckInitialState(0)); 126 ASSERT_TRUE(CheckInitialState(0));
158 127
159 ASSERT_TRUE(OpenTab(0, GURL(chrome::kChromeUIHistoryURL))); 128 // Add a new session to client 0 and wait for it to sync.
160 WaitForURLOnServer(GURL(chrome::kChromeUIHistoryURL)); 129 ScopedWindowMap old_windows;
130 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(chrome::kChromeUIHistoryURL),
131 &old_windows));
132 std::vector<GURL> urls;
133 urls.push_back(GURL(chrome::kChromeUIHistoryURL));
134 ASSERT_TRUE(WaitForTabsToLoad(0, urls));
135
136 // Verify the chrome history page synced.
137 ASSERT_TRUE(ModelAssociatorHasTabWithUrl(0,
138 GURL(chrome::kChromeUIHistoryURL)));
161 } 139 }
162 140
163 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, TimestampMatchesHistory) { 141 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, TimestampMatchesHistory) {
164 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 142 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
165 143
166 ASSERT_TRUE(CheckInitialState(0)); 144 ASSERT_TRUE(CheckInitialState(0));
167 145
168 // We want a URL that doesn't 404 and has a non-empty title. 146 // We want a URL that doesn't 404 and has a non-empty title.
169 const GURL url("data:text/html,<html><title>Test</title></html>"); 147 const GURL url("data:text/html,<html><title>Test</title></html>");
170 148
171 ScopedWindowMap windows; 149 ScopedWindowMap windows;
172 ASSERT_TRUE(OpenTab(0, url)); 150 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &windows));
173 ASSERT_TRUE(GetLocalWindows(0, &windows));
174 151
175 int found_navigations = 0; 152 int found_navigations = 0;
176 for (auto it = windows.begin(); it != windows.end(); ++it) { 153 for (auto it = windows.begin(); it != windows.end(); ++it) {
177 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end(); 154 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end();
178 ++it2) { 155 ++it2) {
179 for (auto it3 = (*it2)->navigations.begin(); 156 for (auto it3 = (*it2)->navigations.begin();
180 it3 != (*it2)->navigations.end(); ++it3) { 157 it3 != (*it2)->navigations.end(); ++it3) {
181 const base::Time timestamp = it3->timestamp(); 158 const base::Time timestamp = it3->timestamp();
182 159
183 history::URLRow virtual_row; 160 history::URLRow virtual_row;
(...skipping 10 matching lines...) Expand all
194 171
195 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ResponseCodeIsPreserved) { 172 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ResponseCodeIsPreserved) {
196 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 173 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
197 174
198 ASSERT_TRUE(CheckInitialState(0)); 175 ASSERT_TRUE(CheckInitialState(0));
199 176
200 // We want a URL that doesn't 404 and has a non-empty title. 177 // We want a URL that doesn't 404 and has a non-empty title.
201 const GURL url("data:text/html,<html><title>Test</title></html>"); 178 const GURL url("data:text/html,<html><title>Test</title></html>");
202 179
203 ScopedWindowMap windows; 180 ScopedWindowMap windows;
204 ASSERT_TRUE(OpenTab(0, url)); 181 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &windows));
205 ASSERT_TRUE(GetLocalWindows(0, &windows));
206 182
207 int found_navigations = 0; 183 int found_navigations = 0;
208 for (auto it = windows.begin(); it != windows.end(); ++it) { 184 for (auto it = windows.begin(); it != windows.end(); ++it) {
209 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end(); 185 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end();
210 ++it2) { 186 ++it2) {
211 for (auto it3 = (*it2)->navigations.begin(); 187 for (auto it3 = (*it2)->navigations.begin();
212 it3 != (*it2)->navigations.end(); ++it3) { 188 it3 != (*it2)->navigations.end(); ++it3) {
213 EXPECT_EQ(200, it3->http_status_code()); 189 EXPECT_EQ(200, it3->http_status_code());
214 ++found_navigations; 190 ++found_navigations;
215 } 191 }
216 } 192 }
217 } 193 }
218 ASSERT_EQ(1, found_navigations); 194 ASSERT_EQ(1, found_navigations);
219 } 195 }
220 196
221 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, FragmentURLNavigation) {
222 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
223 ASSERT_TRUE(CheckInitialState(0));
224
225 GURL url = GURL("http://127.0.0.1/bubba");
226 ASSERT_TRUE(OpenTab(0, url));
227 WaitForURLOnServer(url);
228
229 GURL fragment_url = GURL("http://127.0.0.1/bubba#fragment");
230 NavigateTab(0, fragment_url);
231 WaitForURLOnServer(fragment_url);
232 }
233
234 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest,
235 NavigationChainForwardBack) {
236 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
237 ASSERT_TRUE(CheckInitialState(0));
238
239 GURL first_url = GURL("http://127.0.0.1/foobar");
240 ASSERT_TRUE(OpenTab(0, first_url));
241 WaitForURLOnServer(first_url);
242
243 GURL second_url = GURL("http://127.0.0.1/barbaz");
244 NavigateTab(0, second_url);
245 WaitForURLOnServer(second_url);
246
247 NavigateTabBack(0);
248 WaitForURLOnServer(first_url);
249
250 ExpectNavigationChain({first_url, second_url});
251
252 NavigateTabForward(0);
253 WaitForURLOnServer(second_url);
254
255 ExpectNavigationChain({first_url, second_url});
256 }
257
258 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest,
259 NavigationChainAlteredDestructively) {
260 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
261 ASSERT_TRUE(CheckInitialState(0));
262
263 GURL base_url = GURL("http://127.0.0.1/bubba");
264 ASSERT_TRUE(OpenTab(0, base_url));
265 WaitForURLOnServer(base_url);
266
267 GURL first_url = GURL("http://127.0.0.1/foobar");
268 ASSERT_TRUE(NavigateTab(0, first_url));
269 WaitForURLOnServer(first_url);
270
271 // Check that the navigation chain matches the above sequence of {base_url,
272 // first_url}.
273 ExpectNavigationChain({base_url, first_url});
274
275 NavigateTabBack(0);
276 WaitForURLOnServer(base_url);
277
278 GURL second_url = GURL("http://127.0.0.1/barbaz");
279 NavigateTab(0, second_url);
280 WaitForURLOnServer(second_url);
281
282 NavigateTabBack(0);
283 WaitForURLOnServer(base_url);
284
285 // Check that the navigation chain contains second_url where first_url was
286 // before.
287 ExpectNavigationChain({base_url, second_url});
288 }
289
290 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, OpenNewTab) {
291 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
292 ASSERT_TRUE(CheckInitialState(0));
293
294 GURL base_url = GURL("http://127.0.0.1/bubba");
295 ASSERT_TRUE(OpenTabAtIndex(0, 0, base_url));
296
297 WaitForURLOnServer(base_url);
298
299 GURL new_tab_url = GURL("http://127.0.0.1/foobar");
300 ASSERT_TRUE(OpenTabAtIndex(0, 1, new_tab_url));
301
302 WaitForHierarchyOnServer(
303 SessionsHierarchy({{base_url.spec(), new_tab_url.spec()}}));
304 }
305
306 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, OpenNewWindow) {
307 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
308 ASSERT_TRUE(CheckInitialState(0));
309
310 GURL base_url = GURL("http://127.0.0.1/bubba");
311 ASSERT_TRUE(OpenTab(0, base_url));
312
313 WaitForURLOnServer(base_url);
314
315 GURL new_window_url = GURL("http://127.0.0.1/foobar");
316 AddBrowser(0);
317 ASSERT_TRUE(OpenTab(1, new_window_url));
318
319 WaitForHierarchyOnServer(
320 SessionsHierarchy({{base_url.spec()}, {new_window_url.spec()}}));
321 }
322
323 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, TabMovedToOtherWindow) {
324 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
325 ASSERT_TRUE(CheckInitialState(0));
326
327 GURL base_url = GURL("http://127.0.0.1/bubba");
328 GURL moved_tab_url = GURL("http://127.0.0.1/foobar");
329
330 ASSERT_TRUE(OpenTab(0, base_url));
331 ASSERT_TRUE(OpenTabAtIndex(0, 1, moved_tab_url));
332
333 GURL new_window_url = GURL("http://127.0.0.1/barbaz");
334 AddBrowser(0);
335 ASSERT_TRUE(OpenTab(1, new_window_url));
336
337 WaitForHierarchyOnServer(SessionsHierarchy(
338 {{base_url.spec(), moved_tab_url.spec()}, {new_window_url.spec()}}));
339
340 // Move tab 1 in browser 0 to browser 1.
341 MoveTab(0, 1, 1);
342
343 WaitForHierarchyOnServer(SessionsHierarchy(
344 {{base_url.spec()}, {new_window_url.spec(), moved_tab_url.spec()}}));
345 }
346
347 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, CookieJarMismatch) { 197 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, CookieJarMismatch) {
348 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 198 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
349 199
350 ASSERT_TRUE(CheckInitialState(0)); 200 ASSERT_TRUE(CheckInitialState(0));
351 201
352 ScopedWindowMap old_windows; 202 ScopedWindowMap old_windows;
353 sync_pb::ClientToServerMessage message; 203 sync_pb::ClientToServerMessage message;
354 204
355 // The HistogramTester objects are scoped to allow more precise verification. 205 // The HistogramTester objects are scoped to allow more precise verification.
356 { 206 {
357 HistogramTester histogram_tester; 207 HistogramTester histogram_tester;
358 208
359 // Add a new session to client 0 and wait for it to sync. 209 // Add a new session to client 0 and wait for it to sync.
360 GURL url = GURL("http://127.0.0.1/bubba"); 210 GURL url = GURL("http://127.0.0.1/bubba");
361 ASSERT_TRUE(OpenTab(0, url)); 211 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows));
362 WaitForURLOnServer(url); 212 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS));
213 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait());
363 214
364 // The cookie jar mismatch value will be true by default due to 215 // The cookie jar mismatch value will be true by default due to
365 // the way integration tests trigger signin (which does not involve a normal 216 // the way integration tests trigger signin (which does not involve a normal
366 // web content signin flow). 217 // web content signin flow).
367 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); 218 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message));
368 ASSERT_TRUE(message.commit().config_params().cookie_jar_mismatch()); 219 ASSERT_TRUE(message.commit().config_params().cookie_jar_mismatch());
369 220
370 // It is possible that multiple sync cycles occured during the call to 221 // It is possible that multiple sync cycles occured during the call to
371 // OpenTab, which would cause multiple identical samples. 222 // OpenTabAndGetLocalWindows, which would cause multiple identical samples.
372 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", 223 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation",
373 false, 1); 224 false, 1);
374 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarEmptyOnMismatch", 225 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarEmptyOnMismatch",
375 true, 1); 226 true, 1);
376 227
377 // Trigger a cookie jar change (user signing in to content area). 228 // Trigger a cookie jar change (user signing in to content area).
378 gaia::ListedAccount signed_in_account; 229 gaia::ListedAccount signed_in_account;
379 signed_in_account.id = 230 signed_in_account.id =
380 GetClient(0)->service()->signin()->GetAuthenticatedAccountId(); 231 GetClient(0)->service()->signin()->GetAuthenticatedAccountId();
381 std::vector<gaia::ListedAccount> accounts; 232 std::vector<gaia::ListedAccount> accounts;
382 std::vector<gaia::ListedAccount> signed_out_accounts; 233 std::vector<gaia::ListedAccount> signed_out_accounts;
383 accounts.push_back(signed_in_account); 234 accounts.push_back(signed_in_account);
384 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); 235 GoogleServiceAuthError error(GoogleServiceAuthError::NONE);
385 GetClient(0)->service()->OnGaiaAccountsInCookieUpdated( 236 GetClient(0)->service()->OnGaiaAccountsInCookieUpdated(
386 accounts, signed_out_accounts, error); 237 accounts, signed_out_accounts, error);
387 } 238 }
388 239
389 { 240 {
390 HistogramTester histogram_tester; 241 HistogramTester histogram_tester;
391 242
392 // Trigger a sync and wait for it. 243 // Trigger a sync and wait for it.
393 GURL url = GURL("http://127.0.0.1/bubba2"); 244 GURL url = GURL("http://127.0.0.1/bubba2");
394 ASSERT_TRUE(OpenTab(0, url)); 245 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows));
395 ASSERT_TRUE(GetLocalWindows(0, &old_windows));
396 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); 246 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS));
397 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); 247 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait());
398 248
399 // Verify the cookie jar mismatch bool is set to false. 249 // Verify the cookie jar mismatch bool is set to false.
400 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); 250 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message));
401 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); 251 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch());
402 252
403 // Verify the histograms were recorded properly. 253 // Verify the histograms were recorded properly.
404 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", 254 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation",
405 true, 1); 255 true, 1);
406 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0); 256 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0);
407 } 257 }
408 } 258 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sessions_helper.cc ('k') | chrome/browser/sync/test/integration/sync_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698