diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 23:26:27 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 23:26:27 +0000 |
commit | d27fd0e73b0620cc3af740d2dd2138c20ca4372a (patch) | |
tree | e97bc4d580ed7893b035168f2380b3b2f28908bb /chrome/browser/cocoa/bookmark_button_cell_unittest.mm | |
parent | 38eb08a5fd1ea4f529b9d4651a2f2eb31b0d2192 (diff) | |
download | chromium_src-d27fd0e73b0620cc3af740d2dd2138c20ca4372a.zip chromium_src-d27fd0e73b0620cc3af740d2dd2138c20ca4372a.tar.gz chromium_src-d27fd0e73b0620cc3af740d2dd2138c20ca4372a.tar.bz2 |
Custom "menus" for the bookmark bar folders.
Full behavior: http://JRG_WRITE_FULL_DOC_AND_TEST_PLAN_TOMORROW
BUG=17608 (and a slew of others)
Brief details on how to test:
- add some bookmarks and bookmark folders.
- at a basic level, make sure bookmark folders feel like menus e.g.
-- click to open
-- can open "submenus" and sub-sub-menus
-- can open (click on) bookmarks in any of these submenus
- click-drag does NOT open a menu (different than Mac menus); it initiates a Drag
- click on folder in bookmark bar initiates "hover open"; moving mouse
over other folders will pop them open immediately (much like Mac menus)
- Bookmark bar non-drag hover-open is immediate, but bookmark folder
hover-open has a brief delay so quick "move down" a folder does not
trigger them all to open while you travel (much like Mac menus).
- DnD of bookmarks and folders on bookmark bar.
- While doing DnD of bookmark, "hover" over a folder and see it open.
- Bookmark folder menus have normal DnD "drop indicators" like the bookmark bar.
- Can "hover open" a nested subfolder.
- Can drag a bookmark from one deep sub-sub-folder to a different deep one.
- Confirm buttons and folders in submenus are themed, both with the
theme set at launch time and the theme we change to after launch.
- Empty folders have an "(empty)" item which is not selectable.
- Intentional delay in closing a sub-sub-folder when hovering over
another one. E.g. When moving to a sub-sub-menu, 'brief' travel
over a different submenu does not close the destination sub-menu.
- can use bookmark context menus in folder "menus".
- confirm DnD from "Other bookmarks" to any other random folder and
vice versa.
- While non-drag hover open is active, clicking anywhere other than
the bookmark bar or folder (e.g. the main web view) turns it off.
TODO:
- random bugs (e.g. "add folder" over a folder doesn't put it in there)
- (empty) needs to be revisited, both visually and for a drop indication
- core animations instead of drop indicators
- ...
Review URL: http://codereview.chromium.org/551226
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39947 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_button_cell_unittest.mm')
-rw-r--r-- | chrome/browser/cocoa/bookmark_button_cell_unittest.mm | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/chrome/browser/cocoa/bookmark_button_cell_unittest.mm b/chrome/browser/cocoa/bookmark_button_cell_unittest.mm index a1b7b40..07f9984 100644 --- a/chrome/browser/cocoa/bookmark_button_cell_unittest.mm +++ b/chrome/browser/cocoa/bookmark_button_cell_unittest.mm @@ -5,10 +5,31 @@ #include "base/scoped_nsobject.h" #import "chrome/browser/cocoa/bookmark_button_cell.h" #import "chrome/browser/cocoa/bookmark_menu.h" +#include "chrome/browser/cocoa/browser_test_helper.h" #import "chrome/browser/cocoa/cocoa_test_helper.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" +// Simple class to remember how many mouseEntered: and mouseExited: +// calls it gets. Only used by BookmarkMouseForwarding but placed +// at the top of the file to keep it outside the anon namespace. +@interface ButtonRemembersMouseEnterExit : NSButton { + @public + int enters_; + int exits_; +} +@end + +@implementation ButtonRemembersMouseEnterExit +- (void)mouseEntered:(NSEvent*)event { + enters_++; +} +- (void)mouseExited:(NSEvent*)event { + exits_++; +} +@end + + namespace { class BookmarkButtonCellTest : public CocoaTest { @@ -29,11 +50,59 @@ TEST_F(BookmarkButtonCellTest, SizeForBounds) { EXPECT_TRUE(size.width < 200 && size.height < 200); } -// Make sure the default from the base class is overridden +// Make sure the default from the base class is overridden. TEST_F(BookmarkButtonCellTest, MouseEnterStuff) { scoped_nsobject<BookmarkButtonCell> cell( [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); + [cell setMenu:[[[BookmarkMenu alloc] initWithTitle:@"foo"] autorelease]]; EXPECT_TRUE([cell.get() showsBorderOnlyWhileMouseInside]); + EXPECT_TRUE([cell menu]); + + [cell setEmpty:YES]; + EXPECT_FALSE([cell.get() showsBorderOnlyWhileMouseInside]); + EXPECT_FALSE([cell menu]); +} + +TEST_F(BookmarkButtonCellTest, BookmarkNode) { + BrowserTestHelper helper_; + BookmarkModel& model(*(helper_.profile()->GetBookmarkModel())); + scoped_nsobject<BookmarkButtonCell> cell( + [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); + + const BookmarkNode* node = model.GetBookmarkBarNode(); + [cell setBookmarkNode:node]; + EXPECT_EQ(node, [cell bookmarkNode]); + + node = model.other_node(); + [cell setBookmarkNode:node]; + EXPECT_EQ(node, [cell bookmarkNode]); +} + +TEST_F(BookmarkButtonCellTest, BookmarkMouseForwarding) { + scoped_nsobject<BookmarkButtonCell> cell( + [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); + scoped_nsobject<ButtonRemembersMouseEnterExit> + button([[ButtonRemembersMouseEnterExit alloc] + initWithFrame:NSMakeRect(0,0,50,50)]); + [button setCell:cell.get()]; + EXPECT_EQ(0, button.get()->enters_); + EXPECT_EQ(0, button.get()->exits_); + NSEvent* event = [NSEvent mouseEventWithType:NSMouseMoved + location:NSMakePoint(10,10) + modifierFlags:0 + timestamp:0 + windowNumber:0 + context:nil + eventNumber:0 + clickCount:0 + pressure:0]; + [cell mouseEntered:event]; + EXPECT_TRUE(button.get()->enters_ && !button.get()->exits_); + + for (int i = 0; i < 3; i++) + [cell mouseExited:event]; + EXPECT_EQ(button.get()->enters_, 1); + EXPECT_EQ(button.get()->exits_, 3); } } // namespace |