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

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

Issue 348017: Add the "Other bookmarks" button on the right of the bookmark bar.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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_bar_toolbar_view.h » ('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 30216)
+++ chrome/browser/cocoa/bookmark_bar_controller_unittest.mm (working copy)
@@ -218,7 +218,7 @@
bar.reset(
[[AlwaysNewTabPageBookmarkBarController alloc]
initWithBrowser:helper_.browser()
- initialWidth:100 // arbitrary
+ initialWidth:800 // arbitrary
compressDelegate:compressDelegate_.get()
resizeDelegate:resizeDelegate_.get()
urlDelegate:nil]);
@@ -231,6 +231,32 @@
EXPECT_FALSE([[bar view] isHidden]);
EXPECT_GT([resizeDelegate_ height], 0);
EXPECT_GT([[bar view] frame].size.height, 0);
+
+ // Make sure no buttons fall off the bar, either now or when resized
+ // bigger or smaller.
+ CGFloat sizes[] = { 300.0, -100.0, 200.0, -420.0 };
+ CGFloat previousX = 0.0;
+ for (unsigned x = 0; x < arraysize(sizes); x++) {
+ // Confirm the buttons moved from the last check (which may be
+ // init but that's fine).
+ CGFloat newX = [[bar offTheSideButton] frame].origin.x;
+ EXPECT_NE(previousX, newX);
+ previousX = newX;
+
+ // Confirm the buttons have a reasonable bounds.
+ EXPECT_TRUE(NSContainsRect([[bar buttonView] frame],
+ [[bar offTheSideButton] frame]));
+ EXPECT_TRUE(NSContainsRect([[bar buttonView] frame],
+ [[bar otherBookmarksButton] frame]));
+
+ // Now move them implicitly.
+ // We confirm FrameChangeNotification works in the next unit test;
+ // we simply assume it works here to resize or reposition the
+ // buttons above.
+ NSRect frame = [[bar view] frame];
+ frame.size.width += sizes[x];
+ [[bar view] setFrame:frame];
+ }
}
// Make sure we're watching for frame change notifications.
@@ -552,18 +578,22 @@
// TODO(jrg): write a test to confirm that nodeFavIconLoaded calls
// checkForBookmarkButtonGrowth:.
-// TODO(jrg): Make sure showing the bookmark bar calls loaded: (to
-// process bookmarks)
-TEST_F(BookmarkBarControllerTest, ShowAndLoad) {
-}
-
-// TODO(jrg): Test cellForBookmarkNode:
TEST_F(BookmarkBarControllerTest, Cell) {
-}
+ BookmarkModel* model = helper_.profile()->GetBookmarkModel();
+ [bar_ loaded:model];
-TEST_F(BookmarkBarControllerTest, Contents) {
- // TODO(jrg): addNodesToBar has a LOT of TODOs; when flushed out, write
- // appropriate tests.
+ const BookmarkNode* parent = model->GetBookmarkBarNode();
+ model->AddURL(parent, parent->GetChildCount(),
+ L"supertitle",
+ GURL("http://superfriends.hall-of-justice.edu"));
+ const BookmarkNode* node = parent->GetChild(0);
+
+ NSCell* cell = [bar_ cellForBookmarkNode:node];
+ EXPECT_TRUE(cell);
+ EXPECT_TRUE([[cell title] isEqual:@"supertitle"]);
+ EXPECT_EQ(node, [[cell representedObject] pointerValue]);
+
+ // cell is autoreleased; no need to release here
}
// Test drawing, mostly to ensure nothing leaks or crashes.
@@ -700,10 +730,4 @@
}
}
-
-// Cannot test these methods since they simply call a single static
-// method, BookmarkEditor::Show(), which is impossible to mock.
-// editBookmark:, addPage:
-
-
} // namespace
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_controller.mm ('k') | chrome/browser/cocoa/bookmark_bar_toolbar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698