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

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

Issue 2923593003: Get base_unittests building with the macOS 10.13.0 SDK (Closed)
Patch Set: Created 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/mac/scoped_objc_class_swizzler.h" 5 #import "base/mac/scoped_objc_class_swizzler.h"
6 6
7 #import "base/mac/scoped_nsobject.h" 7 #import "base/mac/scoped_nsobject.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 @interface ObjCClassSwizzlerTestOne : NSObject 10 @interface ObjCClassSwizzlerTestOne : NSObject
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 { 108 {
109 base::mac::ScopedObjCClassSwizzler swizzler( 109 base::mac::ScopedObjCClassSwizzler swizzler(
110 [ObjCClassSwizzlerTestOne class], 110 [ObjCClassSwizzlerTestOne class],
111 [ObjCClassSwizzlerTestTwo class], 111 [ObjCClassSwizzlerTestTwo class],
112 @selector(function)); 112 @selector(function));
113 EXPECT_EQ(20, [ObjCClassSwizzlerTestOne function]); 113 EXPECT_EQ(20, [ObjCClassSwizzlerTestOne function]);
114 EXPECT_EQ(10, [ObjCClassSwizzlerTestTwo function]); 114 EXPECT_EQ(10, [ObjCClassSwizzlerTestTwo function]);
115 115
116 IMP original = swizzler.GetOriginalImplementation(); 116 IMP original = swizzler.GetOriginalImplementation();
117 id expected_result = reinterpret_cast<id>(10); 117 id expected_result = reinterpret_cast<id>(10);
118 EXPECT_EQ(expected_result, original(nil, @selector(function))); 118 EXPECT_EQ(expected_result,
119 original([ObjCClassSwizzlerTestOne class], @selector(function)));
119 } 120 }
120 121
121 EXPECT_EQ(10, [ObjCClassSwizzlerTestOne function]); 122 EXPECT_EQ(10, [ObjCClassSwizzlerTestOne function]);
122 EXPECT_EQ(20, [ObjCClassSwizzlerTestTwo function]); 123 EXPECT_EQ(20, [ObjCClassSwizzlerTestTwo function]);
123 } 124 }
124 125
125 TEST(ObjCClassSwizzlerTest, SwizzleViaCategory) { 126 TEST(ObjCClassSwizzlerTest, SwizzleViaCategory) {
126 base::scoped_nsobject<ObjCClassSwizzlerTestOne> object_one( 127 base::scoped_nsobject<ObjCClassSwizzlerTestOne> object_one(
127 [[ObjCClassSwizzlerTestOne alloc] init]); 128 [[ObjCClassSwizzlerTestOne alloc] init]);
128 EXPECT_EQ(3, [object_one method]); 129 EXPECT_EQ(3, [object_one method]);
(...skipping 28 matching lines...) Expand all
157 IMP original = swizzler.GetOriginalImplementation(); 158 IMP original = swizzler.GetOriginalImplementation();
158 id expected_result = reinterpret_cast<id>(3); 159 id expected_result = reinterpret_cast<id>(3);
159 EXPECT_EQ(expected_result, original(child, @selector(method))); 160 EXPECT_EQ(expected_result, original(child, @selector(method)));
160 } 161 }
161 162
162 EXPECT_EQ(3, [child method]); 163 EXPECT_EQ(3, [child method]);
163 } 164 }
164 165
165 } // namespace mac 166 } // namespace mac
166 } // namespace base 167 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698