| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2009 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/scoped_nsobject.h" |
| 9 #import "chrome/browser/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 foundMouseInGroup = NO; |
| 30 BOOL foundDrawRectOriginal = NO; |
| 31 BOOL foundUpdateTrackingAreas = NO; |
| 32 |
| 33 Method* methods = class_copyMethodList([view_ class], &count); |
| 34 for (unsigned int i = 0; i < count; ++i) { |
| 35 SEL selector = method_getName(methods[i]); |
| 36 if (selector == @selector(_mouseInGroup:)) { |
| 37 foundMouseInGroup = YES; |
| 38 } else if (selector == @selector(drawRectOriginal:)) { |
| 39 foundDrawRectOriginal = YES; |
| 40 } else if (selector == @selector(updateTrackingAreas)) { |
| 41 foundUpdateTrackingAreas = YES; |
| 42 } |
| 43 } |
| 44 EXPECT_TRUE(foundMouseInGroup); |
| 45 EXPECT_TRUE(foundDrawRectOriginal); |
| 46 EXPECT_TRUE(foundUpdateTrackingAreas); |
| 47 free(methods); |
| 48 } |
| OLD | NEW |