| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 int memory_in_percent_override_; | 69 int memory_in_percent_override_; |
| 70 DISALLOW_COPY_AND_ASSIGN(TestMemoryPressureMonitor); | 70 DISALLOW_COPY_AND_ASSIGN(TestMemoryPressureMonitor); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 // This test tests the various transition states from memory pressure, looking | 73 // This test tests the various transition states from memory pressure, looking |
| 74 // for the correct behavior on event reposting as well as state updates. | 74 // for the correct behavior on event reposting as well as state updates. |
| 75 TEST(ChromeOSMemoryPressureMonitorTest, CheckMemoryPressure) { | 75 TEST(ChromeOSMemoryPressureMonitorTest, CheckMemoryPressure) { |
| 76 base::MessageLoopForUI message_loop; | 76 base::MessageLoopForUI message_loop; |
| 77 scoped_ptr<TestMemoryPressureMonitor> monitor( | 77 std::unique_ptr<TestMemoryPressureMonitor> monitor( |
| 78 new TestMemoryPressureMonitor); | 78 new TestMemoryPressureMonitor); |
| 79 scoped_ptr<MemoryPressureListener> listener( | 79 std::unique_ptr<MemoryPressureListener> listener( |
| 80 new MemoryPressureListener(base::Bind(&OnMemoryPressure))); | 80 new MemoryPressureListener(base::Bind(&OnMemoryPressure))); |
| 81 // Checking the memory pressure while 0% are used should not produce any | 81 // Checking the memory pressure while 0% are used should not produce any |
| 82 // events. | 82 // events. |
| 83 monitor->SetMemoryInPercentOverride(0); | 83 monitor->SetMemoryInPercentOverride(0); |
| 84 ResetOnMemoryPressureCalled(); | 84 ResetOnMemoryPressureCalled(); |
| 85 | 85 |
| 86 monitor->CheckMemoryPressureForTest(); | 86 monitor->CheckMemoryPressureForTest(); |
| 87 message_loop.RunUntilIdle(); | 87 message_loop.RunUntilIdle(); |
| 88 EXPECT_FALSE(WasOnMemoryPressureCalled()); | 88 EXPECT_FALSE(WasOnMemoryPressureCalled()); |
| 89 EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE, | 89 EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE, |
| (...skipping 67 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 |