| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import <Cocoa/Cocoa.h> | |
| 6 | |
| 7 #import "chrome/browser/cocoa/bookmark_bar_view.h" | |
| 8 #import "chrome/browser/cocoa/cocoa_test_helper.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | |
| 11 class BookmarkBarViewTest : public testing::Test { | |
| 12 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... | |
| 13 }; | |
| 14 | |
| 15 // Make sure we only get a menu from a right-click. Not left-click or keyDown. | |
| 16 TEST_F(BookmarkBarViewTest, TestMenu) { | |
| 17 scoped_nsobject<BookmarkBarView> view([[BookmarkBarView alloc] | |
| 18 initWithFrame:NSMakeRect(0,0,10,10)]); | |
| 19 EXPECT_TRUE(view.get()); | |
| 20 | |
| 21 // Not loaded from a nib so we must set it explicitly | |
| 22 scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:@"spork"]); | |
| 23 [view setContextMenu:menu.get()]; | |
| 24 | |
| 25 EXPECT_TRUE([view menuForEvent:[NSEvent mouseEventWithType:NSRightMouseDown | |
| 26 location:NSMakePoint(0,0) | |
| 27 modifierFlags:0 | |
| 28 timestamp:0 | |
| 29 windowNumber:0 | |
| 30 context:nil | |
| 31 eventNumber:0 | |
| 32 clickCount:0 | |
| 33 pressure:0.0]]); | |
| 34 EXPECT_FALSE([view menuForEvent:[NSEvent mouseEventWithType:NSLeftMouseDown | |
| 35 location:NSMakePoint(0,0) | |
| 36 modifierFlags:0 | |
| 37 timestamp:0 | |
| 38 windowNumber:0 | |
| 39 context:nil | |
| 40 eventNumber:0 | |
| 41 clickCount:0 | |
| 42 pressure:0.0]]); | |
| 43 EXPECT_FALSE([view menuForEvent:[NSEvent keyEventWithType:NSKeyDown | |
| 44 location:NSMakePoint(0,0) | |
| 45 modifierFlags:0 | |
| 46 timestamp:0 | |
| 47 windowNumber:0 | |
| 48 context:nil | |
| 49 characters:@"x" | |
| 50 charactersIgnoringModifiers:@"x" | |
| 51 isARepeat:NO | |
| 52 keyCode:7]]); | |
| 53 | |
| 54 [view setContextMenu:nil]; | |
| 55 } | |
| 56 | |
| 57 | |
| 58 | |
| OLD | NEW |