Commit 1e5f7142 authored by gajendra.n's avatar gajendra.n Committed by Commit bot

Open just folder menu on middle clicking chevron button.

In common openBookmarkFolder: function, check if button is offTheSideButton and
event is NSOtherMouseUp, if so, open just the folder menu instead of opening all
bookmarks under it.

BUG=46682
R=asvitkine@chromium.org

TEST=
1) Launch chrome and add more bookmarks to Bookmarks bar so that offTheSideButton
is visible.
2) Middle click on the button and observe.
3) It should just open its folder menu instead of opening all bookmarks under it.

Review URL: https://codereview.chromium.org/583223002

Cr-Commit-Position: refs/heads/master@{#295981}
parent b2c1542b
......@@ -389,6 +389,7 @@ willAnimateFromState:(BookmarkBar::State)oldState
// These APIs should only be used by unit tests (or used internally).
@interface BookmarkBarController(InternalOrTestingAPI)
- (void)openBookmarkFolder:(id)sender;
- (void)openOrCloseBookmarkFolderForOffTheSideButton;
- (BookmarkBarView*)buttonView;
- (NSMutableArray*)buttons;
- (NSButton*)offTheSideButton;
......
......@@ -716,13 +716,28 @@ void RecordAppLaunch(Profile* profile, GURL url) {
RecordBookmarkFolderOpen([self bookmarkLaunchLocation]);
showFolderMenus_ = !showFolderMenus_;
if (sender == offTheSideButton_)
// Middle click on chevron should not open bookmarks under it, instead just
// open its folder menu.
if (sender == offTheSideButton_) {
[[sender cell] setStartingChildIndex:displayedButtonCount_];
NSEvent* event = [NSApp currentEvent];
if ([event type] == NSOtherMouseUp) {
[self openOrCloseBookmarkFolderForOffTheSideButton];
return;
}
}
// Toggle presentation of bar folder menus.
[folderTarget_ openBookmarkFolderFromButton:sender];
}
- (void)openOrCloseBookmarkFolderForOffTheSideButton {
// If clicked on already opened folder, then close it and return.
if ([folderController_ parentButton] == offTheSideButton_)
[self closeBookmarkFolder:self];
else
[self addNewFolderControllerWithParentButton:offTheSideButton_];
}
// Click on a bookmark folder button.
- (IBAction)openBookmarkFolderFromButton:(id)sender {
[self openBookmarkFolder:sender];
......
......@@ -939,7 +939,8 @@ TEST_F(BookmarkBarControllerTest, Display) {
[[bar_ view] display];
}
// Test that middle clicking on a bookmark button results in an open action.
// Test that middle clicking on a bookmark button results in an open action,
// except for offTheSideButton, as it just opens its folder menu.
TEST_F(BookmarkBarControllerTest, MiddleClick) {
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
GURL gurl1("http://www.google.com/");
......@@ -953,6 +954,37 @@ TEST_F(BookmarkBarControllerTest, MiddleClick) {
[first otherMouseUp:
cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0)];
EXPECT_EQ(noOpenBar()->urls_.size(), 1U);
// Test for offTheSideButton.
// Add more bookmarks so that offTheSideButton is visible.
const BookmarkNode* parent = model->bookmark_bar_node();
for (int i = 0; i < 20; i++) {
model->AddURL(parent, parent->child_count(),
ASCIIToUTF16("super duper wide title"),
GURL("http://superfriends.hall-of-justice.edu"));
}
EXPECT_FALSE([bar_ offTheSideButtonIsHidden]);
NSButton* offTheSideButton = [bar_ offTheSideButton];
EXPECT_TRUE(offTheSideButton);
[offTheSideButton otherMouseUp:
cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0)];
// Middle click on offTheSideButton should not open any bookmarks under it,
// therefore urls size should still be 1.
EXPECT_EQ(noOpenBar()->urls_.size(), 1U);
// Check that folderController should not be NULL since offTheSideButton
// folder is currently open.
BookmarkBarFolderController* bbfc = [bar_ folderController];
EXPECT_TRUE(bbfc);
EXPECT_TRUE([bbfc parentButton] == offTheSideButton);
// Middle clicking again on it should close the folder.
[offTheSideButton otherMouseUp:
cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0)];
bbfc = [bar_ folderController];
EXPECT_FALSE(bbfc);
}
TEST_F(BookmarkBarControllerTest, DisplaysHelpMessageOnEmpty) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment