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 #include "base/mac/mac_util.h" |
7 #include "base/memory/scoped_nsobject.h" | 8 #include "base/memory/scoped_nsobject.h" |
8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
9 #import "chrome/browser/ui/cocoa/hover_image_button.h" | 10 #import "chrome/browser/ui/cocoa/hover_image_button.h" |
10 #include "grit/theme_resources.h" | 11 #include "grit/theme_resources.h" |
11 #include "grit/theme_resources_standard.h" | 12 #include "grit/theme_resources_standard.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
14 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
15 #include "ui/gfx/image/image.h" | 16 #include "ui/gfx/image/image.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 class HoverImageButtonTest : public CocoaTest { | 20 class HoverImageButtonTest : public CocoaTest { |
20 public: | 21 public: |
21 HoverImageButtonTest() { | 22 HoverImageButtonTest() { |
22 NSRect content_frame = [[test_window() contentView] frame]; | 23 NSRect content_frame = [[test_window() contentView] frame]; |
23 scoped_nsobject<HoverImageButton> button( | 24 scoped_nsobject<HoverImageButton> button( |
24 [[HoverImageButton alloc] initWithFrame:content_frame]); | 25 [[HoverImageButton alloc] initWithFrame:content_frame]); |
25 button_ = button.get(); | 26 button_ = button.get(); |
26 [[test_window() contentView] addSubview:button_]; | 27 [[test_window() contentView] addSubview:button_]; |
27 } | 28 } |
28 | 29 |
29 virtual void SetUp() { | 30 virtual void SetUp() { |
30 CocoaTest::BootstrapCocoa(); | 31 CocoaTest::BootstrapCocoa(); |
| 32 |
| 33 // This test crashes when run on Lion. Fail early. |
| 34 if (base::mac::IsOSLionOrLater()) { |
| 35 FAIL() << "This test crashes on Lion; http://crbug.com/93926"; |
| 36 } |
31 } | 37 } |
32 | 38 |
33 HoverImageButton* button_; | 39 HoverImageButton* button_; |
34 }; | 40 }; |
35 | 41 |
36 // Test mouse events. | 42 // Test mouse events. |
37 TEST_F(HoverImageButtonTest, ImageSwap) { | 43 TEST_F(HoverImageButtonTest, ImageSwap) { |
38 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 44 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
39 NSImage* image = rb.GetNativeImageNamed(IDR_HOME); | 45 NSImage* image = rb.GetNativeImageNamed(IDR_HOME); |
40 NSImage* hover = rb.GetNativeImageNamed(IDR_BACK); | 46 NSImage* hover = rb.GetNativeImageNamed(IDR_BACK); |
(...skipping 19 matching lines...) Expand all Loading... |
60 | 66 |
61 [button_ mouseEntered:nil]; | 67 [button_ mouseEntered:nil]; |
62 [button_ drawRect:[button_ frame]]; | 68 [button_ drawRect:[button_ frame]]; |
63 EXPECT_EQ([button_ alphaValue], 1.0); | 69 EXPECT_EQ([button_ alphaValue], 1.0); |
64 [button_ mouseExited:nil]; | 70 [button_ mouseExited:nil]; |
65 [button_ drawRect:[button_ frame]]; | 71 [button_ drawRect:[button_ frame]]; |
66 EXPECT_EQ([button_ alphaValue], 0.5); | 72 EXPECT_EQ([button_ alphaValue], 0.5); |
67 } | 73 } |
68 | 74 |
69 } // namespace | 75 } // namespace |
OLD | NEW |