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

Side by Side Diff: chrome/common/mac/objc_zombie_unittest.mm

Issue 8368018: Convert chrome/common non-debug logs to debug logs. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/mac/objc_zombie.mm ('k') | chrome/common/metrics_helpers.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #include <dlfcn.h> 6 #include <dlfcn.h>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #import "base/memory/scoped_nsobject.h" 9 #import "base/memory/scoped_nsobject.h"
10 #import "chrome/common/mac/objc_zombie.h" 10 #import "chrome/common/mac/objc_zombie.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 ObjcEvilDoers::ZombieDisable(); 100 ObjcEvilDoers::ZombieDisable();
101 EXPECT_EQ(1u, [anObject retainCount]); 101 EXPECT_EQ(1u, [anObject retainCount]);
102 } 102 }
103 103
104 // Verify that the associated objects are released when the object is 104 // Verify that the associated objects are released when the object is
105 // released. 105 // released.
106 // NOTE(shess): To test the negative, hardcode |g_objectDestruct| to 106 // NOTE(shess): To test the negative, hardcode |g_objectDestruct| to
107 // the 10.5 version in |ZombieInit()|, and run this test on 10.6. 107 // the 10.5 version in |ZombieInit()|, and run this test on 10.6.
108 TEST(ObjcZombieTest, AssociatedObjectsReleased) { 108 TEST(ObjcZombieTest, AssociatedObjectsReleased) {
109 if (![ZombieAssociatedObjectTest supportsAssociatedObjects]) { 109 if (![ZombieAssociatedObjectTest supportsAssociatedObjects]) {
110 LOG(ERROR) 110 DLOG(ERROR)
111 << "ObjcZombieTest.AssociatedObjectsReleased not supported on 10.5"; 111 << "ObjcZombieTest.AssociatedObjectsReleased not supported on 10.5";
112 return; 112 return;
113 } 113 }
114 114
115 scoped_nsobject<id> anObject([[NSObject alloc] init]); 115 scoped_nsobject<id> anObject([[NSObject alloc] init]);
116 EXPECT_EQ(1u, [anObject retainCount]); 116 EXPECT_EQ(1u, [anObject retainCount]);
117 117
118 ASSERT_TRUE(ObjcEvilDoers::ZombieEnable(YES, 100)); 118 ASSERT_TRUE(ObjcEvilDoers::ZombieEnable(YES, 100));
119 119
120 scoped_nsobject<ZombieAssociatedObjectTest> soonInfected( 120 scoped_nsobject<ZombieAssociatedObjectTest> soonInfected(
121 [[ZombieAssociatedObjectTest alloc] initWithAssociatedObject:anObject]); 121 [[ZombieAssociatedObjectTest alloc] initWithAssociatedObject:anObject]);
122 EXPECT_EQ(2u, [anObject retainCount]); 122 EXPECT_EQ(2u, [anObject retainCount]);
123 123
124 // When |soonInfected| becomes a zombie, the associated object 124 // When |soonInfected| becomes a zombie, the associated object
125 // should be released. 125 // should be released.
126 soonInfected.reset(); 126 soonInfected.reset();
127 EXPECT_EQ(1u, [anObject retainCount]); 127 EXPECT_EQ(1u, [anObject retainCount]);
128 128
129 // The local reference should remain (associated objects not re-released). 129 // The local reference should remain (associated objects not re-released).
130 ObjcEvilDoers::ZombieDisable(); 130 ObjcEvilDoers::ZombieDisable();
131 EXPECT_EQ(1u, [anObject retainCount]); 131 EXPECT_EQ(1u, [anObject retainCount]);
132 } 132 }
133 133
134 } // namespace 134 } // namespace
OLDNEW
« no previous file with comments | « chrome/common/mac/objc_zombie.mm ('k') | chrome/common/metrics_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698