Changeset View
Changeset View
Standalone View
Standalone View
head/www/chromium/files/patch-base_test_fontconfig__util__linux.cc
--- base/test/fontconfig_util_linux.cc.orig 2019-04-30 22:22:28 UTC | --- base/test/fontconfig_util_linux.cc.orig 2019-04-30 22:22:28 UTC | ||||
+++ base/test/fontconfig_util_linux.cc | +++ base/test/fontconfig_util_linux.cc | ||||
@@ -6,24 +6,397 @@ | @@ -6,22 +6,397 @@ | ||||
#include <fontconfig/fontconfig.h> | #include <fontconfig/fontconfig.h> | ||||
-#include <memory> | -#include <memory> | ||||
- | - | ||||
#include "base/base_paths.h" | #include "base/base_paths.h" | ||||
#include "base/environment.h" | #include "base/environment.h" | ||||
#include "base/files/file_path.h" | #include "base/files/file_path.h" | ||||
▲ Show 20 Lines • Show All 369 Lines • ▼ Show 20 Lines | |||||
+ FilePath dir_module; | + FilePath dir_module; | ||||
+ PathService::Get(DIR_MODULE, &dir_module); | + PathService::Get(DIR_MODULE, &dir_module); | ||||
+ FilePath font_cache = dir_module.Append("fontconfig_caches"); | + FilePath font_cache = dir_module.Append("fontconfig_caches"); | ||||
+ FilePath test_fonts = dir_module.Append("test_fonts"); | + FilePath test_fonts = dir_module.Append("test_fonts"); | ||||
+ std::string fonts_conf = ReplaceStringPlaceholders( | + std::string fonts_conf = ReplaceStringPlaceholders( | ||||
+ kFontsConfTemplate, {font_cache.value(), test_fonts.value()}, nullptr); | + kFontsConfTemplate, {font_cache.value(), test_fonts.value()}, nullptr); | ||||
- std::unique_ptr<Environment> env(Environment::Create()); | - std::unique_ptr<Environment> env(Environment::Create()); | ||||
- // TODO(thomasanderson): This still stat()'s the real /etc/fonts/fonts.conf. | |||||
- // Prevent fontconfig from doing this. | |||||
- CHECK(env->SetVar("FONTCONFIG_SYSROOT", dir_module.value().c_str())); | - CHECK(env->SetVar("FONTCONFIG_SYSROOT", dir_module.value().c_str())); | ||||
+ // Write the data to a different file and then atomically rename it to | + // Write the data to a different file and then atomically rename it to | ||||
+ // fonts.conf. This avoids the file being in a bad state when different | + // fonts.conf. This avoids the file being in a bad state when different | ||||
+ // parallel tests call this function at the same time. | + // parallel tests call this function at the same time. | ||||
+ FilePath fonts_conf_file_temp; | + FilePath fonts_conf_file_temp; | ||||
+ if(!CreateTemporaryFileInDir(dir_module, &fonts_conf_file_temp)) | + if(!CreateTemporaryFileInDir(dir_module, &fonts_conf_file_temp)) | ||||
+ CHECK(CreateTemporaryFile(&fonts_conf_file_temp)); | + CHECK(CreateTemporaryFile(&fonts_conf_file_temp)); | ||||
+ CHECK( | + CHECK( | ||||
Show All 10 Lines |