OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/task_runner_util.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 namespace base { |
| 12 |
| 13 namespace { |
| 14 |
| 15 int ReturnFourtyTwo() { |
| 16 return 42; |
| 17 } |
| 18 |
| 19 void StoreValue(int* destination, int value) { |
| 20 *destination = value; |
| 21 } |
| 22 |
| 23 } // namespace |
| 24 |
| 25 TEST(TaskRunnerHelpersTest, PostAndReplyWithStatus) { |
| 26 MessageLoop message_loop; |
| 27 int result = 0; |
| 28 |
| 29 PostTaskAndReplyWithResult( |
| 30 message_loop.message_loop_proxy(), |
| 31 FROM_HERE, |
| 32 Bind(&ReturnFourtyTwo), |
| 33 Bind(&StoreValue, &result)); |
| 34 |
| 35 message_loop.RunAllPending(); |
| 36 |
| 37 EXPECT_EQ(42, result); |
| 38 } |
| 39 |
| 40 } // namespace base |
OLD | NEW |