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

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

Issue 2023243002: Remove base::Tuple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint fix Created 4 years, 6 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
OLDNEW
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 <tuple>
6
5 #include "base/bind.h" 7 #include "base/bind.h"
6 #include "base/memory/memory_pressure_listener.h" 8 #include "base/memory/memory_pressure_listener.h"
7 #include "content/browser/memory/memory_message_filter.h" 9 #include "content/browser/memory/memory_message_filter.h"
8 #include "content/browser/memory/memory_pressure_controller_impl.h" 10 #include "content/browser/memory/memory_pressure_controller_impl.h"
9 #include "content/common/memory_messages.h" 11 #include "content/common/memory_messages.h"
10 #include "content/public/test/content_browser_test.h" 12 #include "content/public/test/content_browser_test.h"
11 #include "content/public/test/content_browser_test_utils.h" 13 #include "content/public/test/content_browser_test_utils.h"
12 #include "content/public/test/test_utils.h" 14 #include "content/public/test/test_utils.h"
13 #include "ipc/ipc_message.h" 15 #include "ipc/ipc_message.h"
14 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
15 17
16 namespace content { 18 namespace content {
17 19
18 MATCHER_P(IsSetSuppressedMessage, suppressed, "") { 20 MATCHER_P(IsSetSuppressedMessage, suppressed, "") {
19 // Ensure that the message is deleted upon return. 21 // Ensure that the message is deleted upon return.
20 std::unique_ptr<IPC::Message> message(arg); 22 std::unique_ptr<IPC::Message> message(arg);
21 if (message == nullptr) 23 if (message == nullptr)
22 return false; 24 return false;
23 MemoryMsg_SetPressureNotificationsSuppressed::Param param; 25 MemoryMsg_SetPressureNotificationsSuppressed::Param param;
24 if (!MemoryMsg_SetPressureNotificationsSuppressed::Read(message.get(), 26 if (!MemoryMsg_SetPressureNotificationsSuppressed::Read(message.get(),
25 &param)) 27 &param))
26 return false; 28 return false;
27 return suppressed == base::get<0>(param); 29 return suppressed == std::get<0>(param);
28 } 30 }
29 31
30 MATCHER_P(IsSimulateMessage, level, "") { 32 MATCHER_P(IsSimulateMessage, level, "") {
31 // Ensure that the message is deleted upon return. 33 // Ensure that the message is deleted upon return.
32 std::unique_ptr<IPC::Message> message(arg); 34 std::unique_ptr<IPC::Message> message(arg);
33 if (message == nullptr) 35 if (message == nullptr)
34 return false; 36 return false;
35 MemoryMsg_SimulatePressureNotification::Param param; 37 MemoryMsg_SimulatePressureNotification::Param param;
36 if (!MemoryMsg_SimulatePressureNotification::Read(message.get(), &param)) 38 if (!MemoryMsg_SimulatePressureNotification::Read(message.get(), &param))
37 return false; 39 return false;
38 return level == base::get<0>(param); 40 return level == std::get<0>(param);
39 } 41 }
40 42
41 MATCHER_P(IsPressureMessage, level, "") { 43 MATCHER_P(IsPressureMessage, level, "") {
42 // Ensure that the message is deleted upon return. 44 // Ensure that the message is deleted upon return.
43 std::unique_ptr<IPC::Message> message(arg); 45 std::unique_ptr<IPC::Message> message(arg);
44 if (message == nullptr) 46 if (message == nullptr)
45 return false; 47 return false;
46 MemoryMsg_PressureNotification::Param param; 48 MemoryMsg_PressureNotification::Param param;
47 if (!MemoryMsg_PressureNotification::Read(message.get(), &param)) 49 if (!MemoryMsg_PressureNotification::Read(message.get(), &param))
48 return false; 50 return false;
49 return level == base::get<0>(param); 51 return level == std::get<0>(param);
50 } 52 }
51 53
52 class MemoryMessageFilterForTesting : public MemoryMessageFilter { 54 class MemoryMessageFilterForTesting : public MemoryMessageFilter {
53 public: 55 public:
54 // Use this object itself as a fake RenderProcessHost pointer. The address is 56 // Use this object itself as a fake RenderProcessHost pointer. The address is
55 // only used for looking up the message filter in the controller and is never 57 // only used for looking up the message filter in the controller and is never
56 // actually dereferenced, so this is safe. 58 // actually dereferenced, so this is safe.
57 MemoryMessageFilterForTesting() 59 MemoryMessageFilterForTesting()
58 : MemoryMessageFilter(reinterpret_cast<RenderProcessHost*>(this)) {} 60 : MemoryMessageFilter(reinterpret_cast<RenderProcessHost*>(this)) {}
59 61
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 EXPECT_CALL(*this, OnMemoryPressure(MEMORY_PRESSURE_LEVEL_MODERATE)).Times(1); 267 EXPECT_CALL(*this, OnMemoryPressure(MEMORY_PRESSURE_LEVEL_MODERATE)).Times(1);
266 SimulatePressureNotificationInAllProcessesAndWait( 268 SimulatePressureNotificationInAllProcessesAndWait(
267 MEMORY_PRESSURE_LEVEL_MODERATE); 269 MEMORY_PRESSURE_LEVEL_MODERATE);
268 RunAllPendingInMessageLoop(); // Wait for the listener to run. 270 RunAllPendingInMessageLoop(); // Wait for the listener to run.
269 testing::Mock::VerifyAndClearExpectations(this); 271 testing::Mock::VerifyAndClearExpectations(this);
270 272
271 filter->Remove(); 273 filter->Remove();
272 } 274 }
273 275
274 } // namespace content 276 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698