Index: base/callback_unittest.cc |
diff --git a/base/callback_unittest.cc b/base/callback_unittest.cc |
index 1c3db04c10eb5038066e2651a7700695a411a703..d3ea2682afb4bf279c2a7d9c5342f3fa94d6c2ea 100644 |
--- a/base/callback_unittest.cc |
+++ b/base/callback_unittest.cc |
@@ -2,7 +2,9 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "base/bind.h" |
#include "base/callback.h" |
+#include "base/callback_helpers.h" |
#include "base/callback_internal.h" |
#include "base/memory/scoped_ptr.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -11,21 +13,12 @@ namespace base { |
namespace { |
-class HelperObject { |
- public: |
- HelperObject() : next_number_(0) { } |
- int GetNextNumber() { return ++next_number_; } |
- void GetNextNumberArg(int* number) { *number = GetNextNumber(); } |
- |
- private: |
- int next_number_; |
-}; |
- |
struct FakeInvoker { |
typedef void(RunType)(internal::BindStateBase*); |
static void Run(internal::BindStateBase*) { |
} |
}; |
+ |
} // namespace |
namespace internal { |
@@ -130,5 +123,28 @@ TEST_F(CallbackTest, Reset) { |
EXPECT_TRUE(callback_a_.Equals(null_callback_)); |
} |
+struct TestForReentrancy { |
+ TestForReentrancy() |
+ : cb_already_run(false), |
+ cb(base::Bind(&TestForReentrancy::AssertCBIsNull, |
akalin
2012/03/23 18:42:07
no base::
Ami GONE FROM CHROMIUM
2012/03/24 17:43:35
Done.
|
+ base::Unretained(this))) { |
akalin
2012/03/23 18:42:07
no base::
Ami GONE FROM CHROMIUM
2012/03/24 17:43:35
Done.
|
+ } |
+ void AssertCBIsNull() { |
+ ASSERT_TRUE(cb.is_null()); |
+ cb_already_run = true; |
+ } |
+ bool cb_already_run; |
+ Closure cb; |
+}; |
+ |
+TEST_F(CallbackTest, ResetAndReturn) { |
+ TestForReentrancy tfr; |
+ ASSERT_FALSE(tfr.cb.is_null()); |
+ ASSERT_FALSE(tfr.cb_already_run); |
+ base::ResetAndReturn(&tfr.cb).Run(); |
akalin
2012/03/23 18:42:07
no base::
Ami GONE FROM CHROMIUM
2012/03/24 17:43:35
Done.
|
+ ASSERT_TRUE(tfr.cb.is_null()); |
+ ASSERT_TRUE(tfr.cb_already_run); |
+} |
+ |
} // namespace |
} // namespace base |