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) {
33 BOOL foundDrawRectOriginal = NO;
35 Method* methods = class_copyMethodList([view_ class], &count);
36 for (unsigned int i = 0; i < count; ++i) {
37 SEL selector = method_getName(methods[i]);
38 if (selector == @selector(drawRectOriginal:)) {
39 foundDrawRectOriginal = YES;
42 EXPECT_TRUE(foundDrawRectOriginal);