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

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

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a lost comment and modify a render text unittest to not test black because of test env font con… Created 4 years, 6 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
« no previous file with comments | « ui/gfx/font_render_params_linux.cc ('k') | ui/gfx/font_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_render_params.h" 5 #include "ui/gfx/font_render_params.h"
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 11 matching lines...) Expand all
22 class TestFontDelegate : public LinuxFontDelegate { 22 class TestFontDelegate : public LinuxFontDelegate {
23 public: 23 public:
24 TestFontDelegate() {} 24 TestFontDelegate() {}
25 ~TestFontDelegate() override {} 25 ~TestFontDelegate() override {}
26 26
27 void set_params(const FontRenderParams& params) { params_ = params; } 27 void set_params(const FontRenderParams& params) { params_ = params; }
28 28
29 FontRenderParams GetDefaultFontRenderParams() const override { 29 FontRenderParams GetDefaultFontRenderParams() const override {
30 return params_; 30 return params_;
31 } 31 }
32 void GetDefaultFontDescription( 32 void GetDefaultFontDescription(std::string* family_out,
33 std::string* family_out, 33 int* size_pixels_out,
34 int* size_pixels_out, 34 bool* italic_out,
35 int* style_out, 35 Font::Weight* weight_out,
36 FontRenderParams* params_out) const override { 36 FontRenderParams* params_out) const override {
37 NOTIMPLEMENTED(); 37 NOTIMPLEMENTED();
38 } 38 }
39 39
40 private: 40 private:
41 FontRenderParams params_; 41 FontRenderParams params_;
42 42
43 DISALLOW_COPY_AND_ASSIGN(TestFontDelegate); 43 DISALLOW_COPY_AND_ASSIGN(TestFontDelegate);
44 }; 44 };
45 45
46 } // namespace 46 } // namespace
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 kFontconfigMatchFooter + 187 kFontconfigMatchFooter +
188 kFontconfigFileFooter)); 188 kFontconfigFileFooter));
189 189
190 FontRenderParamsQuery query; 190 FontRenderParamsQuery query;
191 query.style = Font::NORMAL; 191 query.style = Font::NORMAL;
192 FontRenderParams params = GetFontRenderParams(query, NULL); 192 FontRenderParams params = GetFontRenderParams(query, NULL);
193 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting); 193 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting);
194 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB, 194 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB,
195 params.subpixel_rendering); 195 params.subpixel_rendering);
196 196
197 query.style = Font::BOLD; 197 query.weight = Font::Weight::BOLD;
198 params = GetFontRenderParams(query, NULL); 198 params = GetFontRenderParams(query, NULL);
199 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting); 199 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting);
200 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE, 200 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE,
201 params.subpixel_rendering); 201 params.subpixel_rendering);
202 202
203 query.weight = Font::Weight::NORMAL;
203 query.style = Font::ITALIC; 204 query.style = Font::ITALIC;
204 params = GetFontRenderParams(query, NULL); 205 params = GetFontRenderParams(query, NULL);
205 EXPECT_EQ(FontRenderParams::HINTING_NONE, params.hinting); 206 EXPECT_EQ(FontRenderParams::HINTING_NONE, params.hinting);
206 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB, 207 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB,
207 params.subpixel_rendering); 208 params.subpixel_rendering);
208 209
209 query.style = Font::BOLD | Font::ITALIC; 210 query.weight = Font::Weight::BOLD;
211 query.style = Font::ITALIC;
210 params = GetFontRenderParams(query, NULL); 212 params = GetFontRenderParams(query, NULL);
211 EXPECT_EQ(FontRenderParams::HINTING_NONE, params.hinting); 213 EXPECT_EQ(FontRenderParams::HINTING_NONE, params.hinting);
212 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE, 214 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE,
213 params.subpixel_rendering); 215 params.subpixel_rendering);
214 } 216 }
215 217
216 TEST_F(FontRenderParamsTest, Scalable) { 218 TEST_F(FontRenderParamsTest, Scalable) {
217 // Load a config that only enables antialiasing for scalable fonts. 219 // Load a config that only enables antialiasing for scalable fonts.
218 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), 220 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
219 std::string(kFontconfigFileHeader) + 221 std::string(kFontconfigFileHeader) +
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 EXPECT_EQ("Verdana", suggested_family); 379 EXPECT_EQ("Verdana", suggested_family);
378 380
379 query.families.clear(); 381 query.families.clear();
380 query.families.push_back("Arial"); 382 query.families.push_back("Arial");
381 suggested_family.clear(); 383 suggested_family.clear();
382 GetFontRenderParams(query, &suggested_family); 384 GetFontRenderParams(query, &suggested_family);
383 EXPECT_EQ("Verdana", suggested_family); 385 EXPECT_EQ("Verdana", suggested_family);
384 } 386 }
385 387
386 } // namespace gfx 388 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_render_params_linux.cc ('k') | ui/gfx/font_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698