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
3 // found in the LICENSE file.
5 #import "ui/base/cocoa/hover_image_button.h"
7 #import "base/memory/scoped_nsobject.h"
8 #import "ui/base/test/ui_cocoa_test_helper.h"
12 class HoverImageButtonTest : public ui::CocoaTest {
14 HoverImageButtonTest() {
15 NSRect content_frame = [[test_window() contentView] frame];
16 scoped_nsobject<HoverImageButton> button(
17 [[HoverImageButton alloc] initWithFrame:content_frame]);
18 button_ = button.get();
19 [[test_window() contentView] addSubview:button_];
24 [button_ drawRect:[button_ bounds]];
25 [button_ unlockFocus];
28 HoverImageButton* button_;
32 TEST_F(HoverImageButtonTest, ImageSwap) {
33 NSImage* image = [NSImage imageNamed:NSImageNameStatusAvailable];
34 NSImage* hover = [NSImage imageNamed:NSImageNameStatusNone];
35 [button_ setDefaultImage:image];
36 [button_ setHoverImage:hover];
38 [button_ mouseEntered:nil];
40 EXPECT_EQ([button_ image], hover);
41 [button_ mouseExited:nil];
43 EXPECT_NE([button_ image], hover);
44 EXPECT_EQ([button_ image], image);