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

Unified Diff: base/message_loop_unittest.cc

Issue 10210008: Make MessageLoopProxy::current() usable on threads that don't have MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/message_loop_proxy_impl.cc ('k') | base/thread_main_task_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop_unittest.cc
diff --git a/base/message_loop_unittest.cc b/base/message_loop_unittest.cc
index 15f825b7ac992eb791ecc2332819e7a03b160896..6d264fd0dd50597f781a0f6d991424ce36a5f45a 100644
--- a/base/message_loop_unittest.cc
+++ b/base/message_loop_unittest.cc
@@ -1689,3 +1689,24 @@ TEST(MessageLoopTest, DestructionObserverTest) {
EXPECT_TRUE(task_destroyed);
EXPECT_TRUE(destruction_observer_called);
}
+
+// Verify that MessageLoop sets ThreadMainTaskRunner::current() and it
+// posts tasks on that message loop.
+TEST(MessageLoopTest, ThreadMainTaskRunner) {
+ MessageLoop loop;
+
+ scoped_refptr<Foo> foo(new Foo());
+ std::string a("a");
+ base::ThreadMainTaskRunner::current()->PostTask(FROM_HERE, base::Bind(
+ &Foo::Test1ConstRef, foo.get(), a));
+
+ // Post quit task;
+ MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
+ &MessageLoop::Quit, base::Unretained(MessageLoop::current())));
+
+ // Now kick things off
+ MessageLoop::current()->Run();
+
+ EXPECT_EQ(foo->test_count(), 1);
+ EXPECT_EQ(foo->result(), "a");
+}
« no previous file with comments | « base/message_loop_proxy_impl.cc ('k') | base/thread_main_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698