Chromium Code Reviews| Index: base/bind_unittest.cc |
| diff --git a/base/bind_unittest.cc b/base/bind_unittest.cc |
| index 5ca67e9630abaaf4cf4b4df7426a83fca82a19ac..32ccc64dc5c35303c642b2b24f3b1b97abf082a9 100644 |
| --- a/base/bind_unittest.cc |
| +++ b/base/bind_unittest.cc |
| @@ -211,6 +211,11 @@ int FunctionWithWeakFirstParam(WeakPtr<NoRef> o, int n) { |
| return n; |
| } |
| +int FunctionWithScopedRefptrFirstParam(const scoped_refptr<HasRef>& o, int n) { |
| + return n; |
| +} |
| + |
|
awong
2013/06/21 19:46:56
remove extra newline.
|
| + |
| void TakesACallback(const Closure& callback) { |
| callback.Run(); |
| } |
| @@ -663,6 +668,21 @@ TEST_F(BindTest, ConstRef) { |
| EXPECT_EQ(0, assigns); |
| } |
| +TEST_F(BindTest, ScopedRefptr) { |
| + // BUG: The scoped_refptr should cause the only AddRef()/Release() pair. But |
| + // due to a bug in base::Bind(), there's an extra call when invoking the |
| + // callback. |
| + // https://code.google.com/p/chromium/issues/detail?id=251937 |
| + EXPECT_CALL(has_ref_, AddRef()).Times(2); |
| + EXPECT_CALL(has_ref_, Release()).Times(2); |
| + |
| + const scoped_refptr<StrictMock<HasRef> > refptr(&has_ref_); |
| + |
| + Callback<int(void)> scoped_refptr_const_ref_cb = |
| + Bind(&FunctionWithScopedRefptrFirstParam, base::ConstRef(refptr), 1); |
| + EXPECT_EQ(1, scoped_refptr_const_ref_cb.Run()); |
| +} |
| + |
| // Test Owned() support. |
| TEST_F(BindTest, Owned) { |
| int deletes = 0; |