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/menu_button.h" | 10 #import "chrome/browser/cocoa/menu_button.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // Test assigning a menu, again mostly to ensure nothing leaks or crashes. | 44 // Test assigning a menu, again mostly to ensure nothing leaks or crashes. |
45 TEST_F(MenuButtonTest, MenuAssign) { | 45 TEST_F(MenuButtonTest, MenuAssign) { |
46 scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:@""]); | 46 scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:@""]); |
47 ASSERT_TRUE(menu.get()); | 47 ASSERT_TRUE(menu.get()); |
48 | 48 |
49 [menu insertItemWithTitle:@"" action:nil keyEquivalent:@"" atIndex:0]; | 49 [menu insertItemWithTitle:@"" action:nil keyEquivalent:@"" atIndex:0]; |
50 [menu insertItemWithTitle:@"foo" action:nil keyEquivalent:@"" atIndex:1]; | 50 [menu insertItemWithTitle:@"foo" action:nil keyEquivalent:@"" atIndex:1]; |
51 [menu insertItemWithTitle:@"bar" action:nil keyEquivalent:@"" atIndex:2]; | 51 [menu insertItemWithTitle:@"bar" action:nil keyEquivalent:@"" atIndex:2]; |
52 [menu insertItemWithTitle:@"baz" action:nil keyEquivalent:@"" atIndex:3]; | 52 [menu insertItemWithTitle:@"baz" action:nil keyEquivalent:@"" atIndex:3]; |
53 | 53 |
54 [button_ setMenu:menu]; | 54 [button_ setAttachedMenu:menu]; |
55 EXPECT_TRUE([button_ menu]); | 55 EXPECT_TRUE([button_ attachedMenu]); |
56 | 56 |
57 // TODO(viettrungluu): Display the menu. (The tough part is closing the menu, | 57 // TODO(viettrungluu): Display the menu. (The tough part is closing the menu, |
58 // not opening it!) | 58 // not opening it!) |
59 | 59 |
60 // Since |button_| doesn't retain menu, we should probably unset it here. | 60 // Since |button_| doesn't retain menu, we should probably unset it here. |
61 [button_ setMenu:nil]; | 61 [button_ setAttachedMenu:nil]; |
62 } | 62 } |
63 | 63 |
64 } // namespace | 64 } // namespace |
OLD | NEW |