OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/controls/hover_image_menu_button.h" | 5 #import "ui/base/cocoa/controls/hover_image_menu_button.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #import "testing/gtest_mac.h" | 8 #import "testing/gtest_mac.h" |
9 #import "ui/base/cocoa/controls/hover_image_menu_button_cell.h" | 9 #import "ui/base/cocoa/controls/hover_image_menu_button_cell.h" |
10 #import "ui/base/test/ui_cocoa_test_helper.h" | 10 #import "ui/base/test/ui_cocoa_test_helper.h" |
11 | 11 |
12 namespace ui { | 12 namespace ui { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 // Test initialization and display of the NSPopUpButton that shows the drop- | 16 // Test initialization and display of the NSPopUpButton that shows the drop- |
17 // down menu. Don't try to show the menu, since it will block the thread. | 17 // down menu. Don't try to show the menu, since it will block the thread. |
18 class HoverImageMenuButtonTest : public CocoaTest { | 18 class HoverImageMenuButtonTest : public CocoaTest { |
19 public: | 19 public: |
20 HoverImageMenuButtonTest() {} | 20 HoverImageMenuButtonTest() {} |
21 | 21 |
22 // CocoaTest override: | 22 // CocoaTest override: |
23 virtual void SetUp() OVERRIDE; | 23 virtual void SetUp() OVERRIDE; |
24 | 24 |
25 protected: | 25 protected: |
26 scoped_nsobject<HoverImageMenuButton> menu_button_; | 26 base::scoped_nsobject<HoverImageMenuButton> menu_button_; |
27 scoped_nsobject<NSImage> normal_; | 27 base::scoped_nsobject<NSImage> normal_; |
28 scoped_nsobject<NSImage> pressed_; | 28 base::scoped_nsobject<NSImage> pressed_; |
29 scoped_nsobject<NSImage> hovered_; | 29 base::scoped_nsobject<NSImage> hovered_; |
30 | 30 |
31 DISALLOW_COPY_AND_ASSIGN(HoverImageMenuButtonTest); | 31 DISALLOW_COPY_AND_ASSIGN(HoverImageMenuButtonTest); |
32 }; | 32 }; |
33 | 33 |
34 void HoverImageMenuButtonTest::SetUp() { | 34 void HoverImageMenuButtonTest::SetUp() { |
35 menu_button_.reset( | 35 menu_button_.reset( |
36 [[HoverImageMenuButton alloc] initWithFrame:NSMakeRect(0, 0, 50, 30) | 36 [[HoverImageMenuButton alloc] initWithFrame:NSMakeRect(0, 0, 50, 30) |
37 pullsDown:YES]); | 37 pullsDown:YES]); |
38 | 38 |
39 normal_.reset([base::mac::ObjCCastStrict<NSImage>( | 39 normal_.reset([base::mac::ObjCCastStrict<NSImage>( |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 EXPECT_FALSE([menu_button_ needsDisplay]); | 164 EXPECT_FALSE([menu_button_ needsDisplay]); |
165 | 165 |
166 [menu_button_ mouseExited:nil]; | 166 [menu_button_ mouseExited:nil]; |
167 EXPECT_TRUE([menu_button_ needsDisplay]); | 167 EXPECT_TRUE([menu_button_ needsDisplay]); |
168 EXPECT_NSEQ(normal_, [[menu_button_ cell] imageToDraw]); | 168 EXPECT_NSEQ(normal_, [[menu_button_ cell] imageToDraw]); |
169 [menu_button_ display]; | 169 [menu_button_ display]; |
170 EXPECT_FALSE([menu_button_ needsDisplay]); | 170 EXPECT_FALSE([menu_button_ needsDisplay]); |
171 } | 171 } |
172 | 172 |
173 } // namespace ui | 173 } // namespace ui |
OLD | NEW |