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

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

Issue 2448953002: Add MemoryCoordinatorProxy::SetCurrentMemoryStateForTesting (Closed)
Patch Set: Add tests Created 4 years, 2 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 a0d1e925a31bc9cd86495ef3298a05c65d068a26..dd12e5526cd44bb02a5c049a79633cddf85a1b38 100644
--- a/content/browser/memory/memory_coordinator_impl_unittest.cc
+++ b/content/browser/memory/memory_coordinator_impl_unittest.cc
@@ -60,6 +60,10 @@ class MemoryCoordinatorImplTest : public testing::Test {
SetGetCurrentMemoryStateCallback(base::Bind(
&MemoryCoordinator::GetCurrentMemoryState,
base::Unretained(coordinator_.get())));
+ base::MemoryCoordinatorProxy::GetInstance()->
+ SetSetCurrentMemoryStateForTestingCallback(base::Bind(
+ &MemoryCoordinator::SetCurrentMemoryStateForTesting,
+ base::Unretained(coordinator_.get())));
}
MockMemoryMonitor* GetMockMemoryMonitor() {
@@ -167,4 +171,34 @@ TEST_F(MemoryCoordinatorImplTest, UpdateState) {
}
}
+TEST_F(MemoryCoordinatorImplTest, SetMemoryStateForTesting) {
+ coordinator_->expected_renderer_size_ = 10;
+ coordinator_->new_renderers_until_throttled_ = 4;
+ coordinator_->new_renderers_until_suspended_ = 2;
+ coordinator_->new_renderers_back_to_normal_ = 5;
+ coordinator_->new_renderers_back_to_throttled_ = 3;
+ DCHECK(coordinator_->ValidateParameters());
+
+ MockMemoryCoordinatorClient client;
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Register(&client);
+ EXPECT_EQ(base::MemoryState::NORMAL, coordinator_->GetCurrentMemoryState());
+ EXPECT_EQ(base::MemoryState::NORMAL,
+ base::MemoryCoordinatorProxy::GetInstance()->
+ GetCurrentMemoryState());
+ EXPECT_EQ(base::MemoryState::NORMAL, client.state());
+
+ base::MemoryCoordinatorProxy::GetInstance()->SetCurrentMemoryStateForTesting(
+ base::MemoryState::THROTTLED);
+ EXPECT_EQ(base::MemoryState::THROTTLED,
+ coordinator_->GetCurrentMemoryState());
+ EXPECT_EQ(base::MemoryState::THROTTLED,
+ base::MemoryCoordinatorProxy::GetInstance()->
+ GetCurrentMemoryState());
+ base::RunLoop loop;
+ loop.RunUntilIdle();
+ EXPECT_TRUE(client.is_called());
+ EXPECT_EQ(base::MemoryState::THROTTLED, client.state());
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(&client);
+}
+
} // namespace content
« 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