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

Unified Diff: chrome/common/mac/objc_method_swizzle_unittest.mm

Issue 345243007: Add ScopedObjCClassSwizzler in base/mac, absorbs objc_method_swizzle and ScopedClassSwizzler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Inlude in shiny new gn base_unittests target Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/mac/objc_method_swizzle.mm ('k') | chrome/common/mac/objc_zombie.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/mac/objc_method_swizzle_unittest.mm
diff --git a/chrome/common/mac/objc_method_swizzle_unittest.mm b/chrome/common/mac/objc_method_swizzle_unittest.mm
deleted file mode 100644
index 3053f3b711d88606e22bcfca143775e4e87a7833..0000000000000000000000000000000000000000
--- a/chrome/common/mac/objc_method_swizzle_unittest.mm
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "chrome/common/mac/objc_method_swizzle.h"
-
-#include "base/mac/scoped_nsobject.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-@interface ObjcMethodSwizzleTest : NSObject
-- (id)self;
-
-- (NSInteger)one;
-- (NSInteger)two;
-@end
-
-@implementation ObjcMethodSwizzleTest : NSObject
-- (id)self {
- return [super self];
-}
-
-- (NSInteger)one {
- return 1;
-}
-- (NSInteger)two {
- return 2;
-}
-@end
-
-@interface ObjcMethodSwizzleTest (ObjcMethodSwizzleTestCategory)
-- (NSUInteger)hash;
-@end
-
-@implementation ObjcMethodSwizzleTest (ObjcMethodSwizzleTestCategory)
-- (NSUInteger)hash {
- return [super hash];
-}
-@end
-
-namespace ObjcEvilDoers {
-
-TEST(ObjcMethodSwizzleTest, GetImplementedInstanceMethod) {
- EXPECT_EQ(class_getInstanceMethod([NSObject class], @selector(dealloc)),
- GetImplementedInstanceMethod([NSObject class], @selector(dealloc)));
- EXPECT_EQ(class_getInstanceMethod([NSObject class], @selector(self)),
- GetImplementedInstanceMethod([NSObject class], @selector(self)));
- EXPECT_EQ(class_getInstanceMethod([NSObject class], @selector(hash)),
- GetImplementedInstanceMethod([NSObject class], @selector(hash)));
-
- Class testClass = [ObjcMethodSwizzleTest class];
- EXPECT_EQ(class_getInstanceMethod(testClass, @selector(self)),
- GetImplementedInstanceMethod(testClass, @selector(self)));
- EXPECT_NE(class_getInstanceMethod([NSObject class], @selector(self)),
- class_getInstanceMethod(testClass, @selector(self)));
-
- EXPECT_TRUE(class_getInstanceMethod(testClass, @selector(dealloc)));
- EXPECT_FALSE(GetImplementedInstanceMethod(testClass, @selector(dealloc)));
-}
-
-TEST(ObjcMethodSwizzleTest, SwizzleImplementedInstanceMethods) {
- base::scoped_nsobject<ObjcMethodSwizzleTest> object(
- [[ObjcMethodSwizzleTest alloc] init]);
- EXPECT_EQ([object one], 1);
- EXPECT_EQ([object two], 2);
-
- Class testClass = [object class];
- SwizzleImplementedInstanceMethods(testClass, @selector(one), @selector(two));
- EXPECT_EQ([object one], 2);
- EXPECT_EQ([object two], 1);
-
- SwizzleImplementedInstanceMethods(testClass, @selector(one), @selector(two));
- EXPECT_EQ([object one], 1);
- EXPECT_EQ([object two], 2);
-}
-
-} // namespace ObjcEvilDoers
« no previous file with comments | « chrome/common/mac/objc_method_swizzle.mm ('k') | chrome/common/mac/objc_zombie.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698