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 "components/memory_pressure/memory_pressure_monitor.h" | 5 #include "components/memory_pressure/memory_pressure_monitor.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
9 #include "base/tracked_objects.h" | 11 #include "base/tracked_objects.h" |
10 #include "components/memory_pressure/memory_pressure_stats_collector.h" | 12 #include "components/memory_pressure/memory_pressure_stats_collector.h" |
11 #include "components/memory_pressure/test_memory_pressure_calculator.h" | 13 #include "components/memory_pressure/test_memory_pressure_calculator.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
14 | 16 |
15 namespace memory_pressure { | 17 namespace memory_pressure { |
16 | 18 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 MockTaskRunner mock_task_runner_; | 210 MockTaskRunner mock_task_runner_; |
209 scoped_refptr<TaskRunnerProxy> task_runner_proxy_; | 211 scoped_refptr<TaskRunnerProxy> task_runner_proxy_; |
210 base::SimpleTestTickClock tick_clock_; | 212 base::SimpleTestTickClock tick_clock_; |
211 MemoryPressureStatsCollector stats_collector_; | 213 MemoryPressureStatsCollector stats_collector_; |
212 | 214 |
213 #if defined(MEMORY_PRESSURE_IS_POLLING) | 215 #if defined(MEMORY_PRESSURE_IS_POLLING) |
214 TestMemoryPressureCalculator calculator_; | 216 TestMemoryPressureCalculator calculator_; |
215 #endif | 217 #endif |
216 | 218 |
217 MockDispatch mock_dispatch_; | 219 MockDispatch mock_dispatch_; |
218 scoped_ptr<TestMemoryPressureMonitor> monitor_; | 220 std::unique_ptr<TestMemoryPressureMonitor> monitor_; |
219 }; | 221 }; |
220 | 222 |
221 TEST_F(MemoryPressureMonitorTest, NormalScheduling) { | 223 TEST_F(MemoryPressureMonitorTest, NormalScheduling) { |
222 CreateMonitor(MEMORY_PRESSURE_LEVEL_NONE); | 224 CreateMonitor(MEMORY_PRESSURE_LEVEL_NONE); |
223 | 225 |
224 Tick(MemoryPressureMonitor::kDefaultPollingIntervalMs); | 226 Tick(MemoryPressureMonitor::kDefaultPollingIntervalMs); |
225 ExpectTaskPosted(MemoryPressureMonitor::kDefaultPollingIntervalMs); | 227 ExpectTaskPosted(MemoryPressureMonitor::kDefaultPollingIntervalMs); |
226 monitor_->CheckPressureAndUpdateStats(monitor_->serial_number()); | 228 monitor_->CheckPressureAndUpdateStats(monitor_->serial_number()); |
227 VerifyAndClearExpectations(); | 229 VerifyAndClearExpectations(); |
228 | 230 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 ExpectDispatchCritical(); | 380 ExpectDispatchCritical(); |
379 monitor_->OnMemoryPressureChanged(MEMORY_PRESSURE_LEVEL_CRITICAL); | 381 monitor_->OnMemoryPressureChanged(MEMORY_PRESSURE_LEVEL_CRITICAL); |
380 VerifyAndClearExpectations(); | 382 VerifyAndClearExpectations(); |
381 ExpectCritical(); | 383 ExpectCritical(); |
382 EXPECT_EQ(2u, monitor_->scheduled_checks().size()); | 384 EXPECT_EQ(2u, monitor_->scheduled_checks().size()); |
383 } | 385 } |
384 | 386 |
385 #endif // !MEMORY_PRESSURE_IS_POLLING | 387 #endif // !MEMORY_PRESSURE_IS_POLLING |
386 | 388 |
387 } // namespace memory_pressure | 389 } // namespace memory_pressure |
OLD | NEW |