| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/threading/post_task_and_reply_impl.h" | 5 #include "base/threading/post_task_and_reply_impl.h" |
| 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/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/test/test_simple_task_runner.h" | 11 #include "base/test/test_simple_task_runner.h" |
| 12 #include "base/threading/sequenced_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 using ::testing::_; | 16 using ::testing::_; |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 namespace internal { | 19 namespace internal { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 DISALLOW_COPY_AND_ASSIGN(MockObject); | 69 DISALLOW_COPY_AND_ASSIGN(MockObject); |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 } // namespace | 72 } // namespace |
| 73 | 73 |
| 74 TEST(PostTaskAndReplyImplTest, PostTaskAndReply) { | 74 TEST(PostTaskAndReplyImplTest, PostTaskAndReply) { |
| 75 scoped_refptr<TestSimpleTaskRunner> post_runner(new TestSimpleTaskRunner); | 75 scoped_refptr<TestSimpleTaskRunner> post_runner(new TestSimpleTaskRunner); |
| 76 scoped_refptr<TestSimpleTaskRunner> reply_runner(new TestSimpleTaskRunner); | 76 scoped_refptr<TestSimpleTaskRunner> reply_runner(new TestSimpleTaskRunner); |
| 77 SequencedTaskRunnerHandle sequenced_task_runner_handle(reply_runner); | 77 ThreadTaskRunnerHandle task_runner_handle(reply_runner); |
| 78 | 78 |
| 79 testing::StrictMock<MockObject> mock_object; | 79 testing::StrictMock<MockObject> mock_object; |
| 80 bool delete_flag = false; | 80 bool delete_flag = false; |
| 81 | 81 |
| 82 EXPECT_TRUE( | 82 EXPECT_TRUE( |
| 83 PostTaskAndReplyTaskRunner(post_runner.get()) | 83 PostTaskAndReplyTaskRunner(post_runner.get()) |
| 84 .PostTaskAndReply( | 84 .PostTaskAndReply( |
| 85 FROM_HERE, | 85 FROM_HERE, |
| 86 Bind(&MockObject::Task, Unretained(&mock_object), | 86 Bind(&MockObject::Task, Unretained(&mock_object), |
| 87 make_scoped_refptr(new ObjectToDelete(&delete_flag))), | 87 make_scoped_refptr(new ObjectToDelete(&delete_flag))), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 108 testing::Mock::VerifyAndClear(&mock_object); | 108 testing::Mock::VerifyAndClear(&mock_object); |
| 109 EXPECT_TRUE(delete_flag); | 109 EXPECT_TRUE(delete_flag); |
| 110 | 110 |
| 111 // Expect no pending task in |post_runner| and |reply_runner|. | 111 // Expect no pending task in |post_runner| and |reply_runner|. |
| 112 EXPECT_FALSE(post_runner->HasPendingTask()); | 112 EXPECT_FALSE(post_runner->HasPendingTask()); |
| 113 EXPECT_FALSE(reply_runner->HasPendingTask()); | 113 EXPECT_FALSE(reply_runner->HasPendingTask()); |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace internal | 116 } // namespace internal |
| 117 } // namespace base | 117 } // namespace base |
| OLD | NEW |