| 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 #include "ui/gfx/font.h" | 5 #include "ui/gfx/font.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 #if defined(OS_LINUX) | 10 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 11 #include <pango/pango.h> | 11 #include <pango/pango.h> |
| 12 #elif defined(OS_WIN) | 12 #elif defined(OS_WIN) |
| 13 #include "ui/gfx/platform_font_win.h" | 13 #include "ui/gfx/platform_font_win.h" |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 using gfx::Font; | 18 using gfx::Font; |
| 19 | 19 |
| 20 class FontTest : public testing::Test { | 20 class FontTest : public testing::Test { |
| 21 public: | 21 public: |
| 22 // Fulfills the memory management contract as outlined by the comment at | 22 // Fulfills the memory management contract as outlined by the comment at |
| 23 // gfx::Font::GetNativeFont(). | 23 // gfx::Font::GetNativeFont(). |
| 24 void FreeIfNecessary(gfx::NativeFont font) { | 24 void FreeIfNecessary(gfx::NativeFont font) { |
| 25 #if defined(OS_LINUX) | 25 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 26 pango_font_description_free(font); | 26 pango_font_description_free(font); |
| 27 #endif | 27 #endif |
| 28 } | 28 } |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 32 class ScopedMinimumFontSizeCallback { | 32 class ScopedMinimumFontSizeCallback { |
| 33 public: | 33 public: |
| 34 explicit ScopedMinimumFontSizeCallback(int minimum_size) { | 34 explicit ScopedMinimumFontSizeCallback(int minimum_size) { |
| 35 minimum_size_ = minimum_size; | 35 minimum_size_ = minimum_size; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 ScopedMinimumFontSizeCallback minimum_size(5); | 127 ScopedMinimumFontSizeCallback minimum_size(5); |
| 128 | 128 |
| 129 Font derived_font = cf.DeriveFont(-2); | 129 Font derived_font = cf.DeriveFont(-2); |
| 130 LOGFONT font_info; | 130 LOGFONT font_info; |
| 131 GetObject(derived_font.GetNativeFont(), sizeof(LOGFONT), &font_info); | 131 GetObject(derived_font.GetNativeFont(), sizeof(LOGFONT), &font_info); |
| 132 EXPECT_EQ(-6, font_info.lfHeight); | 132 EXPECT_EQ(-6, font_info.lfHeight); |
| 133 } | 133 } |
| 134 #endif // defined(OS_WIN) | 134 #endif // defined(OS_WIN) |
| 135 | 135 |
| 136 } // namespace | 136 } // namespace |
| OLD | NEW |