| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 | 6 |
| 7 #import "base/mac/cocoa_protocols.h" |
| 7 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 8 #import "chrome/browser/ui/cocoa/profile_menu_button.h" | 9 #import "chrome/browser/ui/cocoa/profile_menu_button.h" |
| 9 #import "chrome/browser/ui/cocoa/test_event_utils.h" | 10 #import "chrome/browser/ui/cocoa/test_event_utils.h" |
| 10 #import "testing/gtest_mac.h" | 11 #import "testing/gtest_mac.h" |
| 11 #import "third_party/ocmock/OCMock/OCMock.h" | 12 #import "third_party/ocmock/OCMock/OCMock.h" |
| 12 | 13 |
| 13 class ProfileMenuButtonTest : public CocoaTest { | 14 class ProfileMenuButtonTest : public CocoaTest { |
| 14 public: | 15 public: |
| 15 ProfileMenuButtonTest() { | 16 ProfileMenuButtonTest() { |
| 16 scoped_nsobject<ProfileMenuButton> button([[ProfileMenuButton alloc] | 17 scoped_nsobject<ProfileMenuButton> button([[ProfileMenuButton alloc] |
| (...skipping 23 matching lines...) Expand all Loading... |
| 40 EXPECT_GT([button desiredControlSize].height, minSize.height); | 41 EXPECT_GT([button desiredControlSize].height, minSize.height); |
| 41 EXPECT_GT([button desiredControlSize].width, minSize.width); | 42 EXPECT_GT([button desiredControlSize].width, minSize.width); |
| 42 | 43 |
| 43 [button setShouldShowProfileDisplayName:NO]; | 44 [button setShouldShowProfileDisplayName:NO]; |
| 44 EXPECT_TRUE(NSEqualSizes(minSize, [button desiredControlSize])); | 45 EXPECT_TRUE(NSEqualSizes(minSize, [button desiredControlSize])); |
| 45 EXPECT_TRUE(NSEqualSizes(minSize, [button desiredControlSize])); | 46 EXPECT_TRUE(NSEqualSizes(minSize, [button desiredControlSize])); |
| 46 } | 47 } |
| 47 | 48 |
| 48 // A menu delegate that will count the number open/close calls it recieves. | 49 // A menu delegate that will count the number open/close calls it recieves. |
| 49 // The delegate will also automatically close the menu after it opens. | 50 // The delegate will also automatically close the menu after it opens. |
| 50 @interface ProfileMenuDelegate : NSObject { | 51 @interface ProfileMenuDelegate : NSObject<NSMenuDelegate> { |
| 51 int menuOpenCount_; | 52 int menuOpenCount_; |
| 52 int menuCloseCount_; | 53 int menuCloseCount_; |
| 53 } | 54 } |
| 54 | 55 |
| 55 @property(assign,nonatomic) int menuOpenCount; | 56 @property(assign, nonatomic) int menuOpenCount; |
| 56 @property(assign,nonatomic) int menuCloseCount; | 57 @property(assign, nonatomic) int menuCloseCount; |
| 57 | 58 |
| 58 @end | 59 @end |
| 59 | 60 |
| 60 @implementation ProfileMenuDelegate | 61 @implementation ProfileMenuDelegate |
| 61 | 62 |
| 62 @synthesize menuOpenCount = menuOpenCount_; | 63 @synthesize menuOpenCount = menuOpenCount_; |
| 63 @synthesize menuCloseCount = menuCloseCount_; | 64 @synthesize menuCloseCount = menuCloseCount_; |
| 64 | 65 |
| 65 - (void)menuWillOpen:(NSMenu*)menu { | 66 - (void)menuWillOpen:(NSMenu*)menu { |
| 66 ++menuOpenCount_; | 67 ++menuOpenCount_; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 NSMaxY([button_ bounds]) - 1); | 130 NSMaxY([button_ bounds]) - 1); |
| 130 point = [button_ convertPointToBase:point]; | 131 point = [button_ convertPointToBase:point]; |
| 131 NSEvent* downEvent = | 132 NSEvent* downEvent = |
| 132 test_event_utils::LeftMouseDownAtPointInWindow(point, test_window()); | 133 test_event_utils::LeftMouseDownAtPointInWindow(point, test_window()); |
| 133 [button_ mouseDown:downEvent]; | 134 [button_ mouseDown:downEvent]; |
| 134 | 135 |
| 135 // Verify that the menu was shown. | 136 // Verify that the menu was shown. |
| 136 EXPECT_EQ([delegate menuOpenCount], 1); | 137 EXPECT_EQ([delegate menuOpenCount], 1); |
| 137 EXPECT_EQ([delegate menuCloseCount], 1); | 138 EXPECT_EQ([delegate menuCloseCount], 1); |
| 138 } | 139 } |
| OLD | NEW |