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

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

Issue 1551943002: Rewrite most of the scopers in //base/mac to use ScopedTypeRef or ScopedGeneric. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix iOS Created 4 years, 11 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
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
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 ASSERT_EQ(3u, [p6 retainCount]); 45 ASSERT_EQ(3u, [p6 retainCount]);
46 { 46 {
47 base::mac::ScopedNSAutoreleasePool pool; 47 base::mac::ScopedNSAutoreleasePool pool;
48 p6.autorelease(); 48 p6.autorelease();
49 ASSERT_EQ(nil, p6.get()); 49 ASSERT_EQ(nil, p6.get());
50 ASSERT_EQ(3u, [p1 retainCount]); 50 ASSERT_EQ(3u, [p1 retainCount]);
51 } 51 }
52 ASSERT_EQ(2u, [p1 retainCount]); 52 ASSERT_EQ(2u, [p1 retainCount]);
53 } 53 }
54 54
55 #if 0
Nico 2016/01/05 16:18:30 ?
Robert Sesek 2016/01/05 16:26:10 It's for testing a static_assert.
Nico 2016/01/05 16:38:39 This should have a comment saying so, else it's be
Robert Sesek 2016/01/05 17:35:03 Added a comment in https://codereview.chromium.org
56 TEST(ScopedNSObjectTest, FailToCreateScopedNSObjectAutoreleasePool) {
57 base::scoped_nsobject<NSAutoreleasePool> pool;
58 }
59 #endif
60
55 TEST(ScopedNSObjectTest, ScopedNSObjectInContainer) { 61 TEST(ScopedNSObjectTest, ScopedNSObjectInContainer) {
56 base::scoped_nsobject<id> p([[NSObject alloc] init]); 62 base::scoped_nsobject<id> p([[NSObject alloc] init]);
57 ASSERT_TRUE(p.get()); 63 ASSERT_TRUE(p.get());
58 ASSERT_EQ(1u, [p retainCount]); 64 ASSERT_EQ(1u, [p retainCount]);
59 { 65 {
60 std::vector<base::scoped_nsobject<id>> objects; 66 std::vector<base::scoped_nsobject<id>> objects;
61 objects.push_back(p); 67 objects.push_back(p);
62 ASSERT_EQ(2u, [p retainCount]); 68 ASSERT_EQ(2u, [p retainCount]);
63 ASSERT_EQ(p.get(), objects[0].get()); 69 ASSERT_EQ(p.get(), objects[0].get());
64 objects.push_back(base::scoped_nsobject<id>([[NSObject alloc] init])); 70 objects.push_back(base::scoped_nsobject<id>([[NSObject alloc] init]));
(...skipping 11 matching lines...) Expand all
76 base::scoped_nsobject<id> p2([[NSObject alloc] init]); 82 base::scoped_nsobject<id> p2([[NSObject alloc] init]);
77 ASSERT_TRUE(o1 != p2); 83 ASSERT_TRUE(o1 != p2);
78 ASSERT_FALSE(o1 == p2); 84 ASSERT_FALSE(o1 == p2);
79 id o2 = p2.get(); 85 id o2 = p2.get();
80 swap(p1, p2); 86 swap(p1, p2);
81 ASSERT_EQ(o2, p1.get()); 87 ASSERT_EQ(o2, p1.get());
82 ASSERT_EQ(o1, p2.get()); 88 ASSERT_EQ(o1, p2.get());
83 } 89 }
84 90
85 } // namespace 91 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698