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

Side by Side Diff: ui/gfx/platform_font_win_unittest.cc

Issue 1513043002: clang/win: Let remaining chromium_code targets build with -Wextra. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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
« no previous file with comments | « ui/gfx/icon_util_unittest.cc ('k') | ui/gfx/range/range_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/platform_font_win.h" 5 #include "ui/gfx/platform_font_win.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 {base::ASCIIToUTF16("Tahoma"), 10}, 120 {base::ASCIIToUTF16("Tahoma"), 10},
121 {base::ASCIIToUTF16("Tahoma"), 16}, 121 {base::ASCIIToUTF16("Tahoma"), 16},
122 {base::ASCIIToUTF16("Segoe UI"), 6}, 122 {base::ASCIIToUTF16("Segoe UI"), 6},
123 {base::ASCIIToUTF16("Segoe UI"), 8}, 123 {base::ASCIIToUTF16("Segoe UI"), 8},
124 {base::ASCIIToUTF16("Segoe UI"), 20}, 124 {base::ASCIIToUTF16("Segoe UI"), 20},
125 }; 125 };
126 126
127 base::win::ScopedGetDC screen_dc(NULL); 127 base::win::ScopedGetDC screen_dc(NULL);
128 gfx::ScopedSetMapMode mode(screen_dc, MM_TEXT); 128 gfx::ScopedSetMapMode mode(screen_dc, MM_TEXT);
129 129
130 for (int i = 0; i < arraysize(fonts); ++i) { 130 for (const FontInfo& font : fonts) {
131 LOGFONT font_info = {0}; 131 LOGFONT font_info = {0};
132 132
133 font_info.lfHeight = -fonts[i].font_size; 133 font_info.lfHeight = -font.font_size;
134 font_info.lfWeight = FW_NORMAL; 134 font_info.lfWeight = FW_NORMAL;
135 wcscpy_s(font_info.lfFaceName, 135 wcscpy_s(font_info.lfFaceName, font.font_name.length() + 1,
136 fonts[i].font_name.length() + 1, 136 font.font_name.c_str());
137 fonts[i].font_name.c_str());
138 137
139 HFONT font = CreateFontIndirect(&font_info); 138 HFONT hFont = CreateFontIndirect(&font_info);
140 139
141 TEXTMETRIC font_metrics; 140 TEXTMETRIC font_metrics;
142 PlatformFontWin::GetTextMetricsForFont(screen_dc, font, &font_metrics); 141 PlatformFontWin::GetTextMetricsForFont(screen_dc, hFont, &font_metrics);
143 142
144 scoped_refptr<PlatformFontWin::HFontRef> h_font_gdi( 143 scoped_refptr<PlatformFontWin::HFontRef> h_font_gdi(
145 PlatformFontWin::CreateHFontRefFromGDI(font, font_metrics)); 144 PlatformFontWin::CreateHFontRefFromGDI(hFont, font_metrics));
146 145
147 scoped_refptr<PlatformFontWin::HFontRef> h_font_skia( 146 scoped_refptr<PlatformFontWin::HFontRef> h_font_skia(
148 PlatformFontWin::CreateHFontRefFromSkia(font, font_metrics)); 147 PlatformFontWin::CreateHFontRefFromSkia(hFont, font_metrics));
149 148
150 EXPECT_EQ(h_font_gdi->font_size(), h_font_skia->font_size()); 149 EXPECT_EQ(h_font_gdi->font_size(), h_font_skia->font_size());
151 EXPECT_EQ(h_font_gdi->style(), h_font_skia->style()); 150 EXPECT_EQ(h_font_gdi->style(), h_font_skia->style());
152 EXPECT_EQ(h_font_gdi->font_name(), h_font_skia->font_name()); 151 EXPECT_EQ(h_font_gdi->font_name(), h_font_skia->font_name());
153 EXPECT_EQ(h_font_gdi->ave_char_width(), h_font_skia->ave_char_width()); 152 EXPECT_EQ(h_font_gdi->ave_char_width(), h_font_skia->ave_char_width());
154 153
155 EXPECT_LE(abs(h_font_gdi->cap_height() - h_font_skia->cap_height()), 1); 154 EXPECT_LE(abs(h_font_gdi->cap_height() - h_font_skia->cap_height()), 1);
156 EXPECT_LE(abs(h_font_gdi->baseline() - h_font_skia->baseline()), 1); 155 EXPECT_LE(abs(h_font_gdi->baseline() - h_font_skia->baseline()), 1);
157 EXPECT_LE(abs(h_font_gdi->height() - h_font_skia->height()), 1); 156 EXPECT_LE(abs(h_font_gdi->height() - h_font_skia->height()), 1);
158 } 157 }
(...skipping 19 matching lines...) Expand all
178 177
179 FontInfo fonts[] = { 178 FontInfo fonts[] = {
180 {base::ASCIIToUTF16("MS Shell Dlg"), "Microsoft Sans Serif"}, 179 {base::ASCIIToUTF16("MS Shell Dlg"), "Microsoft Sans Serif"},
181 {base::ASCIIToUTF16("MS Shell Dlg 2"), "Tahoma"}, 180 {base::ASCIIToUTF16("MS Shell Dlg 2"), "Tahoma"},
182 {base::ASCIIToUTF16("FooBar"), "Arial"}, 181 {base::ASCIIToUTF16("FooBar"), "Arial"},
183 }; 182 };
184 183
185 base::win::ScopedGetDC screen_dc(NULL); 184 base::win::ScopedGetDC screen_dc(NULL);
186 gfx::ScopedSetMapMode mode(screen_dc, MM_TEXT); 185 gfx::ScopedSetMapMode mode(screen_dc, MM_TEXT);
187 186
188 for (int i = 0; i < arraysize(fonts); ++i) { 187 for (const FontInfo& font : fonts) {
189 LOGFONT font_info = {0}; 188 LOGFONT font_info = {0};
190 189
191 font_info.lfHeight = -10; 190 font_info.lfHeight = -10;
192 font_info.lfWeight = FW_NORMAL; 191 font_info.lfWeight = FW_NORMAL;
193 wcscpy_s(font_info.lfFaceName, 192 wcscpy_s(font_info.lfFaceName, font.font_name.length() + 1,
194 fonts[i].font_name.length() + 1, 193 font.font_name.c_str());
195 fonts[i].font_name.c_str());
196 194
197 HFONT font = CreateFontIndirect(&font_info); 195 HFONT hFont = CreateFontIndirect(&font_info);
198 196
199 TEXTMETRIC font_metrics; 197 TEXTMETRIC font_metrics;
200 PlatformFontWin::GetTextMetricsForFont(screen_dc, font, &font_metrics); 198 PlatformFontWin::GetTextMetricsForFont(screen_dc, hFont, &font_metrics);
201 199
202 scoped_refptr<PlatformFontWin::HFontRef> h_font_skia( 200 scoped_refptr<PlatformFontWin::HFontRef> h_font_skia(
203 PlatformFontWin::CreateHFontRefFromSkia(font, font_metrics)); 201 PlatformFontWin::CreateHFontRefFromSkia(hFont, font_metrics));
204 202
205 EXPECT_EQ(fonts[i].expected_font_name, h_font_skia->font_name()); 203 EXPECT_EQ(font.expected_font_name, h_font_skia->font_name());
206 } 204 }
207 } 205 }
208 206
209 } // namespace gfx 207 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/icon_util_unittest.cc ('k') | ui/gfx/range/range_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698