Index: base/memory/weak_ptr_unittest.cc |
diff --git a/base/memory/weak_ptr_unittest.cc b/base/memory/weak_ptr_unittest.cc |
index be3b6dbf6d1e6104435bc8a29e1cbda42621e946..799fab0c93a7da09ab1f6a60caf4c200e0165ae2 100644 |
--- a/base/memory/weak_ptr_unittest.cc |
+++ b/base/memory/weak_ptr_unittest.cc |
@@ -336,21 +336,6 @@ TEST(WeakPtrTest, MoveOwnershipImplicitly) { |
background.DeleteArrow(arrow); |
} |
-TEST(WeakPtrTest, MoveOwnershipExplicitlyObjectNotReferenced) { |
- // Case 1: The target is not bound to any thread yet. So calling |
- // DetachFromThread() is a no-op. |
- Target target; |
- target.DetachFromThreadHack(); |
- |
- // Case 2: The target is bound to main thread but no WeakPtr is pointing to |
- // it. In this case, it will be re-bound to any thread trying to get a |
- // WeakPtr pointing to it. So detach function call is again no-op. |
- { |
- WeakPtr<Target> weak_ptr = target.AsWeakPtr(); |
- } |
- target.DetachFromThreadHack(); |
-} |
- |
TEST(WeakPtrTest, MoveOwnershipExplicitly) { |
BackgroundThread background; |
background.Start(); |
@@ -358,12 +343,15 @@ TEST(WeakPtrTest, MoveOwnershipExplicitly) { |
Arrow* arrow; |
{ |
Target target; |
- // Background thread creates WeakPtr(and implicitly owns the object). |
+ // Background thread creates WeakPtr. |
background.CreateArrowFromTarget(&arrow, &target); |
+ |
+ // Bind to background thread. |
EXPECT_EQ(&target, background.DeRef(arrow)); |
- // Detach from background thread. |
- target.DetachFromThreadHack(); |
+ // Invalidating the only weak pointer unbinds it from the background thread. |
+ arrow->target.reset(); |
Wez
2013/07/31 22:46:43
This should crash, since you're invalidating from
|
+ arrow->target = target.AsWeakPtr(); |
// Re-bind to main thread. |
EXPECT_EQ(&target, arrow->target.get()); |