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

Unified Diff: chrome/browser/sync/profile_sync_service_unittest.cc

Issue 1136763004: Add UMA data for memory pressure warning received for sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | components/sync_driver/pref_names.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/profile_sync_service_unittest.cc
diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc
index cba1633676a6c71f862274a4669a261f5d7a98bf..f4cb23af2cd8cc950911c7b8c713156ad19558cd 100644
--- a/chrome/browser/sync/profile_sync_service_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_unittest.cc
@@ -659,5 +659,50 @@ TEST_F(ProfileSyncServiceTest, NoDisableSyncFlag) {
EXPECT_TRUE(ProfileSyncService::IsSyncEnabled());
}
+// Test Sync will stop after receive memory pressure
+TEST_F(ProfileSyncServiceTest, MemoryPressureRecording) {
+ CreateService(browser_sync::AUTO_START);
+ IssueTestTokens();
+ ExpectDataTypeManagerCreation(1);
+ ExpectSyncBackendHostCreation(1);
+ InitializeForNthSync();
+
+ EXPECT_TRUE(service()->SyncActive());
+ EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(
+ sync_driver::prefs::kSyncSuppressStart));
+
+ testing::Mock::VerifyAndClearExpectations(components_factory());
+
+ sync_driver::SyncPrefs sync_prefs(service()->profile()->GetPrefs());
+
+ EXPECT_EQ(profile()->GetPrefs()->GetInteger(
+ sync_driver::prefs::kSyncMemoryPressureWarningCount),
+ 0);
+ EXPECT_FALSE(sync_prefs.DidSyncShutdownCleanly());
+
+ // Simulate memory pressure notification.
+ base::MemoryPressureListener::NotifyMemoryPressure(
+ base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL);
+ base::RunLoop().RunUntilIdle();
+
+ // Verify memory pressure recorded.
+ EXPECT_EQ(profile()->GetPrefs()->GetInteger(
+ sync_driver::prefs::kSyncMemoryPressureWarningCount),
+ 1);
+ EXPECT_FALSE(sync_prefs.DidSyncShutdownCleanly());
+
+ // Simulate memory pressure notification.
+ base::MemoryPressureListener::NotifyMemoryPressure(
+ base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL);
+ base::RunLoop().RunUntilIdle();
+ ShutdownAndDeleteService();
+
+ // Verify memory pressure and shutdown recorded.
+ EXPECT_EQ(profile()->GetPrefs()->GetInteger(
+ sync_driver::prefs::kSyncMemoryPressureWarningCount),
+ 2);
+ EXPECT_TRUE(sync_prefs.DidSyncShutdownCleanly());
+}
+
} // namespace
} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | components/sync_driver/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698