diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-08 21:08:56 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-08 21:08:56 +0000 |
commit | 718752f446cf0ef6d029e72d9f7c74656a782e09 (patch) | |
tree | c909edd335920bc46dcc945292f29ea4fce39b93 | |
parent | 736ae603876f0eb5a45611992981d695f2030685 (diff) | |
download | chromium_src-718752f446cf0ef6d029e72d9f7c74656a782e09.zip chromium_src-718752f446cf0ef6d029e72d9f7c74656a782e09.tar.gz chromium_src-718752f446cf0ef6d029e72d9f7c74656a782e09.tar.bz2 |
[Mac] Fix HoverImageButtonTest on Lion.
You cannot call |-drawRect:| without first having a context, provided by
|-lockFocus|. I tried calling |-display|, but calling that repeatedly without
having control return to an NSApplication-based runloop causes drawing to not
happen.
BUG=93926
TEST=unit_tests --gtest_filter=HoverImageButtonTest.* on 10.7
Review URL: https://chromiumcodereview.appspot.com/10386028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135907 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/cocoa/hover_image_button_unittest.mm | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/chrome/browser/ui/cocoa/hover_image_button_unittest.mm b/chrome/browser/ui/cocoa/hover_image_button_unittest.mm index 6b8ab0e..6e995ad 100644 --- a/chrome/browser/ui/cocoa/hover_image_button_unittest.mm +++ b/chrome/browser/ui/cocoa/hover_image_button_unittest.mm @@ -1,17 +1,15 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #import <Cocoa/Cocoa.h> -#include "base/mac/mac_util.h" #include "base/memory/scoped_nsobject.h" #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" #import "chrome/browser/ui/cocoa/hover_image_button.h" #include "grit/theme_resources.h" #include "grit/theme_resources_standard.h" #include "testing/gtest/include/gtest/gtest.h" -#include "testing/platform_test.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" @@ -27,13 +25,10 @@ class HoverImageButtonTest : public CocoaTest { [[test_window() contentView] addSubview:button_]; } - virtual void SetUp() { - CocoaTest::BootstrapCocoa(); - - // This test crashes when run on Lion. Fail early. - if (base::mac::IsOSLionOrLater()) { - FAIL() << "This test crashes on Lion; http://crbug.com/93926"; - } + void DrawRect() { + [button_ lockFocus]; + [button_ drawRect:[button_ bounds]]; + [button_ unlockFocus]; } HoverImageButton* button_; @@ -48,10 +43,11 @@ TEST_F(HoverImageButtonTest, ImageSwap) { [button_ setHoverImage:hover]; [button_ mouseEntered:nil]; - [button_ drawRect:[button_ frame]]; + DrawRect(); EXPECT_EQ([button_ image], hover); [button_ mouseExited:nil]; - [button_ drawRect:[button_ frame]]; + DrawRect(); + EXPECT_NE([button_ image], hover); EXPECT_EQ([button_ image], image); } @@ -65,10 +61,10 @@ TEST_F(HoverImageButtonTest, Opacity) { [button_ setHoverOpacity:1.0]; [button_ mouseEntered:nil]; - [button_ drawRect:[button_ frame]]; + DrawRect(); EXPECT_EQ([button_ alphaValue], 1.0); [button_ mouseExited:nil]; - [button_ drawRect:[button_ frame]]; + DrawRect(); EXPECT_EQ([button_ alphaValue], 0.5); } |