Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Unified Diff: ui/gfx/platform_font_win_unittest.cc

Issue 10228009: Fix CJK font linking size on Windows XP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/platform_font_win_unittest.cc
===================================================================
--- ui/gfx/platform_font_win_unittest.cc (revision 0)
+++ ui/gfx/platform_font_win_unittest.cc (revision 0)
@@ -0,0 +1,82 @@
+// 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.
+
+#include "ui/gfx/platform_font_win.h"
+
+#include "base/logging.h"
+#include "base/memory/ref_counted.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/font.h"
+
+namespace gfx {
+
+TEST(PlatformFontWinTest, DeriveFontWithHeight_SameHeight) {
msw 2012/04/26 21:04:42 optional: It'd be awesome if we could combine thes
Alexei Svitkine (slow) 2012/04/26 21:45:56 Done.
+ const Font font;
+ PlatformFontWin* platform_font =
+ static_cast<PlatformFontWin*>(font.platform_font());
+
+ Font derived_font =
+ platform_font->DeriveFontWithHeight(font.GetHeight(), font.GetStyle());
+ EXPECT_EQ(font.GetHeight(), derived_font.GetHeight());
+ EXPECT_EQ(font.GetStyle(), derived_font.GetStyle());
+
+ derived_font = platform_font->DeriveFontWithHeight(font.GetHeight(),
+ Font::BOLD);
+ EXPECT_EQ(font.GetHeight(), derived_font.GetHeight());
+ EXPECT_EQ(Font::BOLD, derived_font.GetStyle());
+}
+
+TEST(PlatformFontWinTest, DeriveFontWithHeight_Smaller) {
+ const Font base_font;
+
+ for (int i = 1; i < 10; i++) {
+ const int target_height = base_font.GetHeight() - i;
+
+ Font expected_font = base_font;
+ do {
+ expected_font = expected_font.DeriveFont(-1, 0);
msw 2012/04/26 21:04:42 This is slightly un-intuitive... can you explain i
Alexei Svitkine (slow) 2012/04/26 21:45:56 Added comments.
+ } while (expected_font.GetHeight() > target_height);
msw 2012/04/26 21:04:42 Should we [EXPECT|ASSERT]_LE(expected_font.GetHeig
Alexei Svitkine (slow) 2012/04/26 21:45:56 Done.
+
+ PlatformFontWin* platform_font =
+ static_cast<PlatformFontWin*>(base_font.platform_font());
+
+ Font derived_font = platform_font->DeriveFontWithHeight(target_height, 0);
+ EXPECT_EQ(expected_font.GetFontSize(), derived_font.GetFontSize());
msw 2012/04/26 21:04:42 Also EXPECT_LE(expected_font.GetHeight(), target_h
Alexei Svitkine (slow) 2012/04/26 21:45:56 Done.
+ EXPECT_EQ(0, derived_font.GetStyle());
+
+ derived_font = platform_font->DeriveFontWithHeight(target_height,
+ Font::BOLD);
+ EXPECT_EQ(expected_font.GetFontSize(), derived_font.GetFontSize());
msw 2012/04/26 21:04:42 Also EXPECT_LE(expected_font.GetHeight(), target_h
Alexei Svitkine (slow) 2012/04/26 21:45:56 Done.
+ EXPECT_EQ(Font::BOLD, derived_font.GetStyle());
+ }
+}
+
+TEST(PlatformFontWinTest, DeriveFontWithHeight_Larger) {
+ const Font base_font;
+
+ for (int i = 1; i < 10; i++) {
+ const int target_height = base_font.GetHeight() + i;
+
+ Font expected_font = base_font;
+ Font larger_font = base_font.DeriveFont(1, 0);
+ while (larger_font.GetHeight() <= target_height) {
+ expected_font = larger_font;
+ larger_font = larger_font.DeriveFont(1, 0);
+ }
msw 2012/04/26 21:04:42 Should we [EXPECT|ASSERT]_LE(expected_font.GetHeig
Alexei Svitkine (slow) 2012/04/26 21:45:56 Done.
+
+ PlatformFontWin* platform_font =
+ static_cast<PlatformFontWin*>(base_font.platform_font());
+
+ Font derived_font = platform_font->DeriveFontWithHeight(target_height, 0);
+ EXPECT_EQ(expected_font.GetFontSize(), derived_font.GetFontSize());
msw 2012/04/26 21:04:42 Also EXPECT_LE(expected_font.GetHeight(), target_h
Alexei Svitkine (slow) 2012/04/26 21:45:56 Done.
+ EXPECT_EQ(0, derived_font.GetStyle());
+
+ derived_font = platform_font->DeriveFontWithHeight(target_height,
+ Font::BOLD);
+ EXPECT_EQ(expected_font.GetFontSize(), derived_font.GetFontSize());
msw 2012/04/26 21:04:42 Also EXPECT_LE(expected_font.GetHeight(), target_h
Alexei Svitkine (slow) 2012/04/26 21:45:56 Done.
+ EXPECT_EQ(Font::BOLD, derived_font.GetStyle());
+ }
+}
+
+} // namespace gfx

Powered by Google App Engine
This is Rietveld 408576698