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

Unified Diff: chrome/browser/cocoa/bookmark_bar_controller_unittest.mm

Issue 149308: a bunch of bookmark bar changes (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_controller.mm ('k') | chrome/browser/cocoa/bookmark_button_cell.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/bookmark_bar_controller_unittest.mm
===================================================================
--- chrome/browser/cocoa/bookmark_bar_controller_unittest.mm (revision 20198)
+++ chrome/browser/cocoa/bookmark_bar_controller_unittest.mm (working copy)
@@ -10,6 +10,21 @@
#import "chrome/browser/cocoa/cocoa_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
+// Pretend BookmarkURLOpener delegate to keep track of requests
+@interface BookmarkURLOpenerPong : NSObject<BookmarkURLOpener> {
+ @public
+ GURL url_;
+}
+@end
+
+@implementation BookmarkURLOpenerPong
+- (void)openBookmarkURL:(const GURL&)url
+ disposition:(WindowOpenDisposition)disposition {
+ url_ = url;
+}
+@end
+
+
namespace {
static const int kContentAreaHeight = 500;
@@ -18,10 +33,15 @@
public:
BookmarkBarControllerTest() {
NSRect content_frame = NSMakeRect(0, 0, 800, kContentAreaHeight);
+ NSRect bar_frame = NSMakeRect(0, 0, 800, 0);
content_area_.reset([[NSView alloc] initWithFrame:content_frame]);
+ bar_view_.reset([[NSView alloc] initWithFrame:bar_frame]);
+ [bar_view_ setHidden:YES];
+ BookmarkBarView *bbv = (BookmarkBarView*)bar_view_.get();
bar_.reset(
[[BookmarkBarController alloc] initWithProfile:helper_.profile()
- contentView:content_area_.get()
+ view:bbv
+ webContentView:content_area_.get()
delegate:nil]);
NSView* parent = cocoa_helper_.contentView();
[parent addSubview:content_area_.get()];
@@ -30,6 +50,7 @@
CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc...
scoped_nsobject<NSView> content_area_;
+ scoped_nsobject<NSView> bar_view_;
BrowserTestHelper helper_;
scoped_nsobject<BookmarkBarController> bar_;
};
@@ -38,6 +59,7 @@
// Assume hidden by default in a new profile.
EXPECT_FALSE([bar_ isBookmarkBarVisible]);
EXPECT_TRUE([[bar_ view] isHidden]);
+ EXPECT_EQ([bar_view_ frame].size.height, 0);
// Show and hide it by toggling.
[bar_ toggleBookmarkBar];
@@ -45,18 +67,34 @@
EXPECT_FALSE([[bar_ view] isHidden]);
NSRect content_frame = [content_area_ frame];
EXPECT_NE(content_frame.size.height, kContentAreaHeight);
+ EXPECT_GT([bar_view_ frame].size.height, 0);
[bar_ toggleBookmarkBar];
EXPECT_FALSE([bar_ isBookmarkBarVisible]);
EXPECT_TRUE([[bar_ view] isHidden]);
content_frame = [content_area_ frame];
EXPECT_EQ(content_frame.size.height, kContentAreaHeight);
+ EXPECT_EQ([bar_view_ frame].size.height, 0);
}
-// TODO(jrg): replace getTabContents
+// Confirm openBookmark: forwards the request to the controller's delegate
TEST_F(BookmarkBarControllerTest, OpenBookmark) {
+ GURL gurl("http://walla.walla.ding.dong.com");
+ scoped_ptr<BookmarkNode> node(new BookmarkNode(gurl));
+ scoped_nsobject<BookmarkURLOpenerPong> pong([[BookmarkURLOpenerPong alloc]
pink (ping after 24hrs) 2009/07/09 14:19:42 the problem with converting this to a scoped objec
John Grabowski 2009/07/09 22:07:26 It's a good idea; I will follow-up in a future CL.
+ init]);
+ [bar_ setDelegate:pong.get()];
+
+ scoped_nsobject<NSButtonCell> cell([[NSButtonCell alloc] init]);
+ scoped_nsobject<NSButton> button([[NSButton alloc] init]);
+ [button setCell:cell.get()];
+ [cell setRepresentedObject:[NSValue valueWithPointer:node.get()]];
+ [bar_ openBookmark:button];
+
+ EXPECT_EQ(pong.get()->url_, node->GetURL());
}
-// TODO(jrg): Make sure showing the bookmark bar calls loaded: (to process bookmarks)
+// TODO(jrg): Make sure showing the bookmark bar calls loaded: (to
+// process bookmarks)
TEST_F(BookmarkBarControllerTest, ShowAndLoad) {
}
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_controller.mm ('k') | chrome/browser/cocoa/bookmark_button_cell.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698