Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Side by Side Diff: content/browser/memory/memory_monitor_win_unittest.cc

Issue 2558043007: Fix free memory calculation. (Closed)
Patch Set: Fix integer overflow in unittest. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/memory/memory_monitor_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_.free = free_memory_kb; 20 mem_info_.avail_phys = 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
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
OLDNEW
« no previous file with comments | « content/browser/memory/memory_monitor_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698