summaryrefslogtreecommitdiffstats
path: root/ui/gfx/font_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gfx/font_unittest.cc')
-rw-r--r--ui/gfx/font_unittest.cc30
1 files changed, 23 insertions, 7 deletions
diff --git a/ui/gfx/font_unittest.cc b/ui/gfx/font_unittest.cc
index d5854c0..7ea01db 100644
--- a/ui/gfx/font_unittest.cc
+++ b/ui/gfx/font_unittest.cc
@@ -1,20 +1,31 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
#include "ui/gfx/font.h"
#include "base/utf_string_conversions.h"
-#if defined(OS_WIN)
-#include "ui/gfx/platform_font_win.h"
-#endif // defined(OS_WIN)
#include "testing/gtest/include/gtest/gtest.h"
+#if defined(OS_LINUX)
+#include <pango/pango.h>
+#elif defined(OS_WIN)
+#include "ui/gfx/platform_font_win.h"
+#endif
+
namespace {
using gfx::Font;
class FontTest : public testing::Test {
+ public:
+ // Fulfills the memory management contract as outlined by the comment at
+ // gfx::Font::GetNativeFont().
+ void FreeIfNecessary(gfx::NativeFont font) {
+#if defined(OS_LINUX)
+ pango_font_description_free(font);
+#endif
+ }
};
#if defined(OS_WIN)
@@ -47,17 +58,21 @@ int ScopedMinimumFontSizeCallback::minimum_size_ = 0;
TEST_F(FontTest, LoadArial) {
Font cf(ASCIIToUTF16("Arial"), 16);
- ASSERT_TRUE(cf.GetNativeFont());
+ gfx::NativeFont native = cf.GetNativeFont();
+ ASSERT_TRUE(native);
ASSERT_EQ(cf.GetStyle(), Font::NORMAL);
ASSERT_EQ(cf.GetFontSize(), 16);
ASSERT_EQ(cf.GetFontName(), ASCIIToUTF16("Arial"));
+ FreeIfNecessary(native);
}
TEST_F(FontTest, LoadArialBold) {
Font cf(ASCIIToUTF16("Arial"), 16);
Font bold(cf.DeriveFont(0, Font::BOLD));
- ASSERT_TRUE(bold.GetNativeFont());
+ gfx::NativeFont native = bold.GetNativeFont();
+ ASSERT_TRUE(native);
ASSERT_EQ(bold.GetStyle(), Font::BOLD);
+ FreeIfNecessary(native);
}
TEST_F(FontTest, Ascent) {
@@ -116,5 +131,6 @@ TEST_F(FontTest, DeriveFontKeepsOriginalSizeIfHeightOk) {
GetObject(derived_font.GetNativeFont(), sizeof(LOGFONT), &font_info);
EXPECT_EQ(-6, font_info.lfHeight);
}
-#endif
+#endif // defined(OS_WIN)
+
} // namespace