diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-02 00:12:26 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-02 00:12:26 +0000 |
commit | c5726b841ef81c0a6432cfd18381b82767cc15da (patch) | |
tree | 10f578b72f3368e7aa15742b84eb6627d1f0e829 /chrome/browser/cocoa/bookmark_bar_controller_unittest.mm | |
parent | 78263c1774421e5f451a549e754390cfbcc6b27e (diff) | |
download | chromium_src-c5726b841ef81c0a6432cfd18381b82767cc15da.zip chromium_src-c5726b841ef81c0a6432cfd18381b82767cc15da.tar.gz chromium_src-c5726b841ef81c0a6432cfd18381b82767cc15da.tar.bz2 |
Add the "Other bookmarks" button on the right of the bookmark bar.
Lots of fixes to deal better with the floating bar on the
NTP (e.g. chevron resize, chevron enabling only when there is
overflow, ...)
Move layoutSubviews logic from bookmark_bar_toolbar_view to
bookmark_bar_controller to better honor MVC.
BUG=http://crbug.com/24985, http://crbug.com/24827, http://crbug.com/22018
TEST=Lots of moves:
New browser with no bookmarks.
Go to New Tab Page. Show Bookmark Bar.
See "Other Bookmarks" button on right.
Do NOT see chevron.
Hover over and click on Other Bookmarks to be sure it doesn't draw out of bounds.
Disable bookmark bar (so it is now floating).
Repeat hover/click test.
Enable (so now attached).
Add bookmarks until chevron shows up.
Repeat hover/click test with chevron and Other Bookmarks.
Make browser wider and thinner; each time repeat hover/click test.
Detach bookmark bar (so floating on NTP).
Make browser wider and thinner; each time repeat hover/click test.
Carefully make browser wider/thinner so chevron appears/disappears.
Make sure chevron never overlaps a bookmark.
With chevron visible, quit & relaunch. Make sure chevron visible.
With chevron NOT visible, quit & relaunch. Make sure chevron not visible.
Review URL: http://codereview.chromium.org/348017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_bar_controller_unittest.mm')
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller_unittest.mm | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm index a777e8c..5f645bf 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm @@ -218,7 +218,7 @@ TEST_F(BookmarkBarControllerTest, ShowOnNewTabPage) { 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 @@ TEST_F(BookmarkBarControllerTest, ShowOnNewTabPage) { 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 @@ TEST_F(BookmarkBarControllerTest, OpenAllBookmarks) { // 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 @@ TEST_F(BookmarkBarControllerTest, DropBookmarks) { } } - -// Cannot test these methods since they simply call a single static -// method, BookmarkEditor::Show(), which is impossible to mock. -// editBookmark:, addPage: - - } // namespace |