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

Unified Diff: content/browser/memory/memory_coordinator_impl_unittest.cc

Issue 2735633002: Add MemoryCoordinatorImpl::OnChildVisibilityChanged() (Closed)
Patch Set: fix test 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
« no previous file with comments | « content/browser/memory/memory_coordinator_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/memory/memory_coordinator_impl_unittest.cc
diff --git a/content/browser/memory/memory_coordinator_impl_unittest.cc b/content/browser/memory/memory_coordinator_impl_unittest.cc
index d0c7413b09a995ea3f4e4745e7e0251ef7ffa22c..7104ef938c235f568ba886436bce832b6234d004 100644
--- a/content/browser/memory/memory_coordinator_impl_unittest.cc
+++ b/content/browser/memory/memory_coordinator_impl_unittest.cc
@@ -303,6 +303,38 @@ TEST_F(MemoryCoordinatorImplTest, SetChildMemoryState) {
render_process_host->DecrementSharedWorkerRefCount();
}
+TEST_F(MemoryCoordinatorImplTest, OnChildVisibilityChanged) {
+ auto* child = coordinator_->CreateChildMemoryCoordinator(1);
+
+ coordinator_->memory_condition_ = MemoryCondition::NORMAL;
+ coordinator_->OnChildVisibilityChanged(1, true);
+ RunUntilIdle();
+ EXPECT_EQ(mojom::MemoryState::NORMAL, child->state());
+ coordinator_->OnChildVisibilityChanged(1, false);
+ RunUntilIdle();
+#if defined(OS_ANDROID)
+ EXPECT_EQ(mojom::MemoryState::THROTTLED, child->state());
+#else
+ EXPECT_EQ(mojom::MemoryState::NORMAL, child->state());
+#endif
+
+ coordinator_->memory_condition_ = MemoryCondition::WARNING;
+ coordinator_->OnChildVisibilityChanged(1, true);
+ RunUntilIdle();
+ EXPECT_EQ(mojom::MemoryState::NORMAL, child->state());
+ coordinator_->OnChildVisibilityChanged(1, false);
+ RunUntilIdle();
+ EXPECT_EQ(mojom::MemoryState::THROTTLED, child->state());
+
+ coordinator_->memory_condition_ = MemoryCondition::CRITICAL;
+ coordinator_->OnChildVisibilityChanged(1, true);
+ RunUntilIdle();
+ EXPECT_EQ(mojom::MemoryState::THROTTLED, child->state());
+ coordinator_->OnChildVisibilityChanged(1, false);
+ RunUntilIdle();
+ EXPECT_EQ(mojom::MemoryState::THROTTLED, child->state());
+}
+
TEST_F(MemoryCoordinatorImplTest, CalculateNextCondition) {
auto* condition_observer = coordinator_->condition_observer_.get();
condition_observer->expected_renderer_size_ = 10;
« no previous file with comments | « content/browser/memory/memory_coordinator_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698