| OLD | NEW |
| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 #include <objc/runtime.h> | 6 #include <objc/runtime.h> |
| 7 | 7 |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #import "chrome/browser/ui/cocoa/custom_frame_view.h" | 10 #import "chrome/browser/ui/cocoa/custom_frame_view.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 base::mac::IsOSMountainLionOrLater() ? @"NSThemeFrame" | 22 base::mac::IsOSMountainLionOrLater() ? @"NSThemeFrame" |
| 23 : @"NSGrayFrame"); | 23 : @"NSGrayFrame"); |
| 24 view_.reset([[customFrameClass alloc] initWithFrame:frame]); | 24 view_.reset([[customFrameClass alloc] initWithFrame:frame]); |
| 25 } | 25 } |
| 26 | 26 |
| 27 base::scoped_nsobject<NSView> view_; | 27 base::scoped_nsobject<NSView> view_; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 // Test to make sure our class modifications were successful. | 30 // Test to make sure our class modifications were successful. |
| 31 TEST_F(CustomFrameViewTest, SuccessfulClassModifications) { | 31 TEST_F(CustomFrameViewTest, SuccessfulClassModifications) { |
| 32 // In Yosemite, the fullscreen button replaces the zoom button. We no longer |
| 33 // need to swizzle out this AppKit private method. |
| 34 if (!base::mac::IsOSMavericksOrEarlier()) |
| 35 return; |
| 36 |
| 32 unsigned int count; | 37 unsigned int count; |
| 33 BOOL foundDrawRectOriginal = NO; | 38 BOOL foundSwizzledMethod = NO; |
| 34 | 39 |
| 35 Method* methods = class_copyMethodList([view_ class], &count); | 40 Method* methods = class_copyMethodList([view_ class], &count); |
| 36 for (unsigned int i = 0; i < count; ++i) { | 41 for (unsigned int i = 0; i < count; ++i) { |
| 37 SEL selector = method_getName(methods[i]); | 42 SEL selector = method_getName(methods[i]); |
| 38 if (selector == @selector(drawRectOriginal:)) { | 43 if (selector == @selector(_fullScreenButtonOriginOriginal)) |
| 39 foundDrawRectOriginal = YES; | 44 foundSwizzledMethod = YES; |
| 40 } | |
| 41 } | 45 } |
| 42 EXPECT_TRUE(foundDrawRectOriginal); | 46 EXPECT_TRUE(foundSwizzledMethod); |
| 43 free(methods); | 47 free(methods); |
| 44 } | 48 } |
| OLD | NEW |