diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-14 00:58:17 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-14 00:58:17 +0000 |
commit | 7a1951a2d5a549f49714aa243c5f51fa9b86f7a8 (patch) | |
tree | 07805676229df685a71734c3a1b031168af057d1 /chrome/browser/cocoa/bookmark_bar_view_unittest.mm | |
parent | 7cd22a5102842cfbb51e06c626d769d81bb78210 (diff) | |
download | chromium_src-7a1951a2d5a549f49714aa243c5f51fa9b86f7a8.zip chromium_src-7a1951a2d5a549f49714aa243c5f51fa9b86f7a8.tar.gz chromium_src-7a1951a2d5a549f49714aa243c5f51fa9b86f7a8.tar.bz2 |
More bookmark bar changes.
* Applied memory cleanliness fix in unit test; follow-up from
http://codereview.chromium.org/149308.
* Move bookmark bar into it's own nib; minor code refactor to
accomodate.
* The toolbar STAR button somehow lost it's action; added it back in.
* Implemented delete bookmark notification callback so we behave
(remove button from the screen) when a bookmark is deleted.
* Added context menus for the bookmark bar and bookmark buttons.
* Hooked up a handful of these menu items. E.g.
- open in new tab, window, incog window
- delete bookmark (finally)
- bookmark manager (which then hits a NOTIMPLEMENTED())
- always show bookmark bar
* Truncate bookmark button text on end, not on middle.
Experimental to look more like Windows.
It looks cleaner but is less Mac-like.
* Add "draws border when mouse goes over" for bookmark buttons. Need
to do it by hand since we have a custom button drawing method.
BUG=crbug.com/8381
TEST=Here's a list:
- Make sure the bookmark buttons don't have a border unless the mouse is over them
- Toolbar "STAR" should now add bookmarks when clicked
- Test context menus on bookmark buttons, and the bar itself
- Confirm a few of the behaviors as listed in the 'what I hooked up'; e.g.
Right click on bookmark --> delete menu item should delete button
Review URL: http://codereview.chromium.org/155358
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20591 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_bar_view_unittest.mm')
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_view_unittest.mm | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_view_unittest.mm b/chrome/browser/cocoa/bookmark_bar_view_unittest.mm index 51b9f12..a1cb121 100644 --- a/chrome/browser/cocoa/bookmark_bar_view_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_view_unittest.mm @@ -2,5 +2,57 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This file is intentionally empty; there is no code in -// BookmarkBarView to test yet. +#import <Cocoa/Cocoa.h> + +#import "chrome/browser/cocoa/bookmark_bar_view.h" +#import "chrome/browser/cocoa/cocoa_test_helper.h" +#include "testing/gtest/include/gtest/gtest.h" + +class BookmarkBarViewTest : public testing::Test { + CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... +}; + +// Make sure we only get a menu from a right-click. Not left-click or keyDown. +TEST_F(BookmarkBarViewTest, TestMenu) { + scoped_nsobject<BookmarkBarView> view([[BookmarkBarView alloc] + initWithFrame:NSMakeRect(0,0,10,10)]); + EXPECT_TRUE(view.get()); + + // Not loaded from a nib so we must set it explicitly + scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:@"spork"]); + [view setContextMenu:menu.get()]; + + EXPECT_TRUE([view menuForEvent:[NSEvent mouseEventWithType:NSRightMouseDown + location:NSMakePoint(0,0) + modifierFlags:0 + timestamp:0 + windowNumber:0 + context:nil + eventNumber:0 + clickCount:0 + pressure:0.0]]); + EXPECT_FALSE([view menuForEvent:[NSEvent mouseEventWithType:NSLeftMouseDown + location:NSMakePoint(0,0) + modifierFlags:0 + timestamp:0 + windowNumber:0 + context:nil + eventNumber:0 + clickCount:0 + pressure:0.0]]); + EXPECT_FALSE([view menuForEvent:[NSEvent keyEventWithType:NSKeyDown + location:NSMakePoint(0,0) + modifierFlags:0 + timestamp:0 + windowNumber:0 + context:nil + characters:@"x" + charactersIgnoringModifiers:@"x" + isARepeat:NO + keyCode:7]]); + + [view setContextMenu:nil]; +} + + + |