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

Side by Side Diff: base/memory/memory_pressure_listener_unittest.cc

Issue 2132593002: Remove remaining calls to deprecated MessageLoop methods on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: h264_vt_encoder_unittest.cc Created 4 years, 5 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 "base/memory/memory_pressure_listener.h" 5 #include "base/memory/memory_pressure_listener.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h"
9 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
10 11
11 namespace base { 12 namespace base {
12 13
13 using MemoryPressureLevel = MemoryPressureListener::MemoryPressureLevel; 14 using MemoryPressureLevel = MemoryPressureListener::MemoryPressureLevel;
14 15
15 class MemoryPressureListenerTest : public testing::Test { 16 class MemoryPressureListenerTest : public testing::Test {
16 public: 17 public:
17 void SetUp() override { 18 void SetUp() override {
18 message_loop_.reset(new MessageLoopForUI()); 19 message_loop_.reset(new MessageLoopForUI());
19 listener_.reset(new MemoryPressureListener( 20 listener_.reset(new MemoryPressureListener(
20 Bind(&MemoryPressureListenerTest::OnMemoryPressure, Unretained(this)))); 21 Bind(&MemoryPressureListenerTest::OnMemoryPressure, Unretained(this))));
21 } 22 }
22 23
23 void TearDown() override { 24 void TearDown() override {
24 listener_.reset(); 25 listener_.reset();
25 message_loop_.reset(); 26 message_loop_.reset();
26 } 27 }
27 28
28 protected: 29 protected:
29 void ExpectNotification( 30 void ExpectNotification(
30 void (*notification_function)(MemoryPressureLevel), 31 void (*notification_function)(MemoryPressureLevel),
31 MemoryPressureLevel level) { 32 MemoryPressureLevel level) {
32 EXPECT_CALL(*this, OnMemoryPressure(level)).Times(1); 33 EXPECT_CALL(*this, OnMemoryPressure(level)).Times(1);
33 notification_function(level); 34 notification_function(level);
34 message_loop_->RunUntilIdle(); 35 RunLoop().RunUntilIdle();
35 } 36 }
36 37
37 void ExpectNoNotification( 38 void ExpectNoNotification(
38 void (*notification_function)(MemoryPressureLevel), 39 void (*notification_function)(MemoryPressureLevel),
39 MemoryPressureLevel level) { 40 MemoryPressureLevel level) {
40 EXPECT_CALL(*this, OnMemoryPressure(testing::_)).Times(0); 41 EXPECT_CALL(*this, OnMemoryPressure(testing::_)).Times(0);
41 notification_function(level); 42 notification_function(level);
42 message_loop_->RunUntilIdle(); 43 RunLoop().RunUntilIdle();
43 } 44 }
44 45
45 private: 46 private:
46 MOCK_METHOD1(OnMemoryPressure, 47 MOCK_METHOD1(OnMemoryPressure,
47 void(MemoryPressureListener::MemoryPressureLevel)); 48 void(MemoryPressureListener::MemoryPressureLevel));
48 49
49 std::unique_ptr<MessageLoopForUI> message_loop_; 50 std::unique_ptr<MessageLoopForUI> message_loop_;
50 std::unique_ptr<MemoryPressureListener> listener_; 51 std::unique_ptr<MemoryPressureListener> listener_;
51 }; 52 };
52 53
(...skipping 16 matching lines...) Expand all
69 // Disable suppressing memory pressure notifications. 70 // Disable suppressing memory pressure notifications.
70 MemoryPressureListener::SetNotificationsSuppressed(false); 71 MemoryPressureListener::SetNotificationsSuppressed(false);
71 EXPECT_FALSE(MemoryPressureListener::AreNotificationsSuppressed()); 72 EXPECT_FALSE(MemoryPressureListener::AreNotificationsSuppressed());
72 ExpectNotification(&MemoryPressureListener::NotifyMemoryPressure, 73 ExpectNotification(&MemoryPressureListener::NotifyMemoryPressure,
73 MemoryPressureLevel::MEMORY_PRESSURE_LEVEL_CRITICAL); 74 MemoryPressureLevel::MEMORY_PRESSURE_LEVEL_CRITICAL);
74 ExpectNotification(&MemoryPressureListener::SimulatePressureNotification, 75 ExpectNotification(&MemoryPressureListener::SimulatePressureNotification,
75 MemoryPressureLevel::MEMORY_PRESSURE_LEVEL_CRITICAL); 76 MemoryPressureLevel::MEMORY_PRESSURE_LEVEL_CRITICAL);
76 } 77 }
77 78
78 } // namespace base 79 } // namespace base
OLDNEW
« no previous file with comments | « base/ios/weak_nsobject_unittest.mm ('k') | base/message_loop/message_loop_task_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698