| Index: base/bind_unittest.cc
|
| diff --git a/base/bind_unittest.cc b/base/bind_unittest.cc
|
| index fe72f281e75bce8f5d9a908e5cff9bd5a993a41e..d12925aafbc38cb3fb27008a5fff64b7a6be5d1a 100644
|
| --- a/base/bind_unittest.cc
|
| +++ b/base/bind_unittest.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include <memory>
|
| #include <utility>
|
| +#include <vector>
|
|
|
| #include "base/callback.h"
|
| #include "base/macros.h"
|
| @@ -784,6 +785,37 @@ TYPED_TEST(BindMoveOnlyTypeTest, UnboundForwarding) {
|
| EXPECT_EQ(1, deletes);
|
| }
|
|
|
| +void VerifyVector(const std::vector<scoped_ptr<int>>& v) {
|
| + ASSERT_EQ(1u, v.size());
|
| + EXPECT_EQ(12345, *v[0]);
|
| +}
|
| +
|
| +std::vector<scoped_ptr<int>> AcceptAndReturnMoveOnlyVector(
|
| + std::vector<scoped_ptr<int>> v) {
|
| + VerifyVector(v);
|
| + return v;
|
| +}
|
| +
|
| +// Test that a vector containing move-only types can be used with Callback.
|
| +TEST_F(BindTest, BindMoveOnlyVector) {
|
| + using MoveOnlyVector = std::vector<scoped_ptr<int>>;
|
| +
|
| + MoveOnlyVector v;
|
| + v.push_back(make_scoped_ptr(new int(12345)));
|
| +
|
| + // Early binding should work:
|
| + base::Callback<MoveOnlyVector()> bound_cb =
|
| + base::Bind(&AcceptAndReturnMoveOnlyVector, Passed(&v));
|
| + MoveOnlyVector intermediate_result = bound_cb.Run();
|
| + VerifyVector(intermediate_result);
|
| +
|
| + // As should passing it as an argument to Run():
|
| + base::Callback<MoveOnlyVector(MoveOnlyVector)> unbound_cb =
|
| + base::Bind(&AcceptAndReturnMoveOnlyVector);
|
| + MoveOnlyVector final_result = unbound_cb.Run(std::move(intermediate_result));
|
| + VerifyVector(final_result);
|
| +}
|
| +
|
| // Argument Copy-constructor usage for non-reference parameters.
|
| // - Bound arguments are only copied once.
|
| // - Forwarded arguments are only copied once.
|
|
|