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

Side by Side Diff: base/message_loop/message_loop_unittest.cc

Issue 1255673004: Proof-reading comments in base/message_loop/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: imcoming -> incoming Created 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 Time run_time; 112 Time run_time;
113 113
114 loop.PostTask(FROM_HERE, Bind(&SubPumpFunc)); 114 loop.PostTask(FROM_HERE, Bind(&SubPumpFunc));
115 115
116 // This very delayed task should never run. 116 // This very delayed task should never run.
117 loop.PostDelayedTask( 117 loop.PostDelayedTask(
118 FROM_HERE, 118 FROM_HERE,
119 Bind(&RecordRunTimeFunc, &run_time, &num_tasks), 119 Bind(&RecordRunTimeFunc, &run_time, &num_tasks),
120 TimeDelta::FromSeconds(1000)); 120 TimeDelta::FromSeconds(1000));
121 121
122 // This slightly delayed task should run from within SubPumpFunc). 122 // This slightly delayed task should run from within SubPumpFunc.
123 loop.PostDelayedTask( 123 loop.PostDelayedTask(
124 FROM_HERE, 124 FROM_HERE,
125 Bind(&PostQuitMessage, 0), 125 Bind(&PostQuitMessage, 0),
126 TimeDelta::FromMilliseconds(10)); 126 TimeDelta::FromMilliseconds(10));
127 127
128 Time start_time = Time::Now(); 128 Time start_time = Time::Now();
129 129
130 loop.Run(); 130 loop.Run();
131 EXPECT_EQ(1, num_tasks); 131 EXPECT_EQ(1, num_tasks);
132 132
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 options.message_loop_type = MessageLoop::TYPE_IO; 593 options.message_loop_type = MessageLoop::TYPE_IO;
594 ASSERT_TRUE(thread.StartWithOptions(options)); 594 ASSERT_TRUE(thread.StartWithOptions(options));
595 595
596 MessageLoop* thread_loop = thread.message_loop(); 596 MessageLoop* thread_loop = thread.message_loop();
597 ASSERT_TRUE(NULL != thread_loop); 597 ASSERT_TRUE(NULL != thread_loop);
598 598
599 TestIOHandler handler1(kPipeName1, callback1_called.Get(), false); 599 TestIOHandler handler1(kPipeName1, callback1_called.Get(), false);
600 TestIOHandler handler2(kPipeName2, callback2_called.Get(), true); 600 TestIOHandler handler2(kPipeName2, callback2_called.Get(), true);
601 thread_loop->PostTask(FROM_HERE, Bind(&TestIOHandler::Init, 601 thread_loop->PostTask(FROM_HERE, Bind(&TestIOHandler::Init,
602 Unretained(&handler1))); 602 Unretained(&handler1)));
603 // TODO(ajwong): Do we really need such long Sleeps in ths function? 603 // TODO(ajwong): Do we really need such long Sleeps in this function?
604 // Make sure the thread runs and sleeps for lack of work. 604 // Make sure the thread runs and sleeps for lack of work.
605 TimeDelta delay = TimeDelta::FromMilliseconds(100); 605 TimeDelta delay = TimeDelta::FromMilliseconds(100);
606 PlatformThread::Sleep(delay); 606 PlatformThread::Sleep(delay);
607 thread_loop->PostTask(FROM_HERE, Bind(&TestIOHandler::Init, 607 thread_loop->PostTask(FROM_HERE, Bind(&TestIOHandler::Init,
608 Unretained(&handler2))); 608 Unretained(&handler2)));
609 PlatformThread::Sleep(delay); 609 PlatformThread::Sleep(delay);
610 610
611 // At this time handler1 is waiting to be called, and the thread is waiting 611 // At this time handler1 is waiting to be called, and the thread is waiting
612 // on the Init method of handler2, filtering only handler2 callbacks. 612 // on the Init method of handler2, filtering only handler2 callbacks.
613 613
(...skipping 24 matching lines...) Expand all
638 638
639 RUN_MESSAGE_LOOP_TESTS(Default, &TypeDefaultMessagePumpFactory); 639 RUN_MESSAGE_LOOP_TESTS(Default, &TypeDefaultMessagePumpFactory);
640 RUN_MESSAGE_LOOP_TESTS(UI, &TypeUIMessagePumpFactory); 640 RUN_MESSAGE_LOOP_TESTS(UI, &TypeUIMessagePumpFactory);
641 RUN_MESSAGE_LOOP_TESTS(IO, &TypeIOMessagePumpFactory); 641 RUN_MESSAGE_LOOP_TESTS(IO, &TypeIOMessagePumpFactory);
642 642
643 #if defined(OS_WIN) 643 #if defined(OS_WIN)
644 TEST(MessageLoopTest, PostDelayedTask_SharedTimer_SubPump) { 644 TEST(MessageLoopTest, PostDelayedTask_SharedTimer_SubPump) {
645 RunTest_PostDelayedTask_SharedTimer_SubPump(); 645 RunTest_PostDelayedTask_SharedTimer_SubPump();
646 } 646 }
647 647
648 // This test occasionally hangs http://crbug.com/44567 648 // This test occasionally hangs. See http://crbug.com/44567.
649 TEST(MessageLoopTest, DISABLED_RecursiveDenial2) { 649 TEST(MessageLoopTest, DISABLED_RecursiveDenial2) {
650 RunTest_RecursiveDenial2(MessageLoop::TYPE_DEFAULT); 650 RunTest_RecursiveDenial2(MessageLoop::TYPE_DEFAULT);
651 RunTest_RecursiveDenial2(MessageLoop::TYPE_UI); 651 RunTest_RecursiveDenial2(MessageLoop::TYPE_UI);
652 RunTest_RecursiveDenial2(MessageLoop::TYPE_IO); 652 RunTest_RecursiveDenial2(MessageLoop::TYPE_IO);
653 } 653 }
654 654
655 TEST(MessageLoopTest, RecursiveSupport2) { 655 TEST(MessageLoopTest, RecursiveSupport2) {
656 // This test requires a UI loop 656 // This test requires a UI loop.
657 RunTest_RecursiveSupport2(MessageLoop::TYPE_UI); 657 RunTest_RecursiveSupport2(MessageLoop::TYPE_UI);
658 } 658 }
659 #endif // defined(OS_WIN) 659 #endif // defined(OS_WIN)
660 660
661 class DummyTaskObserver : public MessageLoop::TaskObserver { 661 class DummyTaskObserver : public MessageLoop::TaskObserver {
662 public: 662 public:
663 explicit DummyTaskObserver(int num_tasks) 663 explicit DummyTaskObserver(int num_tasks)
664 : num_tasks_started_(0), 664 : num_tasks_started_(0),
665 num_tasks_processed_(0), 665 num_tasks_processed_(0),
666 num_tasks_(num_tasks) {} 666 num_tasks_(num_tasks) {}
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 loop.SetTaskRunner(new_runner); 1028 loop.SetTaskRunner(new_runner);
1029 1029
1030 scoped_refptr<Foo> foo(new Foo()); 1030 scoped_refptr<Foo> foo(new Foo());
1031 original_runner->PostTask(FROM_HERE, 1031 original_runner->PostTask(FROM_HERE,
1032 Bind(&Foo::Test1ConstRef, foo.get(), "a")); 1032 Bind(&Foo::Test1ConstRef, foo.get(), "a"));
1033 loop.RunUntilIdle(); 1033 loop.RunUntilIdle();
1034 EXPECT_EQ(1, foo->test_count()); 1034 EXPECT_EQ(1, foo->test_count());
1035 } 1035 }
1036 1036
1037 } // namespace base 1037 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop_task_runner_unittest.cc ('k') | base/message_loop/message_pump_glib.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698