Chromium Code Reviews| 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/run_loop.h" | |
| 6 #include "base/test/histogram_tester.h" | 7 #include "base/test/histogram_tester.h" |
| 7 #include "chrome/browser/sessions/session_service.h" | 8 #include "chrome/browser/sessions/session_service.h" |
| 8 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 9 #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/session_hierarchy_match_checker.h " |
| 10 #include "chrome/browser/sync/test/integration/sessions_helper.h" | 11 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
| 11 #include "chrome/browser/sync/test/integration/sync_test.h" | 12 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 12 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" | 13 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" |
| 13 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h " | 14 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.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" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 {{base_url.spec(), moved_tab_url.spec()}, {new_window_url.spec()}})); | 318 {{base_url.spec(), moved_tab_url.spec()}, {new_window_url.spec()}})); |
| 318 | 319 |
| 319 // Move tab 1 in browser 0 to browser 1. | 320 // Move tab 1 in browser 0 to browser 1. |
| 320 MoveTab(0, 1, 1); | 321 MoveTab(0, 1, 1); |
| 321 | 322 |
| 322 WaitForHierarchyOnServer(SessionsHierarchy( | 323 WaitForHierarchyOnServer(SessionsHierarchy( |
| 323 {{base_url.spec()}, {new_window_url.spec(), moved_tab_url.spec()}})); | 324 {{base_url.spec()}, {new_window_url.spec(), moved_tab_url.spec()}})); |
| 324 } | 325 } |
| 325 | 326 |
| 326 // crbug.com/689662 | 327 // crbug.com/689662 |
| 327 #if defined(OS_CHROMEOS) || defined(OS_WIN) | 328 #if defined(OS_CHROMEOS) |
| 328 #define MAYBE_CookieJarMismatch DISABLED_CookieJarMismatch | 329 #define MAYBE_CookieJarMismatch DISABLED_CookieJarMismatch |
| 329 #else | 330 #else |
| 330 #define MAYBE_CookieJarMismatch CookieJarMismatch | 331 #define MAYBE_CookieJarMismatch CookieJarMismatch |
| 331 #endif | 332 #endif |
| 332 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, MAYBE_CookieJarMismatch) { | 333 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, MAYBE_CookieJarMismatch) { |
| 333 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 334 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 334 | 335 |
| 335 ASSERT_TRUE(CheckInitialState(0)); | 336 ASSERT_TRUE(CheckInitialState(0)); |
| 336 | 337 |
| 337 sync_pb::ClientToServerMessage message; | 338 sync_pb::ClientToServerMessage message; |
| 338 | 339 |
| 339 // The HistogramTester objects are scoped to allow more precise verification. | 340 // The HistogramTester objects are scoped to allow more precise verification. |
| 340 { | 341 { |
| 341 HistogramTester histogram_tester; | 342 HistogramTester histogram_tester; |
| 342 | 343 |
| 343 // Add a new session to client 0 and wait for it to sync. | 344 // Add a new session to client 0 and wait for it to sync. |
| 344 GURL url = GURL(kURL1); | 345 GURL url = GURL(kURL1); |
| 345 ASSERT_TRUE(OpenTab(0, url)); | 346 ASSERT_TRUE(OpenTab(0, url)); |
| 346 WaitForURLOnServer(url); | 347 WaitForURLOnServer(url); |
| 347 | 348 |
| 348 // The cookie jar mismatch value will be true by default due to | 349 // The cookie jar mismatch value will be true by default due to |
| 349 // the way integration tests trigger signin (which does not involve a normal | 350 // the way integration tests trigger signin (which does not involve a normal |
| 350 // web content signin flow). | 351 // web content signin flow). |
| 351 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 352 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
| 352 ASSERT_TRUE(message.commit().config_params().cookie_jar_mismatch()); | 353 ASSERT_TRUE(message.commit().config_params().cookie_jar_mismatch()); |
| 353 | 354 |
| 354 // It is possible that multiple sync cycles occured during the call to | 355 // It is possible that multiple sync cycles occurred during the call to |
| 355 // OpenTab, which would cause multiple identical samples. | 356 // OpenTab, which would cause multiple identical samples. |
| 356 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", | 357 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", |
| 357 false, 1); | 358 false, 1); |
| 358 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarEmptyOnMismatch", | 359 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarEmptyOnMismatch", |
| 359 true, 1); | 360 true, 1); |
| 361 } | |
| 360 | 362 |
| 361 // Trigger a cookie jar change (user signing in to content area). | 363 // Trigger a cookie jar change (user signing in to content area). |
| 362 gaia::ListedAccount signed_in_account; | 364 gaia::ListedAccount signed_in_account; |
| 363 signed_in_account.id = | 365 signed_in_account.id = |
| 364 GetClient(0)->service()->signin()->GetAuthenticatedAccountId(); | 366 GetClient(0)->service()->signin()->GetAuthenticatedAccountId(); |
| 365 std::vector<gaia::ListedAccount> accounts; | 367 std::vector<gaia::ListedAccount> accounts; |
| 366 std::vector<gaia::ListedAccount> signed_out_accounts; | 368 std::vector<gaia::ListedAccount> signed_out_accounts; |
| 367 accounts.push_back(signed_in_account); | 369 accounts.push_back(signed_in_account); |
| 368 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); | 370 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); |
| 369 GetClient(0)->service()->OnGaiaAccountsInCookieUpdated( | 371 |
| 370 accounts, signed_out_accounts, error); | 372 // Updating the cookie jar has to travel to the sync engine. It is possible |
| 371 } | 373 // something is already running or scheduled to run on the sync thread. We |
| 374 // want to block here and not create the HistogramTester below until we know | |
| 375 // the cookie jar stats have been updated. | |
| 376 base::RunLoop run_loop; | |
| 377 GetClient(0)->service()->OnGaiaAccountsInCookieUpdatedWithCallback( | |
| 378 accounts, signed_out_accounts, error, run_loop.QuitClosure()); | |
| 379 run_loop.Run(); | |
|
pavely
2017/03/20 04:32:02
Waiting for values to arrive on sync thread doesn'
| |
| 372 | 380 |
| 373 { | 381 { |
| 374 HistogramTester histogram_tester; | 382 HistogramTester histogram_tester; |
| 375 | 383 |
| 376 // Trigger a sync and wait for it. | 384 // Trigger a sync and wait for it. |
| 377 GURL url = GURL(kURL2); | 385 GURL url = GURL(kURL2); |
| 378 ASSERT_TRUE(NavigateTab(0, url)); | 386 ASSERT_TRUE(NavigateTab(0, url)); |
| 379 WaitForURLOnServer(url); | 387 WaitForURLOnServer(url); |
| 380 | 388 |
| 381 // Verify the cookie jar mismatch bool is set to false. | 389 // Verify the cookie jar mismatch bool is set to false. |
| 382 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 390 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
| 383 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); | 391 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); |
| 384 | 392 |
| 385 // Verify the histograms were recorded properly. | 393 // Verify the histograms were recorded properly. |
| 386 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", | 394 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", |
| 387 true, 1); | 395 true, 1); |
| 388 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0); | 396 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0); |
| 389 } | 397 } |
| 390 } | 398 } |
| OLD | NEW |