Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Side by Side Diff: chrome/app/nibs/main_menu_unittest.mm

Issue 9230011: Better fix for Lion dictionary popover cmd-W bug. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/nibs/MainMenu.xib ('k') | chrome/browser/app_controller_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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
7 #include "base/mac/foundation_util.h"
8 #include "base/memory/scoped_nsobject.h"
9 #include "chrome/app/chrome_command_ids.h"
10 #include "testing/platform_test.h"
11
12 class MainMenuTest : public PlatformTest {
13 public:
14 // Recursively find the menu item with the given |tag| in |menu|.
15 NSMenuItem* FindMenuItemWithTag(NSMenu* menu, NSInteger tag) {
16 NSMenuItem* found = [menu itemWithTag:tag];
17 if (found)
18 return found;
19 NSMenuItem* item;
20 for (item in [menu itemArray]) {
21 if ([item hasSubmenu]) {
22 found = FindMenuItemWithTag([item submenu], tag);
23 if (found)
24 return found;
25 }
26 }
27 return nil;
28 }
29 };
30
31
32 TEST_F(MainMenuTest, CloseTabPerformClose) {
33 scoped_nsobject<NSNib> nib(
34 [[NSNib alloc] initWithNibNamed:@"MainMenu"
35 bundle:base::mac::MainAppBundle()]);
36 EXPECT_TRUE(nib);
37
38 NSArray* objects = nil;
39 EXPECT_TRUE([nib instantiateNibWithOwner:nil
40 topLevelObjects:&objects]);
41
42 // Check that "Close Tab" is mapped to -performClose:. This is needed to
43 // ensure the Lion dictionary pop up gets closed on Cmd-W, if it's open.
44 // See http://crbug.com/104931 for details.
45 BOOL found = NO;
46 for (NSUInteger i = 0; i < [objects count]; ++i) {
47 if ([[objects objectAtIndex:i] isKindOfClass:[NSMenu class]]) {
48 NSMenu* menu = [objects objectAtIndex:i];
49 NSMenuItem* closeTabItem = FindMenuItemWithTag(menu, IDC_CLOSE_TAB);
50 if (closeTabItem) {
51 EXPECT_EQ(@selector(performClose:), [closeTabItem action]);
52 found = YES;
53 break;
54 }
55 }
56 }
57 EXPECT_TRUE(found);
58 [objects makeObjectsPerformSelector:@selector(release)];
59 [NSApp setMainMenu:nil];
60 }
OLDNEW
« no previous file with comments | « chrome/app/nibs/MainMenu.xib ('k') | chrome/browser/app_controller_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698