Home | History | Annotate | Download | only in cocoa
      1 // Copyright (c) 2011 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.
      4 
      5 #import <Cocoa/Cocoa.h>
      6 #include <objc/runtime.h>
      7 
      8 #include "base/memory/scoped_nsobject.h"
      9 #import "chrome/browser/ui/cocoa/browser_frame_view.h"
     10 #include "testing/gtest/include/gtest/gtest.h"
     11 #include "testing/platform_test.h"
     12 
     13 class BrowserFrameViewTest : public PlatformTest {
     14  public:
     15   BrowserFrameViewTest() {
     16     NSRect frame = NSMakeRect(0, 0, 50, 50);
     17     // We create NSGrayFrame instead of BrowserFrameView because
     18     // we are swizzling into NSGrayFrame.
     19     Class browserFrameClass = NSClassFromString(@"NSGrayFrame");
     20     view_.reset([[browserFrameClass alloc] initWithFrame:frame]);
     21   }
     22 
     23   scoped_nsobject<NSView> view_;
     24 };
     25 
     26 //  Test to make sure our class modifications were successful.
     27 TEST_F(BrowserFrameViewTest, SuccessfulClassModifications) {
     28   unsigned int count;
     29   BOOL foundDrawRectOriginal = NO;
     30 
     31   Method* methods = class_copyMethodList([view_ class], &count);
     32   for (unsigned int i = 0; i < count; ++i) {
     33     SEL selector = method_getName(methods[i]);
     34     if (selector == @selector(drawRectOriginal:)) {
     35       foundDrawRectOriginal = YES;
     36     }
     37   }
     38   EXPECT_TRUE(foundDrawRectOriginal);
     39   free(methods);
     40 }
     41