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

Side by Side Diff: base/message_loop_unittest.cc

Issue 12226007: base: Convert the remaining uses of MessageLoop::RunUntilIdle to RunLoop variant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « base/files/important_file_writer_unittest.cc ('k') | base/message_pump_glib_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 EXPECT_EQ(0, num_tasks); 320 EXPECT_EQ(0, num_tasks);
321 321
322 // Ensure that we ran in far less time than the slower timer. 322 // Ensure that we ran in far less time than the slower timer.
323 TimeDelta total_time = Time::Now() - start_time; 323 TimeDelta total_time = Time::Now() - start_time;
324 EXPECT_GT(5000, total_time.InMilliseconds()); 324 EXPECT_GT(5000, total_time.InMilliseconds());
325 325
326 // In case both timers somehow run at nearly the same time, sleep a little 326 // In case both timers somehow run at nearly the same time, sleep a little
327 // and then run all pending to force them both to have run. This is just 327 // and then run all pending to force them both to have run. This is just
328 // encouraging flakiness if there is any. 328 // encouraging flakiness if there is any.
329 PlatformThread::Sleep(TimeDelta::FromMilliseconds(100)); 329 PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
330 loop.RunUntilIdle(); 330 base::RunLoop().RunUntilIdle();
331 331
332 EXPECT_TRUE(run_time1.is_null()); 332 EXPECT_TRUE(run_time1.is_null());
333 EXPECT_FALSE(run_time2.is_null()); 333 EXPECT_FALSE(run_time2.is_null());
334 } 334 }
335 335
336 #if defined(OS_WIN) 336 #if defined(OS_WIN)
337 337
338 void SubPumpFunc() { 338 void SubPumpFunc() {
339 MessageLoop::current()->SetNestableTasksAllowed(true); 339 MessageLoop::current()->SetNestableTasksAllowed(true);
340 MSG msg; 340 MSG msg;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 EXPECT_EQ(1, num_tasks); 376 EXPECT_EQ(1, num_tasks);
377 377
378 // Ensure that we ran in far less time than the slower timer. 378 // Ensure that we ran in far less time than the slower timer.
379 TimeDelta total_time = Time::Now() - start_time; 379 TimeDelta total_time = Time::Now() - start_time;
380 EXPECT_GT(5000, total_time.InMilliseconds()); 380 EXPECT_GT(5000, total_time.InMilliseconds());
381 381
382 // In case both timers somehow run at nearly the same time, sleep a little 382 // In case both timers somehow run at nearly the same time, sleep a little
383 // and then run all pending to force them both to have run. This is just 383 // and then run all pending to force them both to have run. This is just
384 // encouraging flakiness if there is any. 384 // encouraging flakiness if there is any.
385 PlatformThread::Sleep(TimeDelta::FromMilliseconds(100)); 385 PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
386 loop.RunUntilIdle(); 386 base::RunLoop().RunUntilIdle();
387 387
388 EXPECT_TRUE(run_time.is_null()); 388 EXPECT_TRUE(run_time.is_null());
389 } 389 }
390 390
391 #endif // defined(OS_WIN) 391 #endif // defined(OS_WIN)
392 392
393 // This is used to inject a test point for recording the destructor calls for 393 // This is used to inject a test point for recording the destructor calls for
394 // Closure objects send to MessageLoop::PostTask(). It is awkward usage since we 394 // Closure objects send to MessageLoop::PostTask(). It is awkward usage since we
395 // are trying to hook the actual destruction, which is not a common operation. 395 // are trying to hook the actual destruction, which is not a common operation.
396 class RecordDeletionProbe : public base::RefCounted<RecordDeletionProbe> { 396 class RecordDeletionProbe : public base::RefCounted<RecordDeletionProbe> {
(...skipping 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 // exist in other MessagePumps. 2075 // exist in other MessagePumps.
2076 2076
2077 // On Linux, the pipe buffer size is 64KiB by default. The bug caused one 2077 // On Linux, the pipe buffer size is 64KiB by default. The bug caused one
2078 // byte accumulated in the pipe per two posts, so we should repeat 128K 2078 // byte accumulated in the pipe per two posts, so we should repeat 128K
2079 // times to reproduce the bug. 2079 // times to reproduce the bug.
2080 const int kNumTimes = 1 << 17; 2080 const int kNumTimes = 1 << 17;
2081 RunTest_RecursivePosts(MessageLoop::TYPE_DEFAULT, kNumTimes); 2081 RunTest_RecursivePosts(MessageLoop::TYPE_DEFAULT, kNumTimes);
2082 RunTest_RecursivePosts(MessageLoop::TYPE_UI, kNumTimes); 2082 RunTest_RecursivePosts(MessageLoop::TYPE_UI, kNumTimes);
2083 RunTest_RecursivePosts(MessageLoop::TYPE_IO, kNumTimes); 2083 RunTest_RecursivePosts(MessageLoop::TYPE_IO, kNumTimes);
2084 } 2084 }
OLDNEW
« no previous file with comments | « base/files/important_file_writer_unittest.cc ('k') | base/message_pump_glib_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698