| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/ios/weak_nsobject.h" | 7 #include "base/ios/weak_nsobject.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/googletest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 TEST(WeakNSObjectTest, WeakNSObject) { | 17 TEST(WeakNSObjectTest, WeakNSObject) { |
| 18 scoped_nsobject<NSObject> p1([[NSObject alloc] init]); | 18 scoped_nsobject<NSObject> p1([[NSObject alloc] init]); |
| 19 WeakNSObject<NSObject> w1(p1); | 19 WeakNSObject<NSObject> w1(p1); |
| 20 EXPECT_TRUE(w1); | 20 EXPECT_TRUE(w1); |
| 21 p1.reset(); | 21 p1.reset(); |
| 22 EXPECT_FALSE(w1); | 22 EXPECT_FALSE(w1); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 FROM_HERE, Bind(&CopyWeakNSObjectAndPost, weak, runner)); | 131 FROM_HERE, Bind(&CopyWeakNSObjectAndPost, weak, runner)); |
| 132 other_thread.Stop(); | 132 other_thread.Stop(); |
| 133 loop.RunUntilIdle(); | 133 loop.RunUntilIdle(); |
| 134 | 134 |
| 135 // Check that TouchWeakData was called and the object touched twice. | 135 // Check that TouchWeakData was called and the object touched twice. |
| 136 EXPECT_EQ(2u, [data length]); | 136 EXPECT_EQ(2u, [data length]); |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace | 139 } // namespace |
| 140 } // namespace base | 140 } // namespace base |
| OLD | NEW |