summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-14 00:58:17 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-14 00:58:17 +0000
commit7a1951a2d5a549f49714aa243c5f51fa9b86f7a8 (patch)
tree07805676229df685a71734c3a1b031168af057d1 /chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm
parent7cd22a5102842cfbb51e06c626d769d81bb78210 (diff)
downloadchromium_src-7a1951a2d5a549f49714aa243c5f51fa9b86f7a8.zip
chromium_src-7a1951a2d5a549f49714aa243c5f51fa9b86f7a8.tar.gz
chromium_src-7a1951a2d5a549f49714aa243c5f51fa9b86f7a8.tar.bz2
More bookmark bar changes.
* Applied memory cleanliness fix in unit test; follow-up from http://codereview.chromium.org/149308. * Move bookmark bar into it's own nib; minor code refactor to accomodate. * The toolbar STAR button somehow lost it's action; added it back in. * Implemented delete bookmark notification callback so we behave (remove button from the screen) when a bookmark is deleted. * Added context menus for the bookmark bar and bookmark buttons. * Hooked up a handful of these menu items. E.g. - open in new tab, window, incog window - delete bookmark (finally) - bookmark manager (which then hits a NOTIMPLEMENTED()) - always show bookmark bar * Truncate bookmark button text on end, not on middle. Experimental to look more like Windows. It looks cleaner but is less Mac-like. * Add "draws border when mouse goes over" for bookmark buttons. Need to do it by hand since we have a custom button drawing method. BUG=crbug.com/8381 TEST=Here's a list: - Make sure the bookmark buttons don't have a border unless the mouse is over them - Toolbar "STAR" should now add bookmarks when clicked - Test context menus on bookmark buttons, and the bar itself - Confirm a few of the behaviors as listed in the 'what I hooked up'; e.g. Right click on bookmark --> delete menu item should delete button Review URL: http://codereview.chromium.org/155358 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20591 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm')
-rw-r--r--chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm34
1 files changed, 23 insertions, 11 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm b/chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm
index 687c64a..0a21e04 100644
--- a/chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm
+++ b/chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm
@@ -32,10 +32,12 @@ typedef std::pair<GURL,WindowOpenDisposition> OpenInfo;
@implementation FakeBookmarkBarController
-- (id)initWithProfile:(Profile*)profile view:(NSView*)view {
+- (id)initWithProfile:(Profile*)profile
+ parentView:(NSView*)parentView
+ webContentView:(NSView*)webContentView {
if ((self = [super initWithProfile:profile
- view:(BookmarkBarView*)view
- webContentView:nil
+ parentView:parentView
+ webContentView:webContentView
delegate:self])) {
callbacks_.reset([[NSMutableArray alloc] init]);
}
@@ -76,6 +78,11 @@ typedef std::pair<GURL,WindowOpenDisposition> OpenInfo;
[callbacks_ addObject:[NSNumber numberWithInt:6]];
}
+- (void)nodeRemoved:(BookmarkModel*)model
+ parent:(const BookmarkNode*)oldParent index:(int)index {
+ [callbacks_ addObject:[NSNumber numberWithInt:7]];
+}
+
// Save the request.
- (void)openBookmarkURL:(const GURL&)url
disposition:(WindowOpenDisposition)disposition {
@@ -102,12 +109,16 @@ TEST_F(BookmarkBarBridgeTest, TestRedirect) {
Profile *profile = browser_test_helper_.profile();
BookmarkModel *model = profile->GetBookmarkModel();
- scoped_nsobject<NSView> view([[NSView alloc]
- initWithFrame:NSMakeRect(0,0,10,10)]);
- [view.get() setHidden:YES];
+ scoped_nsobject<NSView> parentView([[NSView alloc]
+ initWithFrame:NSMakeRect(0,0,100,100)]);
+ scoped_nsobject<NSView> webView([[NSView alloc]
+ initWithFrame:NSMakeRect(0,0,100,100)]);
+
scoped_nsobject<FakeBookmarkBarController>
- controller([[FakeBookmarkBarController alloc] initWithProfile:profile
- view:view.get()]);
+ controller([[FakeBookmarkBarController alloc]
+ initWithProfile:profile
+ parentView:parentView.get()
+ webContentView:webView.get()]);
EXPECT_TRUE(controller.get());
scoped_ptr<BookmarkBarBridge> bridge(new BookmarkBarBridge(controller.get(),
model));
@@ -120,11 +131,12 @@ TEST_F(BookmarkBarBridgeTest, TestRedirect) {
bridge->BookmarkNodeChanged(NULL, NULL);
bridge->BookmarkNodeFavIconLoaded(NULL, NULL);
bridge->BookmarkNodeChildrenReordered(NULL, NULL);
+ bridge->BookmarkNodeRemoved(NULL, NULL, 0);
- // 7 calls above plus an initial Loaded() in init routine makes 8
- EXPECT_TRUE([controller.get()->callbacks_ count] == 8);
+ // 8 calls above plus an initial Loaded() in init routine makes 9
+ EXPECT_TRUE([controller.get()->callbacks_ count] == 9);
- for (int x = 1; x < 8; x++) {
+ for (int x = 1; x < 9; x++) {
NSNumber *num = [NSNumber numberWithInt:x-1];
EXPECT_TRUE([[controller.get()->callbacks_ objectAtIndex:x] isEqual:num]);
}