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

Side by Side Diff: base/message_loop/message_loop_task_runner_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/message_loop/message_loop_task_runner.h" 5 #include "base/message_loop/message_loop_task_runner.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/debug/leak_annotations.h" 11 #include "base/debug/leak_annotations.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/message_loop/message_loop_task_runner.h" 13 #include "base/message_loop/message_loop_task_runner.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/single_thread_task_runner.h"
16 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
17 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
18 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
19 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
20 #include "testing/platform_test.h" 19 #include "testing/platform_test.h"
21 20
22 namespace base { 21 namespace base {
23 22
24 class MessageLoopTaskRunnerTest : public testing::Test { 23 class MessageLoopTaskRunnerTest : public testing::Test {
25 public: 24 public:
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 FROM_HERE, Bind(&RecordLoop, task_recoder), 117 FROM_HERE, Bind(&RecordLoop, task_recoder),
119 Bind(&RecordLoopAndQuit, reply_recoder))); 118 Bind(&RecordLoopAndQuit, reply_recoder)));
120 119
121 // Die if base::Bind doesn't retain a reference to the recorders. 120 // Die if base::Bind doesn't retain a reference to the recorders.
122 task_recoder = NULL; 121 task_recoder = NULL;
123 reply_recoder = NULL; 122 reply_recoder = NULL;
124 ASSERT_FALSE(task_deleted_on); 123 ASSERT_FALSE(task_deleted_on);
125 ASSERT_FALSE(reply_deleted_on); 124 ASSERT_FALSE(reply_deleted_on);
126 125
127 UnblockTaskThread(); 126 UnblockTaskThread();
128 current_loop_->Run(); 127 RunLoop().Run();
129 128
130 EXPECT_EQ(task_thread_.message_loop(), task_run_on); 129 EXPECT_EQ(task_thread_.message_loop(), task_run_on);
131 EXPECT_EQ(current_loop_.get(), task_deleted_on); 130 EXPECT_EQ(current_loop_.get(), task_deleted_on);
132 EXPECT_EQ(current_loop_.get(), reply_run_on); 131 EXPECT_EQ(current_loop_.get(), reply_run_on);
133 EXPECT_EQ(current_loop_.get(), reply_deleted_on); 132 EXPECT_EQ(current_loop_.get(), reply_deleted_on);
134 EXPECT_LT(task_delete_order, reply_delete_order); 133 EXPECT_LT(task_delete_order, reply_delete_order);
135 } 134 }
136 135
137 TEST_F(MessageLoopTaskRunnerTest, PostTaskAndReplyOnDeletedThreadDoesNotLeak) { 136 TEST_F(MessageLoopTaskRunnerTest, PostTaskAndReplyOnDeletedThreadDoesNotLeak) {
138 MessageLoop* task_run_on = NULL; 137 MessageLoop* task_run_on = NULL;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 ASSERT_TRUE(current_loop_->task_runner()->PostTaskAndReply( 184 ASSERT_TRUE(current_loop_->task_runner()->PostTaskAndReply(
186 FROM_HERE, Bind(&RecordLoop, task_recoder), 185 FROM_HERE, Bind(&RecordLoop, task_recoder),
187 Bind(&RecordLoopAndQuit, reply_recoder))); 186 Bind(&RecordLoopAndQuit, reply_recoder)));
188 187
189 // Die if base::Bind doesn't retain a reference to the recorders. 188 // Die if base::Bind doesn't retain a reference to the recorders.
190 task_recoder = NULL; 189 task_recoder = NULL;
191 reply_recoder = NULL; 190 reply_recoder = NULL;
192 ASSERT_FALSE(task_deleted_on); 191 ASSERT_FALSE(task_deleted_on);
193 ASSERT_FALSE(reply_deleted_on); 192 ASSERT_FALSE(reply_deleted_on);
194 193
195 current_loop_->Run(); 194 RunLoop().Run();
196 195
197 EXPECT_EQ(current_loop_.get(), task_run_on); 196 EXPECT_EQ(current_loop_.get(), task_run_on);
198 EXPECT_EQ(current_loop_.get(), task_deleted_on); 197 EXPECT_EQ(current_loop_.get(), task_deleted_on);
199 EXPECT_EQ(current_loop_.get(), reply_run_on); 198 EXPECT_EQ(current_loop_.get(), reply_run_on);
200 EXPECT_EQ(current_loop_.get(), reply_deleted_on); 199 EXPECT_EQ(current_loop_.get(), reply_deleted_on);
201 EXPECT_LT(task_delete_order, reply_delete_order); 200 EXPECT_LT(task_delete_order, reply_delete_order);
202 } 201 }
203 202
204 TEST_F(MessageLoopTaskRunnerTest, PostTaskAndReply_DeadReplyLoopDoesNotDelete) { 203 TEST_F(MessageLoopTaskRunnerTest, PostTaskAndReply_DeadReplyLoopDoesNotDelete) {
205 // Annotate the scope as having memory leaks to suppress heapchecker reports. 204 // Annotate the scope as having memory leaks to suppress heapchecker reports.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 new Thread("MessageLoopTaskRunnerThreadingTest_Dummy")); 353 new Thread("MessageLoopTaskRunnerThreadingTest_Dummy"));
355 test_thread->Start(); 354 test_thread->Start();
356 task_runner = test_thread->task_runner(); 355 task_runner = test_thread->task_runner();
357 } 356 }
358 bool ret = task_runner->PostTask( 357 bool ret = task_runner->PostTask(
359 FROM_HERE, Bind(&MessageLoopTaskRunnerThreadingTest::AssertNotRun)); 358 FROM_HERE, Bind(&MessageLoopTaskRunnerThreadingTest::AssertNotRun));
360 EXPECT_FALSE(ret); 359 EXPECT_FALSE(ret);
361 } 360 }
362 361
363 } // namespace base 362 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/memory_pressure_listener_unittest.cc ('k') | base/message_loop/message_loop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698