| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/memory/memory_coordinator_impl.h" | 5 #include "content/browser/memory/memory_coordinator_impl.h" |
| 6 | 6 |
| 7 #include "base/memory/memory_coordinator_proxy.h" | 7 #include "base/memory/memory_coordinator_proxy.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "content/browser/memory/memory_monitor.h" | 9 #include "content/browser/memory/memory_monitor.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 int free_memory_ = 0; | 46 int free_memory_ = 0; |
| 47 | 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(MockMemoryMonitor); | 48 DISALLOW_COPY_AND_ASSIGN(MockMemoryMonitor); |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 class MemoryCoordinatorImplTest : public testing::Test { | 51 class MemoryCoordinatorImplTest : public testing::Test { |
| 52 public: | 52 public: |
| 53 void SetUp() override { | 53 void SetUp() override { |
| 54 MemoryCoordinator::EnableFeaturesForTesting(); | 54 content::EnableFeaturesForTesting(); |
| 55 | 55 |
| 56 coordinator_.reset(new MemoryCoordinatorImpl( | 56 coordinator_.reset(new MemoryCoordinatorImpl( |
| 57 message_loop_.task_runner(), base::WrapUnique(new MockMemoryMonitor))); | 57 message_loop_.task_runner(), base::WrapUnique(new MockMemoryMonitor))); |
| 58 | 58 |
| 59 base::MemoryCoordinatorProxy::GetInstance()-> | 59 base::MemoryCoordinatorProxy::GetInstance()-> |
| 60 SetGetCurrentMemoryStateCallback(base::Bind( | 60 SetGetCurrentMemoryStateCallback(base::Bind( |
| 61 &MemoryCoordinator::GetCurrentMemoryState, | 61 &MemoryCoordinator::GetCurrentMemoryState, |
| 62 base::Unretained(coordinator_.get()))); | 62 base::Unretained(coordinator_.get()))); |
| 63 base::MemoryCoordinatorProxy::GetInstance()-> | 63 base::MemoryCoordinatorProxy::GetInstance()-> |
| 64 SetSetCurrentMemoryStateForTestingCallback(base::Bind( | 64 SetSetCurrentMemoryStateForTestingCallback(base::Bind( |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 base::MemoryCoordinatorProxy::GetInstance()-> | 195 base::MemoryCoordinatorProxy::GetInstance()-> |
| 196 GetCurrentMemoryState()); | 196 GetCurrentMemoryState()); |
| 197 base::RunLoop loop; | 197 base::RunLoop loop; |
| 198 loop.RunUntilIdle(); | 198 loop.RunUntilIdle(); |
| 199 EXPECT_TRUE(client.is_called()); | 199 EXPECT_TRUE(client.is_called()); |
| 200 EXPECT_EQ(base::MemoryState::THROTTLED, client.state()); | 200 EXPECT_EQ(base::MemoryState::THROTTLED, client.state()); |
| 201 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(&client); | 201 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(&client); |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace content | 204 } // namespace content |
| OLD | NEW |