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

Unified Diff: base/threading/post_task_and_reply_impl_unittest.cc

Issue 2657603004: Clear PostTaskAndReply task on the destination thread (3) (Closed)
Patch Set: reorder delete_flag check. +comment Created 3 years, 9 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/threading/post_task_and_reply_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/post_task_and_reply_impl_unittest.cc
diff --git a/base/threading/post_task_and_reply_impl_unittest.cc b/base/threading/post_task_and_reply_impl_unittest.cc
index 2e8fc44291b0eab156d05bf20268bafb4f1eae83..5385739599f18daa5095e277d6e88fd06ba7da54 100644
--- a/base/threading/post_task_and_reply_impl_unittest.cc
+++ b/base/threading/post_task_and_reply_impl_unittest.cc
@@ -58,14 +58,7 @@ class MockObject {
MockObject() = default;
MOCK_METHOD1(Task, void(scoped_refptr<ObjectToDelete>));
-
- void Reply(bool* delete_flag) {
- // Expect the task's deletion flag to be set before the reply runs.
- EXPECT_TRUE(*delete_flag);
- ReplyMock();
- }
-
- MOCK_METHOD0(ReplyMock, void());
+ MOCK_METHOD0(Reply, void());
private:
DISALLOW_COPY_AND_ASSIGN(MockObject);
@@ -87,25 +80,25 @@ TEST(PostTaskAndReplyImplTest, PostTaskAndReply) {
FROM_HERE,
Bind(&MockObject::Task, Unretained(&mock_object),
make_scoped_refptr(new ObjectToDelete(&delete_flag))),
- Bind(&MockObject::Reply, Unretained(&mock_object),
- Unretained(&delete_flag))));
-
- // Expect no reply in |reply_runner|.
- EXPECT_FALSE(reply_runner->HasPendingTask());
+ Bind(&MockObject::Reply, Unretained(&mock_object))));
// Expect the task to be posted to |post_runner|.
EXPECT_TRUE(post_runner->HasPendingTask());
+ EXPECT_FALSE(reply_runner->HasPendingTask());
+ EXPECT_FALSE(delete_flag);
+
EXPECT_CALL(mock_object, Task(_));
post_runner->RunUntilIdle();
testing::Mock::VerifyAndClear(&mock_object);
- // Expect the task's argument not to have been deleted yet.
- EXPECT_FALSE(delete_flag);
+ // |task| should have been deleted right after being run.
+ EXPECT_TRUE(delete_flag);
// Expect the reply to be posted to |reply_runner|.
EXPECT_FALSE(post_runner->HasPendingTask());
EXPECT_TRUE(reply_runner->HasPendingTask());
- EXPECT_CALL(mock_object, ReplyMock());
+
+ EXPECT_CALL(mock_object, Reply());
reply_runner->RunUntilIdle();
testing::Mock::VerifyAndClear(&mock_object);
EXPECT_TRUE(delete_flag);
« no previous file with comments | « base/threading/post_task_and_reply_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698