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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_unittest_helper.mm

Issue 7465090: [Mac] Replace the custom bookmark menus with native NSMenus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Typo Created 9 years, 4 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
OLDNEW
1 // Copyright (c) 2010 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 "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_unittest_helper.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_unittest_helper.h"
6 6
7 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h"
8 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h"
9
10 NSUInteger NumberOfMenuItems(BookmarkBarFolderController* folder) {
11 if (![folder menuBridge])
12 return 0;
13 return [[[[folder menuBridge]->controller() menu] itemArray] count];
14 }
15
16 void CloseFolderAfterDelay(BookmarkBarFolderController* folder,
17 NSTimeInterval delay) {
18 NSArray* modes = [NSArray arrayWithObjects:NSDefaultRunLoopMode,
19 NSEventTrackingRunLoopMode, nil];
20 [folder performSelector:@selector(closeMenu)
21 withObject:nil
22 afterDelay:delay
23 inModes:modes];
24 }
25
7 @interface NSArray (BookmarkBarUnitTestHelper) 26 @interface NSArray (BookmarkBarUnitTestHelper)
8 27
9 // A helper function for scanning an array of buttons looking for the 28 // A helper function for scanning an array of buttons looking for the
10 // button with the given |title|. 29 // button with the given |title|.
11 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title; 30 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title;
12 31
13 @end 32 @end
14 33
15 34
16 @implementation NSArray (BookmarkBarUnitTestHelper) 35 @implementation NSArray (BookmarkBarUnitTestHelper)
17 36
18 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title { 37 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title {
19 for (BookmarkButton* button in self) { 38 for (BookmarkButton* button in self) {
20 if ([[button title] isEqualToString:title]) 39 if ([[button title] isEqualToString:title])
21 return button; 40 return button;
22 } 41 }
23 return nil; 42 return nil;
24 } 43 }
25 44
26 @end 45 @end
27 46
28 @implementation BookmarkBarController (BookmarkBarUnitTestHelper) 47 @implementation BookmarkBarController (BookmarkBarUnitTestHelper)
29 48
30 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title { 49 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title {
31 return [[self buttons] buttonWithTitleEqualTo:title]; 50 return [[self buttons] buttonWithTitleEqualTo:title];
32 } 51 }
33 52
34 @end 53 @end
35 54
36 @implementation BookmarkBarFolderController(BookmarkBarUnitTestHelper)
37
38 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title {
39 return [[self buttons] buttonWithTitleEqualTo:title];
40 }
41
42 @end
43
44 @implementation BookmarkButton(BookmarkBarUnitTestHelper) 55 @implementation BookmarkButton(BookmarkBarUnitTestHelper)
45 56
46 - (NSPoint)center { 57 - (NSPoint)center {
47 NSRect frame = [self frame]; 58 NSRect frame = [self frame];
48 NSPoint center = NSMakePoint(NSMidX(frame), NSMidY(frame)); 59 NSPoint center = NSMakePoint(NSMidX(frame), NSMidY(frame));
49 center = [[self superview] convertPoint:center toView:nil]; 60 center = [[self superview] convertPoint:center toView:nil];
50 return center; 61 return center;
51 } 62 }
52 63
53 - (NSPoint)top { 64 - (NSPoint)top {
(...skipping 18 matching lines...) Expand all
72 } 83 }
73 84
74 - (NSPoint)right { 85 - (NSPoint)right {
75 NSRect frame = [self frame]; 86 NSRect frame = [self frame];
76 NSPoint right = NSMakePoint(NSMaxX(frame), NSMidY(frame)); 87 NSPoint right = NSMakePoint(NSMaxX(frame), NSMidY(frame));
77 right = [[self superview] convertPoint:right toView:nil]; 88 right = [[self superview] convertPoint:right toView:nil];
78 return right; 89 return right;
79 } 90 }
80 91
81 @end 92 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_unittest_helper.h ('k') | chrome/browser/ui/cocoa/bookmarks/bookmark_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698