OLD | NEW |
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/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 std::string suggested_family; | 280 std::string suggested_family; |
281 FontRenderParams params = GetFontRenderParams(query, &suggested_family); | 281 FontRenderParams params = GetFontRenderParams(query, &suggested_family); |
282 | 282 |
283 // The system params and the first requested family should be returned. | 283 // The system params and the first requested family should be returned. |
284 EXPECT_EQ(system_params.antialiasing, params.antialiasing); | 284 EXPECT_EQ(system_params.antialiasing, params.antialiasing); |
285 EXPECT_EQ(system_params.hinting, params.hinting); | 285 EXPECT_EQ(system_params.hinting, params.hinting); |
286 EXPECT_EQ(system_params.subpixel_rendering, params.subpixel_rendering); | 286 EXPECT_EQ(system_params.subpixel_rendering, params.subpixel_rendering); |
287 EXPECT_EQ(query.families[0], suggested_family); | 287 EXPECT_EQ(query.families[0], suggested_family); |
288 } | 288 } |
289 | 289 |
| 290 TEST_F(FontRenderParamsTest, MissingFamily) { |
| 291 // With Arial and Verdana installed, request (in order) Helvetica, Arial, and |
| 292 // Verdana and check that Arial is returned. |
| 293 ASSERT_TRUE(LoadSystemFont("arial.ttf")); |
| 294 ASSERT_TRUE(LoadSystemFont("verdana.ttf")); |
| 295 FontRenderParamsQuery query(false); |
| 296 query.families.push_back("Helvetica"); |
| 297 query.families.push_back("Arial"); |
| 298 query.families.push_back("Verdana"); |
| 299 std::string suggested_family; |
| 300 GetFontRenderParams(query, &suggested_family); |
| 301 EXPECT_EQ("Arial", suggested_family); |
| 302 } |
| 303 |
| 304 TEST_F(FontRenderParamsTest, SubstituteFamily) { |
| 305 // Configure Fontconfig to use Verdana for both Helvetica and Arial. |
| 306 ASSERT_TRUE(LoadSystemFont("arial.ttf")); |
| 307 ASSERT_TRUE(LoadSystemFont("verdana.ttf")); |
| 308 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), |
| 309 std::string(kFontconfigFileHeader) + |
| 310 CreateFontconfigAliasStanza("Helvetica", "Verdana") + |
| 311 kFontconfigMatchHeader + |
| 312 CreateFontconfigTestStanza("family", "eq", "string", "Arial") + |
| 313 CreateFontconfigEditStanza("family", "string", "Verdana") + |
| 314 kFontconfigMatchFooter + |
| 315 kFontconfigFileFooter)); |
| 316 |
| 317 FontRenderParamsQuery query(false); |
| 318 query.families.push_back("Helvetica"); |
| 319 std::string suggested_family; |
| 320 GetFontRenderParams(query, &suggested_family); |
| 321 EXPECT_EQ("Verdana", suggested_family); |
| 322 |
| 323 query.families.clear(); |
| 324 query.families.push_back("Arial"); |
| 325 suggested_family.clear(); |
| 326 GetFontRenderParams(query, &suggested_family); |
| 327 EXPECT_EQ("Verdana", suggested_family); |
| 328 } |
| 329 |
290 } // namespace gfx | 330 } // namespace gfx |
OLD | NEW |