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

Unified Diff: base/message_loop_proxy_impl_unittest.cc

Issue 7316015: Support Closure in ALL the loops! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 9 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 side-by-side diff with in-line comments
Download patch
Index: base/message_loop_proxy_impl_unittest.cc
diff --git a/base/message_loop_proxy_impl_unittest.cc b/base/message_loop_proxy_impl_unittest.cc
index 558cd93278b1aa9d078fdb2582d6056423a797ab..fd5f133cdaf80928077aa6eea7fe15b7e1889f57 100644
--- a/base/message_loop_proxy_impl_unittest.cc
+++ b/base/message_loop_proxy_impl_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy_impl.h"
willchan no longer on Chromium 2011/07/08 12:04:21 This header should be first.
awong 2011/07/08 18:36:51 I don't think this rule applies to unittests does
willchan no longer on Chromium 2011/07/10 16:47:33 Common misconception for old fartz who first read
awong 2011/07/14 23:03:30 Done. (And I'm not old!)
willchan no longer on Chromium 2011/07/19 12:18:26 In Google years you are pretty old now :)
@@ -47,6 +48,10 @@ class MessageLoopProxyImplTest : public testing::Test {
test->Quit();
}
+ static void AssertNotRun() {
+ FAIL() << "Callback Should not get executed.";
+ }
+
class DummyTask : public Task {
public:
explicit DummyTask(bool* deleted) : deleted_(deleted) { }
@@ -83,7 +88,7 @@ class MessageLoopProxyImplTest : public testing::Test {
};
-TEST_F(MessageLoopProxyImplTest, PostTask) {
+TEST_F(MessageLoopProxyImplTest, LegacyPostTask) {
EXPECT_TRUE(file_thread_->message_loop_proxy()->PostTask(
FROM_HERE, NewRunnableFunction(&BasicFunction, this)));
MessageLoop::current()->Run();
@@ -101,7 +106,7 @@ TEST_F(MessageLoopProxyImplTest, Delete) {
MessageLoop::current()->Run();
}
-TEST_F(MessageLoopProxyImplTest, PostTaskAfterThreadExits) {
+TEST_F(MessageLoopProxyImplTest, LegacyPostTaskAfterThreadExits) {
scoped_ptr<base::Thread> test_thread(
new base::Thread("MessageLoopProxyImplTest_Dummy"));
test_thread->Start();
@@ -116,7 +121,7 @@ TEST_F(MessageLoopProxyImplTest, PostTaskAfterThreadExits) {
EXPECT_TRUE(deleted);
}
-TEST_F(MessageLoopProxyImplTest, PostTaskAfterThreadIsDeleted) {
+TEST_F(MessageLoopProxyImplTest, LegacyPostTaskAfterThreadIsDeleted) {
scoped_refptr<base::MessageLoopProxy> message_loop_proxy;
{
scoped_ptr<base::Thread> test_thread(
@@ -130,3 +135,37 @@ TEST_F(MessageLoopProxyImplTest, PostTaskAfterThreadIsDeleted) {
EXPECT_TRUE(deleted);
}
+TEST_F(MessageLoopProxyImplTest, PostTask) {
+ EXPECT_TRUE(file_thread_->message_loop_proxy()->PostTask(
+ FROM_HERE, base::Bind(&MessageLoopProxyImplTest::BasicFunction,
+ base::Unretained(this))));
+ MessageLoop::current()->Run();
+}
+
+TEST_F(MessageLoopProxyImplTest, PostTaskAfterThreadExits) {
+ scoped_ptr<base::Thread> test_thread(
+ new base::Thread("MessageLoopProxyImplTest_Dummy"));
+ test_thread->Start();
+ scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
+ test_thread->message_loop_proxy();
+ test_thread->Stop();
+
+ bool ret = message_loop_proxy->PostTask(
+ FROM_HERE,
+ base::Bind(&MessageLoopProxyImplTest::AssertNotRun));
+ EXPECT_FALSE(ret);
+}
+
+TEST_F(MessageLoopProxyImplTest, PostTaskAfterThreadIsDeleted) {
+ scoped_refptr<base::MessageLoopProxy> message_loop_proxy;
+ {
+ scoped_ptr<base::Thread> test_thread(
+ new base::Thread("MessageLoopProxyImplTest_Dummy"));
+ test_thread->Start();
+ message_loop_proxy = test_thread->message_loop_proxy();
+ }
+ bool ret = message_loop_proxy->PostTask(
+ FROM_HERE,
+ base::Bind(&MessageLoopProxyImplTest::AssertNotRun));
+ EXPECT_FALSE(ret);
+}

Powered by Google App Engine
This is Rietveld 408576698