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
3 // found in the LICENSE file.
5 #import <Cocoa/Cocoa.h>
6 #include <objc/runtime.h>
8 #include "base/mac/mac_util.h"
9 #include "base/mac/scoped_nsobject.h"
10 #import "chrome/browser/ui/cocoa/custom_frame_view.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/platform_test.h"
14 class CustomFrameViewTest : public PlatformTest {
16 CustomFrameViewTest() {
17 NSRect frame = NSMakeRect(0, 0, 50, 50);
18 // We create NSGrayFrame instead of CustomFrameView because
19 // we are swizzling into NSGrayFrame. (NSThemeFrame on Mountain Lion and
21 Class customFrameClass = NSClassFromString(
22 base::mac::IsOSMountainLionOrLater() ? @"NSThemeFrame"
24 view_.reset([[customFrameClass alloc] initWithFrame:frame]);
27 base::scoped_nsobject<NSView> view_;
30 // Test to make sure our class modifications were successful.
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())
38 BOOL foundSwizzledMethod = NO;
40 Method* methods = class_copyMethodList([view_ class], &count);
41 for (unsigned int i = 0; i < count; ++i) {
42 SEL selector = method_getName(methods[i]);
43 if (selector == @selector(_fullScreenButtonOriginOriginal))
44 foundSwizzledMethod = YES;
46 EXPECT_TRUE(foundSwizzledMethod);