diff options
author | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-06 22:56:47 +0000 |
---|---|---|
committer | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-06 22:56:47 +0000 |
commit | 5b3a7e96fdd94ef0a7f8d375e8b88babcfe5fcc4 (patch) | |
tree | 4ba52dd8f508efb0f6bc4e8bc06e28a4fb36eba3 /gfx/font_unittest.cc | |
parent | 0e6d874af53c7d08ad8a2eafd3e3e7ae8ba563af (diff) | |
download | chromium_src-5b3a7e96fdd94ef0a7f8d375e8b88babcfe5fcc4.zip chromium_src-5b3a7e96fdd94ef0a7f8d375e8b88babcfe5fcc4.tar.gz chromium_src-5b3a7e96fdd94ef0a7f8d375e8b88babcfe5fcc4.tar.bz2 |
Fix gfx unit-tests so they do not crash on Windows, prior to Windows 7
Also fix failing Font test.
TEST=unit tests
BUG=46733
Review URL: http://codereview.chromium.org/3615001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61725 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx/font_unittest.cc')
-rw-r--r-- | gfx/font_unittest.cc | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/gfx/font_unittest.cc b/gfx/font_unittest.cc index d2eda1c..1cf1b11 100644 --- a/gfx/font_unittest.cc +++ b/gfx/font_unittest.cc @@ -4,6 +4,9 @@ #include "gfx/font.h" +#if defined(OS_WIN) +#include "gfx/platform_font_win.h" +#endif // defined(OS_WIN) #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -13,6 +16,34 @@ using gfx::Font; class FontTest : public testing::Test { }; +#if defined(OS_WIN) +class ScopedMinimumFontSizeCallback { + public: + explicit ScopedMinimumFontSizeCallback(int minimum_size) { + minimum_size_ = minimum_size; + old_callback_ = gfx::PlatformFontWin::get_minimum_font_size_callback; + gfx::PlatformFontWin::get_minimum_font_size_callback = &GetMinimumFontSize; + } + + ~ScopedMinimumFontSizeCallback() { + gfx::PlatformFontWin::get_minimum_font_size_callback = old_callback_; + } + + private: + static int GetMinimumFontSize() { + return minimum_size_; + } + + gfx::PlatformFontWin::GetMinimumFontSizeCallback old_callback_; + static int minimum_size_; + + DISALLOW_COPY_AND_ASSIGN(ScopedMinimumFontSizeCallback); +}; + +int ScopedMinimumFontSizeCallback::minimum_size_ = 0; +#endif // defined(OS_WIN) + + TEST_F(FontTest, LoadArial) { Font cf(L"Arial", 16); ASSERT_TRUE(cf.GetNativeFont()); @@ -58,10 +89,12 @@ TEST_F(FontTest, Widths) { } #if defined(OS_WIN) -// http://crbug.com/46733 -TEST_F(FontTest, FAILS_DeriveFontResizesIfSizeTooSmall) { +TEST_F(FontTest, DeriveFontResizesIfSizeTooSmall) { // This creates font of height -8. Font cf(L"Arial", 6); + // The minimum font size is set to 5 in browser_main.cc. + ScopedMinimumFontSizeCallback minimum_size(5); + Font derived_font = cf.DeriveFont(-4); LOGFONT font_info; GetObject(derived_font.GetNativeFont(), sizeof(LOGFONT), &font_info); @@ -71,6 +104,9 @@ TEST_F(FontTest, FAILS_DeriveFontResizesIfSizeTooSmall) { TEST_F(FontTest, DeriveFontKeepsOriginalSizeIfHeightOk) { // This creates font of height -8. Font cf(L"Arial", 6); + // The minimum font size is set to 5 in browser_main.cc. + ScopedMinimumFontSizeCallback minimum_size(5); + Font derived_font = cf.DeriveFont(-2); LOGFONT font_info; GetObject(derived_font.GetNativeFont(), sizeof(LOGFONT), &font_info); |