OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_monitor_win.h" | 5 #include "content/browser/memory/memory_monitor_win.h" |
6 | 6 |
7 #include "content/browser/memory/test_memory_monitor.h" | 7 #include "content/browser/memory/test_memory_monitor.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 // A delegate that allows mocking the various inputs to MemoryMonitorWin. | 14 // A delegate that allows mocking the various inputs to MemoryMonitorWin. |
15 class TestMemoryMonitorWinDelegate : public TestMemoryMonitorDelegate { | 15 class TestMemoryMonitorWinDelegate : public TestMemoryMonitorDelegate { |
16 public: | 16 public: |
17 TestMemoryMonitorWinDelegate() {} | 17 TestMemoryMonitorWinDelegate() {} |
18 | 18 |
19 void SetFreeMemoryKB(int free_memory_kb) { | 19 void SetFreeMemoryKB(int free_memory_kb) { |
20 mem_info_.avail_phys = free_memory_kb; | 20 mem_info_.free = free_memory_kb; |
21 } | 21 } |
22 | 22 |
23 private: | 23 private: |
24 DISALLOW_COPY_AND_ASSIGN(TestMemoryMonitorWinDelegate); | 24 DISALLOW_COPY_AND_ASSIGN(TestMemoryMonitorWinDelegate); |
25 }; | 25 }; |
26 | 26 |
27 class TestMemoryMonitorWin : public MemoryMonitorWin { | 27 class TestMemoryMonitorWin : public MemoryMonitorWin { |
28 public: | 28 public: |
29 using MemoryMonitorWin::IsLargeMemory; | 29 using MemoryMonitorWin::IsLargeMemory; |
30 using MemoryMonitorWin::GetTargetFreeMB; | 30 using MemoryMonitorWin::GetTargetFreeMB; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 EXPECT_EQ(1u, delegate_.calls()); | 129 EXPECT_EQ(1u, delegate_.calls()); |
130 delegate_.ResetCalls(); | 130 delegate_.ResetCalls(); |
131 | 131 |
132 delegate_.SetFreeMemoryKB(50 * kKBperMB); | 132 delegate_.SetFreeMemoryKB(50 * kKBperMB); |
133 EXPECT_EQ(-50, monitor_->GetFreeMemoryUntilCriticalMB()); | 133 EXPECT_EQ(-50, monitor_->GetFreeMemoryUntilCriticalMB()); |
134 EXPECT_EQ(1u, delegate_.calls()); | 134 EXPECT_EQ(1u, delegate_.calls()); |
135 delegate_.ResetCalls(); | 135 delegate_.ResetCalls(); |
136 } | 136 } |
137 | 137 |
138 } // namespace content | 138 } // namespace content |
OLD | NEW |