Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: base/mac/scoped_nsobject_unittest.mm

Issue 1855483004: [iOS/OS X] Allow base::scoped_nsobject<> to be used when ARC is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing copy constructor from scoped_nsobject<subclass> to scoped_nsobject<class> Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/mac/scoped_nsobject.mm ('k') | base/mac/scoped_nsobject_unittest_arc.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/mac/scoped_nsautorelease_pool.h" 7 #include "base/mac/scoped_nsautorelease_pool.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 // See scoped_nsobject_unittest_arc.mm for why this is necessary. Remove once
12 // gyp support is dropped.
13 void ScopedNSObjectUnittestArcLinkerWorkaround();
14
11 namespace { 15 namespace {
12 16
17 TEST(ScopedNSObjectTest, EnableARCTests) {
18 ScopedNSObjectUnittestArcLinkerWorkaround();
19 }
20
13 TEST(ScopedNSObjectTest, ScopedNSObject) { 21 TEST(ScopedNSObjectTest, ScopedNSObject) {
14 base::scoped_nsobject<NSObject> p1([[NSObject alloc] init]); 22 base::scoped_nsobject<NSObject> p1([[NSObject alloc] init]);
15 ASSERT_TRUE(p1.get()); 23 ASSERT_TRUE(p1.get());
16 ASSERT_EQ(1u, [p1 retainCount]); 24 ASSERT_EQ(1u, [p1 retainCount]);
17 base::scoped_nsobject<NSObject> p2(p1); 25 base::scoped_nsobject<NSObject> p2(p1);
18 ASSERT_EQ(p1.get(), p2.get()); 26 ASSERT_EQ(p1.get(), p2.get());
19 ASSERT_EQ(2u, [p1 retainCount]); 27 ASSERT_EQ(2u, [p1 retainCount]);
20 p2.reset(); 28 p2.reset();
21 ASSERT_EQ(nil, p2.get()); 29 ASSERT_EQ(nil, p2.get());
22 ASSERT_EQ(1u, [p1 retainCount]); 30 ASSERT_EQ(1u, [p1 retainCount]);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 base::scoped_nsobject<id> p2([[NSObject alloc] init]); 92 base::scoped_nsobject<id> p2([[NSObject alloc] init]);
85 ASSERT_TRUE(o1 != p2); 93 ASSERT_TRUE(o1 != p2);
86 ASSERT_FALSE(o1 == p2); 94 ASSERT_FALSE(o1 == p2);
87 id o2 = p2.get(); 95 id o2 = p2.get();
88 swap(p1, p2); 96 swap(p1, p2);
89 ASSERT_EQ(o2, p1.get()); 97 ASSERT_EQ(o2, p1.get());
90 ASSERT_EQ(o1, p2.get()); 98 ASSERT_EQ(o1, p2.get());
91 } 99 }
92 100
93 } // namespace 101 } // namespace
OLDNEW
« no previous file with comments | « base/mac/scoped_nsobject.mm ('k') | base/mac/scoped_nsobject_unittest_arc.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698