| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/memory/memory_pressure_monitor_chromeos.h" | 5 #include "base/memory/memory_pressure_monitor_chromeos.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/memory_pressure_listener.h" | 8 #include "base/memory/memory_pressure_listener.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 monitor->CheckMemoryPressureForTest(); | 105 monitor->CheckMemoryPressureForTest(); |
| 106 message_loop.RunUntilIdle(); | 106 message_loop.RunUntilIdle(); |
| 107 EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE, | 107 EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE, |
| 108 monitor->GetCurrentPressureLevel()); | 108 monitor->GetCurrentPressureLevel()); |
| 109 if (WasOnMemoryPressureCalled()) { | 109 if (WasOnMemoryPressureCalled()) { |
| 110 EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE, | 110 EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE, |
| 111 on_memory_pressure_level); | 111 on_memory_pressure_level); |
| 112 break; | 112 break; |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 // Should be more then 5 and less then 100. | 115 // Should be more than 5 and less than 100. |
| 116 EXPECT_LE(5, i); | 116 EXPECT_LE(5, i); |
| 117 EXPECT_GE(99, i); | 117 EXPECT_GE(99, i); |
| 118 | 118 |
| 119 // Setting the memory usage to 99% should produce critical levels. | 119 // Setting the memory usage to 99% should produce critical levels. |
| 120 monitor->SetMemoryInPercentOverride(99); | 120 monitor->SetMemoryInPercentOverride(99); |
| 121 monitor->CheckMemoryPressureForTest(); | 121 monitor->CheckMemoryPressureForTest(); |
| 122 message_loop.RunUntilIdle(); | 122 message_loop.RunUntilIdle(); |
| 123 EXPECT_TRUE(WasOnMemoryPressureCalled()); | 123 EXPECT_TRUE(WasOnMemoryPressureCalled()); |
| 124 EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL, | 124 EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL, |
| 125 on_memory_pressure_level); | 125 on_memory_pressure_level); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 on_memory_pressure_level); | 157 on_memory_pressure_level); |
| 158 break; | 158 break; |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 // We should have needed exactly the same amount of checks as before. | 161 // We should have needed exactly the same amount of checks as before. |
| 162 EXPECT_EQ(j, i); | 162 EXPECT_EQ(j, i); |
| 163 } | 163 } |
| 164 | 164 |
| 165 } // namespace chromeos | 165 } // namespace chromeos |
| 166 } // namespace base | 166 } // namespace base |
| OLD | NEW |