Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / bookmarks / bookmark_bar_unittest_helper.mm
blob03022bae8b4c55e6960802bceb18214f3e1fefca
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;
13 @end
16 @implementation NSArray (BookmarkBarUnitTestHelper)
18 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title {
19   for (BookmarkButton* button in self) {
20     if ([[button title] isEqualToString:title])
21       return button;
22   }
23   return nil;
26 @end
28 @implementation BookmarkBarController (BookmarkBarUnitTestHelper)
30 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title {
31   return [[self buttons] buttonWithTitleEqualTo:title];
34 @end
36 @implementation BookmarkBarFolderController(BookmarkBarUnitTestHelper)
38 - (BookmarkButton*)buttonWithTitleEqualTo:(NSString*)title {
39   return [[self buttons] buttonWithTitleEqualTo:title];
42 @end
44 @implementation BookmarkButton(BookmarkBarUnitTestHelper)
46 - (NSPoint)center {
47   NSRect frame = [self frame];
48   NSPoint center = NSMakePoint(NSMidX(frame), NSMidY(frame));
49   center = [[self superview] convertPoint:center toView:nil];
50   return center;
53 - (NSPoint)top {
54   NSRect frame = [self frame];
55   NSPoint top = NSMakePoint(NSMidX(frame), NSMaxY(frame));
56   top = [[self superview] convertPoint:top toView:nil];
57   return top;
60 - (NSPoint)bottom {
61   NSRect frame = [self frame];
62   NSPoint bottom = NSMakePoint(NSMidX(frame), NSMinY(frame));
63   bottom = [[self superview] convertPoint:bottom toView:nil];
64   return bottom;
67 - (NSPoint)left {
68   NSRect frame = [self frame];
69   NSPoint left = NSMakePoint(NSMinX(frame), NSMidY(frame));
70   left = [[self superview] convertPoint:left toView:nil];
71   return left;
74 - (NSPoint)right {
75   NSRect frame = [self frame];
76   NSPoint right = NSMakePoint(NSMaxX(frame), NSMidY(frame));
77   right = [[self superview] convertPoint:right toView:nil];
78   return right;
81 @end