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

Side by Side 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, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/gfx/platform_font_win.h"
6
7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gfx/font.h"
11
12 namespace gfx {
13
14 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.
15 const Font font;
16 PlatformFontWin* platform_font =
17 static_cast<PlatformFontWin*>(font.platform_font());
18
19 Font derived_font =
20 platform_font->DeriveFontWithHeight(font.GetHeight(), font.GetStyle());
21 EXPECT_EQ(font.GetHeight(), derived_font.GetHeight());
22 EXPECT_EQ(font.GetStyle(), derived_font.GetStyle());
23
24 derived_font = platform_font->DeriveFontWithHeight(font.GetHeight(),
25 Font::BOLD);
26 EXPECT_EQ(font.GetHeight(), derived_font.GetHeight());
27 EXPECT_EQ(Font::BOLD, derived_font.GetStyle());
28 }
29
30 TEST(PlatformFontWinTest, DeriveFontWithHeight_Smaller) {
31 const Font base_font;
32
33 for (int i = 1; i < 10; i++) {
34 const int target_height = base_font.GetHeight() - i;
35
36 Font expected_font = base_font;
37 do {
38 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.
39 } 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.
40
41 PlatformFontWin* platform_font =
42 static_cast<PlatformFontWin*>(base_font.platform_font());
43
44 Font derived_font = platform_font->DeriveFontWithHeight(target_height, 0);
45 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.
46 EXPECT_EQ(0, derived_font.GetStyle());
47
48 derived_font = platform_font->DeriveFontWithHeight(target_height,
49 Font::BOLD);
50 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.
51 EXPECT_EQ(Font::BOLD, derived_font.GetStyle());
52 }
53 }
54
55 TEST(PlatformFontWinTest, DeriveFontWithHeight_Larger) {
56 const Font base_font;
57
58 for (int i = 1; i < 10; i++) {
59 const int target_height = base_font.GetHeight() + i;
60
61 Font expected_font = base_font;
62 Font larger_font = base_font.DeriveFont(1, 0);
63 while (larger_font.GetHeight() <= target_height) {
64 expected_font = larger_font;
65 larger_font = larger_font.DeriveFont(1, 0);
66 }
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.
67
68 PlatformFontWin* platform_font =
69 static_cast<PlatformFontWin*>(base_font.platform_font());
70
71 Font derived_font = platform_font->DeriveFontWithHeight(target_height, 0);
72 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.
73 EXPECT_EQ(0, derived_font.GetStyle());
74
75 derived_font = platform_font->DeriveFontWithHeight(target_height,
76 Font::BOLD);
77 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.
78 EXPECT_EQ(Font::BOLD, derived_font.GetStyle());
79 }
80 }
81
82 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698