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

Unified Diff: athena/resource_manager/resource_manager_unittest.cc

Issue 588823002: A visibile to invisible state change will also release memory and should therefore wait as an unloa… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 6 years, 3 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 | « athena/resource_manager/resource_manager_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/resource_manager/resource_manager_unittest.cc
diff --git a/athena/resource_manager/resource_manager_unittest.cc b/athena/resource_manager/resource_manager_unittest.cc
index ebb8b863c6d6f054f8869efff0f083a19afd5080..b5796b942d430b7be48a5f5b90c404ae44fd1f11 100644
--- a/athena/resource_manager/resource_manager_unittest.cc
+++ b/athena/resource_manager/resource_manager_unittest.cc
@@ -244,22 +244,35 @@ TEST_F(ResourceManagerTest, VisibilityChanges) {
EXPECT_NE(Activity::ACTIVITY_INVISIBLE, app4->GetCurrentState());
}
-// Make sure that an activity which got just demoted from visible to invisible,
+// Make sure that an activity which got just reduced from visible to invisible,
// does not get thrown out of memory in the same step.
TEST_F(ResourceManagerTest, NoUnloadFromVisible) {
+ // The timeout override in milliseconds.
+ const int kTimeoutOverrideInMs = 20;
+ // Tell the resource manager to wait for 20ms between calls.
+ ResourceManager::Get()->SetWaitTimeBetweenResourceManageCalls(
+ kTimeoutOverrideInMs);
+
// Create a few dummy activities in the reverse order as we need them.
TestActivity* app2 = CreateActivity("app2");
TestActivity* app1 = CreateActivity("app1");
app1->SetCurrentState(Activity::ACTIVITY_VISIBLE);
app2->SetCurrentState(Activity::ACTIVITY_VISIBLE);
- // Applying low resource pressure should turn one item ivisible.
+ // Applying low resource pressure should turn one item invisible.
ResourceManager::Get()->SetMemoryPressureAndStopMonitoring(
MemoryPressureObserver::MEMORY_PRESSURE_CRITICAL);
EXPECT_EQ(Activity::ACTIVITY_VISIBLE, app1->GetCurrentState());
EXPECT_EQ(Activity::ACTIVITY_INVISIBLE, app2->GetCurrentState());
- // Applying low resource pressure again will unload it.
+ // Trying to apply the memory pressure again does not do anything.
+ ResourceManager::Get()->SetMemoryPressureAndStopMonitoring(
+ MemoryPressureObserver::MEMORY_PRESSURE_CRITICAL);
+ EXPECT_EQ(Activity::ACTIVITY_VISIBLE, app1->GetCurrentState());
+ EXPECT_EQ(Activity::ACTIVITY_INVISIBLE, app2->GetCurrentState());
+
+ // Waiting and applying the pressure again should unload it.
+ usleep(kTimeoutOverrideInMs * 1000);
ResourceManager::Get()->SetMemoryPressureAndStopMonitoring(
MemoryPressureObserver::MEMORY_PRESSURE_CRITICAL);
EXPECT_EQ(Activity::ACTIVITY_VISIBLE, app1->GetCurrentState());
« no previous file with comments | « athena/resource_manager/resource_manager_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698