1 // Copyright (c) 2011 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.
5 #import <Cocoa/Cocoa.h>
7 #include "base/mac/scoped_nsobject.h"
8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
9 #import "chrome/browser/ui/cocoa/wrench_menu/menu_tracked_root_view.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h"
12 #import "third_party/ocmock/OCMock/OCMock.h"
13 #include "third_party/ocmock/gtest_support.h"
15 class MenuTrackedRootViewTest : public CocoaTest {
17 virtual void SetUp() {
19 view_.reset([[MenuTrackedRootView alloc] init]);
22 base::scoped_nsobject<MenuTrackedRootView> view_;
25 TEST_F(MenuTrackedRootViewTest, MouseUp) {
26 id menu = [OCMockObject mockForClass:[NSMenu class]];
27 [[menu expect] cancelTracking];
29 id menuItem = [OCMockObject mockForClass:[NSMenuItem class]];
30 [[[menuItem stub] andReturn:menu] menu];
32 [view_ setMenuItem:menuItem];
33 NSEvent* event = [NSEvent mouseEventWithType:NSLeftMouseUp
34 location:NSMakePoint(42, 42)
37 windowNumber:[test_window() windowNumber]
42 [view_ mouseUp:event];
44 EXPECT_OCMOCK_VERIFY(menu);
45 EXPECT_OCMOCK_VERIFY(menuItem);