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

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

Issue 155358: More bookmark bar changes.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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_view.mm ('k') | chrome/browser/cocoa/bookmark_button_cell.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/bookmark_bar_view_unittest.mm
===================================================================
--- chrome/browser/cocoa/bookmark_bar_view_unittest.mm (revision 20588)
+++ chrome/browser/cocoa/bookmark_bar_view_unittest.mm (working copy)
@@ -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];
+}
+
+
+
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_view.mm ('k') | chrome/browser/cocoa/bookmark_button_cell.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698