Revert of Output closure-compiled JavaScript files (patchset #10 id:180001 of https...
[chromium-blink-merge.git] / ui / base / cocoa / hover_image_button_unittest.mm
blob0dff3fc823cd2c2a9a8bc7eb168242d48b5ece16
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/mac/scoped_nsobject.h"
8 #import "ui/gfx/test/ui_cocoa_test_helper.h"
10 namespace {
12 class HoverImageButtonTest : public ui::CocoaTest {
13  public:
14   HoverImageButtonTest() {
15     NSRect content_frame = [[test_window() contentView] frame];
16     base::scoped_nsobject<HoverImageButton> button(
17         [[HoverImageButton alloc] initWithFrame:content_frame]);
18     button_ = button.get();
19     [[test_window() contentView] addSubview:button_];
20   }
22   void DrawRect() {
23     [button_ lockFocus];
24     [button_ drawRect:[button_ bounds]];
25     [button_ unlockFocus];
26   }
28   HoverImageButton* button_;
31 // Test mouse events.
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];
39   DrawRect();
40   EXPECT_EQ([button_ image], hover);
41   [button_ mouseExited:nil];
42   DrawRect();
43   EXPECT_NE([button_ image], hover);
44   EXPECT_EQ([button_ image], image);
47 }  // namespace