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

Unified Diff: chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc

Issue 2750163003: Prevent tabs sync during browser shutdown.
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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc
diff --git a/chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc b/chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc
index 6816ff489a25c7007f2d6961d460d769f77ed744..af2afb56d1c9c499f605b38678858e521ff63b0f 100644
--- a/chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc
+++ b/chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc
@@ -3,7 +3,9 @@
// found in the LICENSE file.
#include "base/macros.h"
+#include "base/run_loop.h"
#include "base/test/histogram_tester.h"
+#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/sessions/session_service.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/session_hierarchy_match_checker.h"
@@ -18,6 +20,9 @@
#include "components/sync/base/time.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/test/fake_server/sessions_hierarchy.h"
+#include "components/sync_sessions/sessions_sync_manager.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/test/test_utils.h"
using base::HistogramBase;
using base::HistogramSamples;
@@ -282,6 +287,51 @@ IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, OpenNewTab) {
SessionsHierarchy({{base_url.spec(), new_tab_url.spec()}}));
}
+IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest,
+ DoNotSyncTabsOnBrowserShutdown) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ ASSERT_TRUE(CheckInitialState(0));
+ ASSERT_TRUE(OpenTab(0, GURL(kURL1)));
+
+ sync_sessions::SessionsSyncManager* sessions_sync_manager =
+ static_cast<sync_sessions::SessionsSyncManager*>(
+ GetSyncService(0)->GetSessionsSyncableService());
+ EXPECT_FALSE(sessions_sync_manager->GetAllBrowsersClosingForTesting());
+
+ content::WindowedNotificationObserver close_all_observer(
+ chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST,
+ content::NotificationService::AllSources());
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST,
+ content::NotificationService::AllSources(),
+ content::NotificationService::NoDetails());
+ close_all_observer.Wait();
+ base::RunLoop().RunUntilIdle();
+ EXPECT_TRUE(sessions_sync_manager->GetAllBrowsersClosingForTesting());
+
+ content::WindowedNotificationObserver cancel_observer(
+ chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED,
+ content::NotificationService::AllSources());
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED,
+ content::NotificationService::AllSources(),
+ content::NotificationService::NoDetails());
+ cancel_observer.Wait();
+ base::RunLoop().RunUntilIdle();
+ EXPECT_FALSE(sessions_sync_manager->GetAllBrowsersClosingForTesting());
+
+ content::WindowedNotificationObserver close_observer(
+ chrome::NOTIFICATION_BROWSER_CLOSING,
+ content::NotificationService::AllSources());
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_BROWSER_CLOSING,
+ content::Source<Browser>(GetBrowser(0)),
+ content::NotificationService::NoDetails());
+ close_observer.Wait();
+ base::RunLoop().RunUntilIdle();
+ EXPECT_TRUE(sessions_sync_manager->GetAllBrowsersClosingForTesting());
+}
+
IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, OpenNewWindow) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(CheckInitialState(0));
« 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