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

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
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..7d635a04df73154d8b6bfa93e247830a7dd152ea 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::kSyncMemoryPressureReceivings),
+ 0);
+ EXPECT_TRUE(sync_prefs.IsPreviousCrashed());
+
+ // 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::kSyncMemoryPressureReceivings),
+ 1);
+ EXPECT_TRUE(sync_prefs.IsPreviousCrashed());
+
+ // 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::kSyncMemoryPressureReceivings),
+ 2);
+ EXPECT_FALSE(sync_prefs.IsPreviousCrashed());
+}
+
} // namespace
} // namespace browser_sync

Powered by Google App Engine
This is Rietveld 408576698