| 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 d8c575d67a32da6a69997937f56be9f6512ef619..a0d1e925a31bc9cd86495ef3298a05c65d068a26 100644
|
| --- a/content/browser/memory/memory_coordinator_impl_unittest.cc
|
| +++ b/content/browser/memory/memory_coordinator_impl_unittest.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "content/browser/memory/memory_coordinator_impl.h"
|
|
|
| +#include "base/memory/memory_coordinator_proxy.h"
|
| #include "base/run_loop.h"
|
| #include "content/browser/memory/memory_monitor.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| @@ -50,8 +51,15 @@ class MockMemoryMonitor : public MemoryMonitor {
|
| class MemoryCoordinatorImplTest : public testing::Test {
|
| public:
|
| void SetUp() override {
|
| + MemoryCoordinator::EnableFeaturesForTesting();
|
| +
|
| coordinator_.reset(new MemoryCoordinatorImpl(
|
| message_loop_.task_runner(), base::WrapUnique(new MockMemoryMonitor)));
|
| +
|
| + base::MemoryCoordinatorProxy::GetInstance()->
|
| + SetGetCurrentMemoryStateCallback(base::Bind(
|
| + &MemoryCoordinator::GetCurrentMemoryState,
|
| + base::Unretained(coordinator_.get())));
|
| }
|
|
|
| MockMemoryMonitor* GetMockMemoryMonitor() {
|
| @@ -73,10 +81,17 @@ TEST_F(MemoryCoordinatorImplTest, CalculateNextState) {
|
|
|
| // The default state is NORMAL.
|
| EXPECT_EQ(base::MemoryState::NORMAL, coordinator_->GetCurrentMemoryState());
|
| + EXPECT_EQ(base::MemoryState::NORMAL,
|
| + base::MemoryCoordinatorProxy::GetInstance()->
|
| + GetCurrentMemoryState());
|
|
|
| // Transitions from NORMAL
|
| coordinator_->current_state_ = base::MemoryState::NORMAL;
|
| EXPECT_EQ(base::MemoryState::NORMAL, coordinator_->GetCurrentMemoryState());
|
| + EXPECT_EQ(base::MemoryState::NORMAL,
|
| + base::MemoryCoordinatorProxy::GetInstance()->
|
| + GetCurrentMemoryState());
|
| +
|
| GetMockMemoryMonitor()->SetFreeMemoryUntilCriticalMB(50);
|
| EXPECT_EQ(base::MemoryState::NORMAL, coordinator_->CalculateNextState());
|
| GetMockMemoryMonitor()->SetFreeMemoryUntilCriticalMB(40);
|
| @@ -88,6 +103,10 @@ TEST_F(MemoryCoordinatorImplTest, CalculateNextState) {
|
| coordinator_->current_state_ = base::MemoryState::THROTTLED;
|
| EXPECT_EQ(base::MemoryState::THROTTLED,
|
| coordinator_->GetCurrentMemoryState());
|
| + EXPECT_EQ(base::MemoryState::THROTTLED,
|
| + base::MemoryCoordinatorProxy::GetInstance()->
|
| + GetCurrentMemoryState());
|
| +
|
| GetMockMemoryMonitor()->SetFreeMemoryUntilCriticalMB(40);
|
| EXPECT_EQ(base::MemoryState::THROTTLED, coordinator_->CalculateNextState());
|
| GetMockMemoryMonitor()->SetFreeMemoryUntilCriticalMB(50);
|
| @@ -99,6 +118,10 @@ TEST_F(MemoryCoordinatorImplTest, CalculateNextState) {
|
| coordinator_->current_state_ = base::MemoryState::SUSPENDED;
|
| EXPECT_EQ(base::MemoryState::SUSPENDED,
|
| coordinator_->GetCurrentMemoryState());
|
| + EXPECT_EQ(base::MemoryState::SUSPENDED,
|
| + base::MemoryCoordinatorProxy::GetInstance()->
|
| + GetCurrentMemoryState());
|
| +
|
| GetMockMemoryMonitor()->SetFreeMemoryUntilCriticalMB(20);
|
| EXPECT_EQ(base::MemoryState::SUSPENDED, coordinator_->CalculateNextState());
|
| GetMockMemoryMonitor()->SetFreeMemoryUntilCriticalMB(30);
|
|
|