OLD | NEW |
---|---|
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 " | |
9 #include "chrome/browser/sync/test/integration/sessions_helper.h" | 10 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
10 #include "chrome/browser/sync/test/integration/sync_test.h" | 11 #include "chrome/browser/sync/test/integration/sync_test.h" |
11 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" | 12 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" |
12 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h " | 13 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h " |
13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
15 #include "components/browser_sync/profile_sync_service.h" | 16 #include "components/browser_sync/profile_sync_service.h" |
16 #include "components/history/core/browser/history_types.h" | 17 #include "components/history/core/browser/history_types.h" |
17 #include "components/sessions/core/session_types.h" | 18 #include "components/sessions/core/session_types.h" |
18 #include "components/sync/base/time.h" | 19 #include "components/sync/base/time.h" |
19 #include "components/sync/driver/sync_driver_switches.h" | 20 #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::OpenTabAndGetLocalWindows; | 35 using sessions_helper::MoveTab; |
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; | |
36 using sessions_helper::ScopedWindowMap; | 41 using sessions_helper::ScopedWindowMap; |
37 using sessions_helper::SessionWindowMap; | 42 using sessions_helper::SessionWindowMap; |
38 using sessions_helper::SyncedSessionVector; | 43 using sessions_helper::SyncedSessionVector; |
39 using sessions_helper::WaitForTabsToLoad; | 44 using sessions_helper::WaitForTabsToLoad; |
40 using sessions_helper::WindowsMatch; | 45 using sessions_helper::WindowsMatch; |
41 using typed_urls_helper::GetUrlFromClient; | 46 using typed_urls_helper::GetUrlFromClient; |
42 | 47 |
43 namespace { | 48 namespace { |
44 | 49 |
45 void ExpectUniqueSampleGE(const HistogramTester& histogram_tester, | 50 void ExpectUniqueSampleGE(const HistogramTester& histogram_tester, |
(...skipping 28 matching lines...) Expand all Loading... | |
74 #if defined(OS_CHROMEOS) | 79 #if defined(OS_CHROMEOS) |
75 // kIgnoreUserProfileMappingForTests will let UserManager always return | 80 // kIgnoreUserProfileMappingForTests will let UserManager always return |
76 // active user. If this switch is not set, sync test's profile will not | 81 // active user. If this switch is not set, sync test's profile will not |
77 // match UserManager's active user, then UserManager won't return active | 82 // match UserManager's active user, then UserManager won't return active |
78 // user to our tests. | 83 // user to our tests. |
79 if (!cl->HasSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests)) | 84 if (!cl->HasSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests)) |
80 cl->AppendSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests); | 85 cl->AppendSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests); |
81 #endif | 86 #endif |
82 } | 87 } |
83 | 88 |
89 void ExpectNavigationChain(const std::vector<GURL> urls) { | |
Nicolas Zea
2017/02/27 23:20:06
nit: pass by const ref
Patrick Noland
2017/02/27 23:37:07
Done.
| |
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 | |
84 private: | 119 private: |
85 DISALLOW_COPY_AND_ASSIGN(SingleClientSessionsSyncTest); | 120 DISALLOW_COPY_AND_ASSIGN(SingleClientSessionsSyncTest); |
86 }; | 121 }; |
87 | 122 |
88 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, Sanity) { | 123 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, Sanity) { |
89 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 124 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
90 | 125 |
91 ASSERT_TRUE(CheckInitialState(0)); | 126 ASSERT_TRUE(CheckInitialState(0)); |
92 | 127 |
93 // Add a new session to client 0 and wait for it to sync. | 128 // Add a new session to client 0 and wait for it to sync. |
94 ScopedWindowMap old_windows; | 129 ScopedWindowMap old_windows; |
95 GURL url = GURL("http://127.0.0.1/bubba"); | 130 GURL url = GURL("http://127.0.0.1/bubba"); |
96 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows)); | 131 ASSERT_TRUE(OpenTab(0, url)); |
132 ASSERT_TRUE(GetLocalWindows(0, &old_windows)); | |
97 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | 133 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
98 | 134 |
99 // Get foreign session data from client 0. | 135 // Get foreign session data from client 0. |
100 SyncedSessionVector sessions; | 136 SyncedSessionVector sessions; |
101 ASSERT_FALSE(GetSessionData(0, &sessions)); | 137 ASSERT_FALSE(GetSessionData(0, &sessions)); |
102 ASSERT_EQ(0U, sessions.size()); | 138 ASSERT_EQ(0U, sessions.size()); |
103 | 139 |
104 // Verify client didn't change. | 140 // Verify client didn't change. |
105 ScopedWindowMap new_windows; | 141 ScopedWindowMap new_windows; |
106 ASSERT_TRUE(GetLocalWindows(0, &new_windows)); | 142 ASSERT_TRUE(GetLocalWindows(0, &new_windows)); |
107 ASSERT_TRUE(WindowsMatch(old_windows, new_windows)); | 143 ASSERT_TRUE(WindowsMatch(old_windows, new_windows)); |
108 | 144 |
109 fake_server::FakeServerVerifier fake_server_verifier(GetFakeServer()); | 145 WaitForURLOnServer(url); |
110 SessionsHierarchy expected_sessions; | |
111 expected_sessions.AddWindow(url.spec()); | |
112 ASSERT_TRUE(fake_server_verifier.VerifySessions(expected_sessions)); | |
113 } | 146 } |
114 | 147 |
115 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, NoSessions) { | 148 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, NoSessions) { |
116 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 149 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
117 | 150 |
118 fake_server::FakeServerVerifier fake_server_verifier(GetFakeServer()); | 151 WaitForHierarchyOnServer(SessionsHierarchy()); |
119 SessionsHierarchy expected_sessions; | |
120 ASSERT_TRUE(fake_server_verifier.VerifySessions(expected_sessions)); | |
121 } | 152 } |
122 | 153 |
123 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ChromeHistory) { | 154 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ChromeHistory) { |
124 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 155 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
125 | 156 |
126 ASSERT_TRUE(CheckInitialState(0)); | 157 ASSERT_TRUE(CheckInitialState(0)); |
127 | 158 |
128 // Add a new session to client 0 and wait for it to sync. | 159 ASSERT_TRUE(OpenTab(0, GURL(chrome::kChromeUIHistoryURL))); |
129 ScopedWindowMap old_windows; | 160 WaitForURLOnServer(GURL(chrome::kChromeUIHistoryURL)); |
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))); | |
139 } | 161 } |
140 | 162 |
141 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, TimestampMatchesHistory) { | 163 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, TimestampMatchesHistory) { |
142 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 164 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
143 | 165 |
144 ASSERT_TRUE(CheckInitialState(0)); | 166 ASSERT_TRUE(CheckInitialState(0)); |
145 | 167 |
146 // We want a URL that doesn't 404 and has a non-empty title. | 168 // We want a URL that doesn't 404 and has a non-empty title. |
147 const GURL url("data:text/html,<html><title>Test</title></html>"); | 169 const GURL url("data:text/html,<html><title>Test</title></html>"); |
148 | 170 |
149 ScopedWindowMap windows; | 171 ScopedWindowMap windows; |
150 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &windows)); | 172 ASSERT_TRUE(OpenTab(0, url)); |
173 ASSERT_TRUE(GetLocalWindows(0, &windows)); | |
151 | 174 |
152 int found_navigations = 0; | 175 int found_navigations = 0; |
153 for (auto it = windows.begin(); it != windows.end(); ++it) { | 176 for (auto it = windows.begin(); it != windows.end(); ++it) { |
154 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end(); | 177 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end(); |
155 ++it2) { | 178 ++it2) { |
156 for (auto it3 = (*it2)->navigations.begin(); | 179 for (auto it3 = (*it2)->navigations.begin(); |
157 it3 != (*it2)->navigations.end(); ++it3) { | 180 it3 != (*it2)->navigations.end(); ++it3) { |
158 const base::Time timestamp = it3->timestamp(); | 181 const base::Time timestamp = it3->timestamp(); |
159 | 182 |
160 history::URLRow virtual_row; | 183 history::URLRow virtual_row; |
(...skipping 10 matching lines...) Expand all Loading... | |
171 | 194 |
172 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ResponseCodeIsPreserved) { | 195 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ResponseCodeIsPreserved) { |
173 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 196 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
174 | 197 |
175 ASSERT_TRUE(CheckInitialState(0)); | 198 ASSERT_TRUE(CheckInitialState(0)); |
176 | 199 |
177 // We want a URL that doesn't 404 and has a non-empty title. | 200 // We want a URL that doesn't 404 and has a non-empty title. |
178 const GURL url("data:text/html,<html><title>Test</title></html>"); | 201 const GURL url("data:text/html,<html><title>Test</title></html>"); |
179 | 202 |
180 ScopedWindowMap windows; | 203 ScopedWindowMap windows; |
181 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &windows)); | 204 ASSERT_TRUE(OpenTab(0, url)); |
205 ASSERT_TRUE(GetLocalWindows(0, &windows)); | |
182 | 206 |
183 int found_navigations = 0; | 207 int found_navigations = 0; |
184 for (auto it = windows.begin(); it != windows.end(); ++it) { | 208 for (auto it = windows.begin(); it != windows.end(); ++it) { |
185 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end(); | 209 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end(); |
186 ++it2) { | 210 ++it2) { |
187 for (auto it3 = (*it2)->navigations.begin(); | 211 for (auto it3 = (*it2)->navigations.begin(); |
188 it3 != (*it2)->navigations.end(); ++it3) { | 212 it3 != (*it2)->navigations.end(); ++it3) { |
189 EXPECT_EQ(200, it3->http_status_code()); | 213 EXPECT_EQ(200, it3->http_status_code()); |
190 ++found_navigations; | 214 ++found_navigations; |
191 } | 215 } |
192 } | 216 } |
193 } | 217 } |
194 ASSERT_EQ(1, found_navigations); | 218 ASSERT_EQ(1, found_navigations); |
195 } | 219 } |
196 | 220 |
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 | |
197 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, CookieJarMismatch) { | 347 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, CookieJarMismatch) { |
198 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 348 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
199 | 349 |
200 ASSERT_TRUE(CheckInitialState(0)); | 350 ASSERT_TRUE(CheckInitialState(0)); |
201 | 351 |
202 ScopedWindowMap old_windows; | 352 ScopedWindowMap old_windows; |
203 sync_pb::ClientToServerMessage message; | 353 sync_pb::ClientToServerMessage message; |
204 | 354 |
205 // The HistogramTester objects are scoped to allow more precise verification. | 355 // The HistogramTester objects are scoped to allow more precise verification. |
206 { | 356 { |
207 HistogramTester histogram_tester; | 357 HistogramTester histogram_tester; |
208 | 358 |
209 // Add a new session to client 0 and wait for it to sync. | 359 // Add a new session to client 0 and wait for it to sync. |
210 GURL url = GURL("http://127.0.0.1/bubba"); | 360 GURL url = GURL("http://127.0.0.1/bubba"); |
211 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows)); | 361 ASSERT_TRUE(OpenTab(0, url)); |
212 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); | 362 WaitForURLOnServer(url); |
213 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | |
214 | 363 |
215 // The cookie jar mismatch value will be true by default due to | 364 // The cookie jar mismatch value will be true by default due to |
216 // the way integration tests trigger signin (which does not involve a normal | 365 // the way integration tests trigger signin (which does not involve a normal |
217 // web content signin flow). | 366 // web content signin flow). |
218 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 367 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
219 ASSERT_TRUE(message.commit().config_params().cookie_jar_mismatch()); | 368 ASSERT_TRUE(message.commit().config_params().cookie_jar_mismatch()); |
220 | 369 |
221 // It is possible that multiple sync cycles occured during the call to | 370 // It is possible that multiple sync cycles occured during the call to |
222 // OpenTabAndGetLocalWindows, which would cause multiple identical samples. | 371 // OpenTab, which would cause multiple identical samples. |
223 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", | 372 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", |
224 false, 1); | 373 false, 1); |
225 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarEmptyOnMismatch", | 374 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarEmptyOnMismatch", |
226 true, 1); | 375 true, 1); |
227 | 376 |
228 // Trigger a cookie jar change (user signing in to content area). | 377 // Trigger a cookie jar change (user signing in to content area). |
229 gaia::ListedAccount signed_in_account; | 378 gaia::ListedAccount signed_in_account; |
230 signed_in_account.id = | 379 signed_in_account.id = |
231 GetClient(0)->service()->signin()->GetAuthenticatedAccountId(); | 380 GetClient(0)->service()->signin()->GetAuthenticatedAccountId(); |
232 std::vector<gaia::ListedAccount> accounts; | 381 std::vector<gaia::ListedAccount> accounts; |
233 std::vector<gaia::ListedAccount> signed_out_accounts; | 382 std::vector<gaia::ListedAccount> signed_out_accounts; |
234 accounts.push_back(signed_in_account); | 383 accounts.push_back(signed_in_account); |
235 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); | 384 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); |
236 GetClient(0)->service()->OnGaiaAccountsInCookieUpdated( | 385 GetClient(0)->service()->OnGaiaAccountsInCookieUpdated( |
237 accounts, signed_out_accounts, error); | 386 accounts, signed_out_accounts, error); |
238 } | 387 } |
239 | 388 |
240 { | 389 { |
241 HistogramTester histogram_tester; | 390 HistogramTester histogram_tester; |
242 | 391 |
243 // Trigger a sync and wait for it. | 392 // Trigger a sync and wait for it. |
244 GURL url = GURL("http://127.0.0.1/bubba2"); | 393 GURL url = GURL("http://127.0.0.1/bubba2"); |
245 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, url, &old_windows)); | 394 ASSERT_TRUE(OpenTab(0, url)); |
395 ASSERT_TRUE(GetLocalWindows(0, &old_windows)); | |
246 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); | 396 TriggerSyncForModelTypes(0, syncer::ModelTypeSet(syncer::SESSIONS)); |
247 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | 397 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
248 | 398 |
249 // Verify the cookie jar mismatch bool is set to false. | 399 // Verify the cookie jar mismatch bool is set to false. |
250 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 400 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
251 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); | 401 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); |
252 | 402 |
253 // Verify the histograms were recorded properly. | 403 // Verify the histograms were recorded properly. |
254 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", | 404 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", |
255 true, 1); | 405 true, 1); |
256 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0); | 406 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0); |
257 } | 407 } |
258 } | 408 } |
OLD | NEW |