Commit 82c6c6e3 authored by Dan Harrington's avatar Dan Harrington Committed by Commit Bot

Additional test assertions for invalidated callbacks

Change-Id: I46655436935303fae59c1c90e74b7f18d5ac1dd2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1693204Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Commit-Queue: Dan H <harringtond@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675843}
parent 5e65ed7e
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
// //
// Callbacks also support cancellation. A common use is binding the receiver // Callbacks also support cancellation. A common use is binding the receiver
// object as a WeakPtr<T>. If that weak pointer is invalidated, calling Run() // object as a WeakPtr<T>. If that weak pointer is invalidated, calling Run()
// will be a no-op. Note that |is_cancelled()| and |is_null()| are distinct: // will be a no-op. Note that |IsCancelled()| and |is_null()| are distinct:
// simply cancelling a callback will not also make it null. // simply cancelling a callback will not also make it null.
// //
// base::Callback is currently a type alias for base::RepeatingCallback. In the // base::Callback is currently a type alias for base::RepeatingCallback. In the
......
...@@ -165,11 +165,15 @@ TEST_F(CallbackTest, MaybeValidInvalidateWeakPtrsOnSameSequence) { ...@@ -165,11 +165,15 @@ TEST_F(CallbackTest, MaybeValidInvalidateWeakPtrsOnSameSequence) {
RepeatingCallback<void()> cb = RepeatingCallback<void()> cb =
BindRepeating(&ClassWithAMethod::TheMethod, ptr); BindRepeating(&ClassWithAMethod::TheMethod, ptr);
EXPECT_TRUE(cb.MaybeValid()); EXPECT_TRUE(cb.MaybeValid());
EXPECT_FALSE(cb.IsCancelled());
factory.InvalidateWeakPtrs(); factory.InvalidateWeakPtrs();
// MaybeValid() should be false because InvalidateWeakPtrs() was called on // MaybeValid() should be false and IsCancelled() should become true because
// the same thread. // InvalidateWeakPtrs() was called on the same thread.
EXPECT_FALSE(cb.MaybeValid()); EXPECT_FALSE(cb.MaybeValid());
EXPECT_TRUE(cb.IsCancelled());
// is_null() is not affected by the invalidated WeakPtr.
EXPECT_FALSE(cb.is_null());
} }
TEST_F(CallbackTest, MaybeValidInvalidateWeakPtrsOnOtherSequence) { TEST_F(CallbackTest, MaybeValidInvalidateWeakPtrsOnOtherSequence) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment