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
3 // found in the LICENSE file.
5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_unittest_helper.h"
7 @interface NSArray (BookmarkBarUnitTestHelper)
9 // A helper function for scanning an array of buttons looking for the
10 // button with the given |title|.
11 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title;
16 @implementation NSArray (BookmarkBarUnitTestHelper)
18 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title {
19 for (BookmarkButton* button in self) {
20 if ([[button title] isEqualToString:title])
28 @implementation BookmarkBarController (BookmarkBarUnitTestHelper)
30 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title {
31 return [[self buttons] buttonWithTitleEqualTo:title];
36 @implementation BookmarkBarFolderController(BookmarkBarUnitTestHelper)
38 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title {
39 return [[self buttons] buttonWithTitleEqualTo:title];
44 @implementation BookmarkButton(BookmarkBarUnitTestHelper)
47 NSRect frame = [self frame];
48 NSPoint center = NSMakePoint(NSMidX(frame), NSMidY(frame));
49 center = [[self superview] convertPoint:center toView:nil];
54 NSRect frame = [self frame];
55 NSPoint top = NSMakePoint(NSMidX(frame), NSMaxY(frame));
56 top = [[self superview] convertPoint:top toView:nil];
61 NSRect frame = [self frame];
62 NSPoint bottom = NSMakePoint(NSMidX(frame), NSMinY(frame));
63 bottom = [[self superview] convertPoint:bottom toView:nil];
68 NSRect frame = [self frame];
69 NSPoint left = NSMakePoint(NSMinX(frame), NSMidY(frame));
70 left = [[self superview] convertPoint:left toView:nil];
75 NSRect frame = [self frame];
76 NSPoint right = NSMakePoint(NSMaxX(frame), NSMidY(frame));
77 right = [[self superview] convertPoint:right toView:nil];