OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #import "base/memory/scoped_nsobject.h" | 7 #import "base/mac/scoped_nsobject.h" |
8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
10 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button.h" | 10 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button.h" |
11 #import "testing/gtest_mac.h" | 11 #import "testing/gtest_mac.h" |
12 #import "ui/base/test/cocoa_test_event_utils.h" | 12 #import "ui/base/test/cocoa_test_event_utils.h" |
13 | 13 |
14 @interface TestableToolbarButton : ToolbarButton { | 14 @interface TestableToolbarButton : ToolbarButton { |
15 @private | 15 @private |
16 NSInteger numOfClick_; | 16 NSInteger numOfClick_; |
17 NSInteger lastCommand_; | 17 NSInteger lastCommand_; |
(...skipping 29 matching lines...) Expand all Loading... |
47 } | 47 } |
48 | 48 |
49 @end | 49 @end |
50 | 50 |
51 namespace { | 51 namespace { |
52 | 52 |
53 class ToolbarButtonTest : public CocoaTest { | 53 class ToolbarButtonTest : public CocoaTest { |
54 public: | 54 public: |
55 ToolbarButtonTest() { | 55 ToolbarButtonTest() { |
56 NSRect frame = NSMakeRect(0, 0, 20, 20); | 56 NSRect frame = NSMakeRect(0, 0, 20, 20); |
57 scoped_nsobject<TestableToolbarButton> button( | 57 base::scoped_nsobject<TestableToolbarButton> button( |
58 [[TestableToolbarButton alloc] initWithFrame:frame]); | 58 [[TestableToolbarButton alloc] initWithFrame:frame]); |
59 button_ = button.get(); | 59 button_ = button.get(); |
60 | 60 |
61 [button_ setTag:IDC_HOME]; | 61 [button_ setTag:IDC_HOME]; |
62 [button_ setTarget:button_]; | 62 [button_ setTarget:button_]; |
63 [button_ setAction:@selector(doAction:)]; | 63 [button_ setAction:@selector(doAction:)]; |
64 [[test_window() contentView] addSubview:button_]; | 64 [[test_window() contentView] addSubview:button_]; |
65 | 65 |
66 NSRect bounds = [button_ bounds]; | 66 NSRect bounds = [button_ bounds]; |
67 NSPoint mid_point = NSMakePoint(NSMidX(bounds), NSMidY(bounds)); | 67 NSPoint mid_point = NSMakePoint(NSMidX(bounds), NSMidY(bounds)); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 [NSApp postEvent:left_up_in_view atStart:YES]; | 303 [NSApp postEvent:left_up_in_view atStart:YES]; |
304 [NSApp postEvent:left_down_in_view atStart:YES]; | 304 [NSApp postEvent:left_down_in_view atStart:YES]; |
305 [button_ otherMouseDown:other_down_in_view]; | 305 [button_ otherMouseDown:other_down_in_view]; |
306 | 306 |
307 EXPECT_EQ(NSOffState, [button_ state]); | 307 EXPECT_EQ(NSOffState, [button_ state]); |
308 EXPECT_EQ(1, [button_ numOfClick]); | 308 EXPECT_EQ(1, [button_ numOfClick]); |
309 EXPECT_EQ(IDC_HOME, [button_ lastCommand]); | 309 EXPECT_EQ(IDC_HOME, [button_ lastCommand]); |
310 } | 310 } |
311 | 311 |
312 } // namespace | 312 } // namespace |
OLD | NEW |