OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/direct_memory_pressure_calculator_linux.h" | 5 #include "components/memory_pressure/direct_memory_pressure_calculator_linux.h" |
6 | 6 |
| 7 #include "base/process/process_metrics.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
8 | 9 |
9 namespace memory_pressure { | 10 namespace memory_pressure { |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 static const int kKBperMB = 1024; | 14 const int kKBperMB = 1024; |
14 static const int kTotalMemoryInMB = 4096; | 15 const int kTotalMemoryInMB = 4096; |
15 | 16 |
16 } // namespace | 17 } // namespace |
17 | 18 |
18 // This is out of the anonymous namespace space because it is a friend of | 19 // This is out of the anonymous namespace space because it is a friend of |
19 // DirectMemoryPressureCalculator. | 20 // DirectMemoryPressureCalculator. |
20 class TestDirectMemoryPressureCalculator | 21 class TestDirectMemoryPressureCalculator |
21 : public DirectMemoryPressureCalculator { | 22 : public DirectMemoryPressureCalculator { |
22 public: | 23 public: |
23 explicit TestDirectMemoryPressureCalculator() | 24 TestDirectMemoryPressureCalculator() |
24 : DirectMemoryPressureCalculator(20, 10) { | 25 : DirectMemoryPressureCalculator(20, 10) { |
25 // The values passed to the MemoryPressureCalculator constructor are dummy | 26 // The values passed to the MemoryPressureCalculator constructor are dummy |
26 // values that are immediately overwritten by InferTresholds. | 27 // values that are immediately overwritten by InferTresholds. |
27 | 28 |
28 // Simulate 4GB of RAM. | 29 // Simulate 4GB of RAM. |
29 mem_info_.total = kTotalMemoryInMB * kKBperMB; | 30 mem_info_.total = kTotalMemoryInMB * kKBperMB; |
30 | 31 |
31 // Run InferThresholds using the test fixture's GetSystemMemoryStatus. | 32 // Run InferThresholds using the test fixture's GetSystemMemoryStatus. |
32 InferThresholds(); | 33 InferThresholds(); |
33 } | 34 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 142 |
142 TestDirectMemoryPressureCalculator calc(kSystemMb, kModerateMb, kCriticalMb); | 143 TestDirectMemoryPressureCalculator calc(kSystemMb, kModerateMb, kCriticalMb); |
143 | 144 |
144 EXPECT_EQ(kModerateMb, calc.moderate_threshold_mb()); | 145 EXPECT_EQ(kModerateMb, calc.moderate_threshold_mb()); |
145 EXPECT_EQ(kCriticalMb, calc.critical_threshold_mb()); | 146 EXPECT_EQ(kCriticalMb, calc.critical_threshold_mb()); |
146 | 147 |
147 ASSERT_NO_FATAL_FAILURE(CalculateCurrentPressureLevelTest(&calc)); | 148 ASSERT_NO_FATAL_FAILURE(CalculateCurrentPressureLevelTest(&calc)); |
148 } | 149 } |
149 | 150 |
150 } // namespace memory_pressure | 151 } // namespace memory_pressure |
OLD | NEW |