OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/base/cocoa/hover_image_button.h" | 5 #import "ui/base/cocoa/hover_image_button.h" |
6 | 6 |
7 #import "base/memory/scoped_nsobject.h" | 7 #import "base/mac/scoped_nsobject.h" |
8 #import "ui/base/test/ui_cocoa_test_helper.h" | 8 #import "ui/base/test/ui_cocoa_test_helper.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 | 11 |
12 class HoverImageButtonTest : public ui::CocoaTest { | 12 class HoverImageButtonTest : public ui::CocoaTest { |
13 public: | 13 public: |
14 HoverImageButtonTest() { | 14 HoverImageButtonTest() { |
15 NSRect content_frame = [[test_window() contentView] frame]; | 15 NSRect content_frame = [[test_window() contentView] frame]; |
16 scoped_nsobject<HoverImageButton> button( | 16 base::scoped_nsobject<HoverImageButton> button( |
17 [[HoverImageButton alloc] initWithFrame:content_frame]); | 17 [[HoverImageButton alloc] initWithFrame:content_frame]); |
18 button_ = button.get(); | 18 button_ = button.get(); |
19 [[test_window() contentView] addSubview:button_]; | 19 [[test_window() contentView] addSubview:button_]; |
20 } | 20 } |
21 | 21 |
22 void DrawRect() { | 22 void DrawRect() { |
23 [button_ lockFocus]; | 23 [button_ lockFocus]; |
24 [button_ drawRect:[button_ bounds]]; | 24 [button_ drawRect:[button_ bounds]]; |
25 [button_ unlockFocus]; | 25 [button_ unlockFocus]; |
26 } | 26 } |
(...skipping 11 matching lines...) Expand all Loading... |
38 [button_ mouseEntered:nil]; | 38 [button_ mouseEntered:nil]; |
39 DrawRect(); | 39 DrawRect(); |
40 EXPECT_EQ([button_ image], hover); | 40 EXPECT_EQ([button_ image], hover); |
41 [button_ mouseExited:nil]; | 41 [button_ mouseExited:nil]; |
42 DrawRect(); | 42 DrawRect(); |
43 EXPECT_NE([button_ image], hover); | 43 EXPECT_NE([button_ image], hover); |
44 EXPECT_EQ([button_ image], image); | 44 EXPECT_EQ([button_ image], image); |
45 } | 45 } |
46 | 46 |
47 } // namespace | 47 } // namespace |
OLD | NEW |