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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/memory_pressure_listener.h" | 6 #include "base/memory/memory_pressure_listener.h" |
7 #include "content/browser/memory/memory_message_filter.h" | 7 #include "content/browser/memory/memory_message_filter.h" |
8 #include "content/browser/memory/memory_pressure_controller_impl.h" | 8 #include "content/browser/memory/memory_pressure_controller_impl.h" |
9 #include "content/common/memory_messages.h" | 9 #include "content/common/memory_messages.h" |
10 #include "content/public/test/content_browser_test.h" | 10 #include "content/public/test/content_browser_test.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 SetPressureNotificationsSuppressedInAllProcessesAndWait(false); | 210 SetPressureNotificationsSuppressedInAllProcessesAndWait(false); |
211 EXPECT_FALSE(base::MemoryPressureListener::AreNotificationsSuppressed()); | 211 EXPECT_FALSE(base::MemoryPressureListener::AreNotificationsSuppressed()); |
212 testing::Mock::VerifyAndClearExpectations(this); | 212 testing::Mock::VerifyAndClearExpectations(this); |
213 } | 213 } |
214 | 214 |
215 IN_PROC_BROWSER_TEST_F(MemoryPressureControllerImplBrowserTest, | 215 IN_PROC_BROWSER_TEST_F(MemoryPressureControllerImplBrowserTest, |
216 SimulatePressureNotificationInAllProcesses) { | 216 SimulatePressureNotificationInAllProcesses) { |
217 scoped_refptr<MemoryMessageFilterForTesting> filter( | 217 scoped_refptr<MemoryMessageFilterForTesting> filter( |
218 new MemoryMessageFilterForTesting); | 218 new MemoryMessageFilterForTesting); |
219 std::unique_ptr<base::MemoryPressureListener> listener( | 219 std::unique_ptr<base::MemoryPressureListener> listener( |
220 new base::MemoryPressureListener( | 220 base::MemoryPressureListener::Create( |
221 base::Bind(&MemoryPressureControllerImplBrowserTest::OnMemoryPressure, | 221 base::Bind(&MemoryPressureControllerImplBrowserTest::OnMemoryPressure, |
222 base::Unretained(this)))); | 222 base::Unretained(this)))); |
223 | 223 |
224 NavigateToURL(shell(), GetTestUrl("", "title.html")); | 224 NavigateToURL(shell(), GetTestUrl("", "title.html")); |
225 | 225 |
226 filter->Add(); | 226 filter->Add(); |
227 | 227 |
228 // Send a memory pressure event to the first child process. It should send a | 228 // Send a memory pressure event to the first child process. It should send a |
229 // pressure notification message. | 229 // pressure notification message. |
230 EXPECT_CALL(*filter, Send(IsPressureMessage(MEMORY_PRESSURE_LEVEL_MODERATE))) | 230 EXPECT_CALL(*filter, Send(IsPressureMessage(MEMORY_PRESSURE_LEVEL_MODERATE))) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 EXPECT_CALL(*this, OnMemoryPressure(MEMORY_PRESSURE_LEVEL_MODERATE)).Times(1); | 265 EXPECT_CALL(*this, OnMemoryPressure(MEMORY_PRESSURE_LEVEL_MODERATE)).Times(1); |
266 SimulatePressureNotificationInAllProcessesAndWait( | 266 SimulatePressureNotificationInAllProcessesAndWait( |
267 MEMORY_PRESSURE_LEVEL_MODERATE); | 267 MEMORY_PRESSURE_LEVEL_MODERATE); |
268 RunAllPendingInMessageLoop(); // Wait for the listener to run. | 268 RunAllPendingInMessageLoop(); // Wait for the listener to run. |
269 testing::Mock::VerifyAndClearExpectations(this); | 269 testing::Mock::VerifyAndClearExpectations(this); |
270 | 270 |
271 filter->Remove(); | 271 filter->Remove(); |
272 } | 272 } |
273 | 273 |
274 } // namespace content | 274 } // namespace content |
OLD | NEW |