| 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" |
| 8 #include "chrome/browser/chrome_notification_types.h" |
| 7 #include "chrome/browser/sessions/session_service.h" | 9 #include "chrome/browser/sessions/session_service.h" |
| 8 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
| 9 #include "chrome/browser/sync/test/integration/session_hierarchy_match_checker.h
" | 11 #include "chrome/browser/sync/test/integration/session_hierarchy_match_checker.h
" |
| 10 #include "chrome/browser/sync/test/integration/sessions_helper.h" | 12 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
| 11 #include "chrome/browser/sync/test/integration/sync_test.h" | 13 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 12 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" | 14 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" |
| 13 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" | 15 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" |
| 14 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 15 #include "components/browser_sync/profile_sync_service.h" | 17 #include "components/browser_sync/profile_sync_service.h" |
| 16 #include "components/history/core/browser/history_types.h" | 18 #include "components/history/core/browser/history_types.h" |
| 17 #include "components/sessions/core/session_types.h" | 19 #include "components/sessions/core/session_types.h" |
| 18 #include "components/sync/base/time.h" | 20 #include "components/sync/base/time.h" |
| 19 #include "components/sync/driver/sync_driver_switches.h" | 21 #include "components/sync/driver/sync_driver_switches.h" |
| 20 #include "components/sync/test/fake_server/sessions_hierarchy.h" | 22 #include "components/sync/test/fake_server/sessions_hierarchy.h" |
| 23 #include "components/sync_sessions/sessions_sync_manager.h" |
| 24 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/test/test_utils.h" |
| 21 | 26 |
| 22 using base::HistogramBase; | 27 using base::HistogramBase; |
| 23 using base::HistogramSamples; | 28 using base::HistogramSamples; |
| 24 using base::HistogramTester; | 29 using base::HistogramTester; |
| 25 using fake_server::SessionsHierarchy; | 30 using fake_server::SessionsHierarchy; |
| 26 using sessions_helper::CheckInitialState; | 31 using sessions_helper::CheckInitialState; |
| 27 using sessions_helper::GetLocalWindows; | 32 using sessions_helper::GetLocalWindows; |
| 28 using sessions_helper::GetSessionData; | 33 using sessions_helper::GetSessionData; |
| 29 using sessions_helper::ModelAssociatorHasTabWithUrl; | 34 using sessions_helper::ModelAssociatorHasTabWithUrl; |
| 30 using sessions_helper::MoveTab; | 35 using sessions_helper::MoveTab; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 280 |
| 276 WaitForURLOnServer(base_url); | 281 WaitForURLOnServer(base_url); |
| 277 | 282 |
| 278 GURL new_tab_url = GURL(kURL2); | 283 GURL new_tab_url = GURL(kURL2); |
| 279 ASSERT_TRUE(OpenTabAtIndex(0, 1, new_tab_url)); | 284 ASSERT_TRUE(OpenTabAtIndex(0, 1, new_tab_url)); |
| 280 | 285 |
| 281 WaitForHierarchyOnServer( | 286 WaitForHierarchyOnServer( |
| 282 SessionsHierarchy({{base_url.spec(), new_tab_url.spec()}})); | 287 SessionsHierarchy({{base_url.spec(), new_tab_url.spec()}})); |
| 283 } | 288 } |
| 284 | 289 |
| 290 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, |
| 291 DoNotSyncTabsOnBrowserShutdown) { |
| 292 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 293 ASSERT_TRUE(CheckInitialState(0)); |
| 294 ASSERT_TRUE(OpenTab(0, GURL(kURL1))); |
| 295 |
| 296 sync_sessions::SessionsSyncManager* sessions_sync_manager = |
| 297 static_cast<sync_sessions::SessionsSyncManager*>( |
| 298 GetSyncService(0)->GetSessionsSyncableService()); |
| 299 EXPECT_FALSE(sessions_sync_manager->GetAllBrowsersClosingForTesting()); |
| 300 |
| 301 content::WindowedNotificationObserver close_all_observer( |
| 302 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
| 303 content::NotificationService::AllSources()); |
| 304 content::NotificationService::current()->Notify( |
| 305 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
| 306 content::NotificationService::AllSources(), |
| 307 content::NotificationService::NoDetails()); |
| 308 close_all_observer.Wait(); |
| 309 base::RunLoop().RunUntilIdle(); |
| 310 EXPECT_TRUE(sessions_sync_manager->GetAllBrowsersClosingForTesting()); |
| 311 |
| 312 content::WindowedNotificationObserver cancel_observer( |
| 313 chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED, |
| 314 content::NotificationService::AllSources()); |
| 315 content::NotificationService::current()->Notify( |
| 316 chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED, |
| 317 content::NotificationService::AllSources(), |
| 318 content::NotificationService::NoDetails()); |
| 319 cancel_observer.Wait(); |
| 320 base::RunLoop().RunUntilIdle(); |
| 321 EXPECT_FALSE(sessions_sync_manager->GetAllBrowsersClosingForTesting()); |
| 322 |
| 323 content::WindowedNotificationObserver close_observer( |
| 324 chrome::NOTIFICATION_BROWSER_CLOSING, |
| 325 content::NotificationService::AllSources()); |
| 326 content::NotificationService::current()->Notify( |
| 327 chrome::NOTIFICATION_BROWSER_CLOSING, |
| 328 content::Source<Browser>(GetBrowser(0)), |
| 329 content::NotificationService::NoDetails()); |
| 330 close_observer.Wait(); |
| 331 base::RunLoop().RunUntilIdle(); |
| 332 EXPECT_TRUE(sessions_sync_manager->GetAllBrowsersClosingForTesting()); |
| 333 } |
| 334 |
| 285 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, OpenNewWindow) { | 335 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, OpenNewWindow) { |
| 286 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 336 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 287 ASSERT_TRUE(CheckInitialState(0)); | 337 ASSERT_TRUE(CheckInitialState(0)); |
| 288 | 338 |
| 289 GURL base_url = GURL(kURL1); | 339 GURL base_url = GURL(kURL1); |
| 290 ASSERT_TRUE(OpenTab(0, base_url)); | 340 ASSERT_TRUE(OpenTab(0, base_url)); |
| 291 | 341 |
| 292 WaitForURLOnServer(base_url); | 342 WaitForURLOnServer(base_url); |
| 293 | 343 |
| 294 GURL new_window_url = GURL(kURL2); | 344 GURL new_window_url = GURL(kURL2); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 // Verify the cookie jar mismatch bool is set to false. | 425 // Verify the cookie jar mismatch bool is set to false. |
| 376 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); | 426 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); |
| 377 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); | 427 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); |
| 378 | 428 |
| 379 // Verify the histograms were recorded properly. | 429 // Verify the histograms were recorded properly. |
| 380 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", | 430 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", |
| 381 true, 1); | 431 true, 1); |
| 382 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0); | 432 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0); |
| 383 } | 433 } |
| 384 } | 434 } |
| OLD | NEW |