OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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 #include "base/scoped_nsobject.h" | 7 #include "base/scoped_nsobject.h" |
8 #import "chrome/browser/cocoa/clickhold_button_cell.h" | 8 #import "chrome/browser/cocoa/clickhold_button_cell.h" |
9 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 9 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
10 #import "chrome/browser/cocoa/delayedmenu_button.h" | 10 #import "chrome/browser/cocoa/delayedmenu_button.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // crashes. | 45 // crashes. |
46 TEST_F(DelayedMenuButtonTest, MenuAssign) { | 46 TEST_F(DelayedMenuButtonTest, MenuAssign) { |
47 scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:@""]); | 47 scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:@""]); |
48 ASSERT_TRUE(menu.get()); | 48 ASSERT_TRUE(menu.get()); |
49 | 49 |
50 [menu insertItemWithTitle:@"" action:nil keyEquivalent:@"" atIndex:0]; | 50 [menu insertItemWithTitle:@"" action:nil keyEquivalent:@"" atIndex:0]; |
51 [menu insertItemWithTitle:@"foo" action:nil keyEquivalent:@"" atIndex:1]; | 51 [menu insertItemWithTitle:@"foo" action:nil keyEquivalent:@"" atIndex:1]; |
52 [menu insertItemWithTitle:@"bar" action:nil keyEquivalent:@"" atIndex:2]; | 52 [menu insertItemWithTitle:@"bar" action:nil keyEquivalent:@"" atIndex:2]; |
53 [menu insertItemWithTitle:@"baz" action:nil keyEquivalent:@"" atIndex:3]; | 53 [menu insertItemWithTitle:@"baz" action:nil keyEquivalent:@"" atIndex:3]; |
54 | 54 |
55 [button_ setMenu:menu]; | 55 [button_ setAttachedMenu:menu]; |
56 EXPECT_TRUE([button_ menu]); | 56 EXPECT_TRUE([button_ attachedMenu]); |
57 | 57 |
58 [button_ setMenuEnabled:YES]; | 58 [button_ setAttachedMenuEnabled:YES]; |
59 EXPECT_TRUE([button_ menuEnabled]); | 59 EXPECT_TRUE([button_ attachedMenuEnabled]); |
60 | 60 |
61 // TODO(viettrungluu): Display the menu. (Calling DelayedMenuButton's private | 61 // TODO(viettrungluu): Display the menu. (Calling DelayedMenuButton's private |
62 // |-menuAction:| method displays it fine, but the problem is getting rid of | 62 // |-attachedMenuAction:| method displays it fine, but the problem is |
63 // the menu. We can catch the |NSMenuDidBeginTrackingNotification| from |menu| | 63 // getting rid of the menu. We can catch the |
64 // fine, but then |-cancelTracking| doesn't dismiss it. I don't know why.) | 64 // |NSMenuDidBeginTrackingNotification| from |menu| fine, but then |
| 65 // |-cancelTracking| doesn't dismiss it. I don't know why.) |
65 } | 66 } |
66 | 67 |
67 // TODO(viettrungluu): Test the two actions of the button (the normal one and | 68 // TODO(viettrungluu): Test the two actions of the button (the normal one and |
68 // displaying the menu, also making sure the latter drags correctly)? It would | 69 // displaying the menu, also making sure the latter drags correctly)? It would |
69 // require "emulating" a mouse.... | 70 // require "emulating" a mouse.... |
70 | 71 |
71 } // namespace | 72 } // namespace |
OLD | NEW |