| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/mac/scoped_nsautorelease_pool.h" | 8 #include "base/mac/scoped_nsautorelease_pool.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/googletest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 TEST(ScopedNSObjectTest, ScopedNSObject) { | 14 TEST(ScopedNSObjectTest, ScopedNSObject) { |
| 15 base::scoped_nsobject<NSObject> p1([[NSObject alloc] init]); | 15 base::scoped_nsobject<NSObject> p1([[NSObject alloc] init]); |
| 16 ASSERT_TRUE(p1.get()); | 16 ASSERT_TRUE(p1.get()); |
| 17 ASSERT_EQ(1u, [p1 retainCount]); | 17 ASSERT_EQ(1u, [p1 retainCount]); |
| 18 base::scoped_nsobject<NSObject> p2(p1); | 18 base::scoped_nsobject<NSObject> p2(p1); |
| 19 ASSERT_EQ(p1.get(), p2.get()); | 19 ASSERT_EQ(p1.get(), p2.get()); |
| 20 ASSERT_EQ(2u, [p1 retainCount]); | 20 ASSERT_EQ(2u, [p1 retainCount]); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 base::scoped_nsobject<id> p2([[NSObject alloc] init]); | 77 base::scoped_nsobject<id> p2([[NSObject alloc] init]); |
| 78 ASSERT_TRUE(o1 != p2); | 78 ASSERT_TRUE(o1 != p2); |
| 79 ASSERT_FALSE(o1 == p2); | 79 ASSERT_FALSE(o1 == p2); |
| 80 id o2 = p2.get(); | 80 id o2 = p2.get(); |
| 81 swap(p1, p2); | 81 swap(p1, p2); |
| 82 ASSERT_EQ(o2, p1.get()); | 82 ASSERT_EQ(o2, p1.get()); |
| 83 ASSERT_EQ(o1, p2.get()); | 83 ASSERT_EQ(o1, p2.get()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // namespace | 86 } // namespace |
| OLD | NEW |