0

misc files R-U: Change ScopedTempDir::path() to GetPath()

path() is being deprecated, GetPath() has better checking against wrong use.

For more context, see https://codereview.chromium.org/2275553005/.

BUG=640599
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.win:win10_chromium_x64_rel_ng

Review-Url: https://codereview.chromium.org/2317123003
Cr-Commit-Position: refs/heads/master@{#421483}
This commit is contained in:
vabr
2016-09-28 01:44:50 -07:00
committed by Commit bot
parent 8db1c398f8
commit a98198273f
22 changed files with 163 additions and 164 deletions

@ -44,13 +44,13 @@ class HostConfigTest : public testing::Test {
TEST_F(HostConfigTest, InvalidFile) {
ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
base::FilePath non_existent_file =
test_dir_.path().AppendASCII("non_existent.json");
test_dir_.GetPath().AppendASCII("non_existent.json");
EXPECT_FALSE(HostConfigFromJsonFile(non_existent_file));
}
TEST_F(HostConfigTest, Read) {
ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
base::FilePath test_file = test_dir_.path().AppendASCII("read.json");
base::FilePath test_file = test_dir_.GetPath().AppendASCII("read.json");
WriteTestFile(test_file);
std::unique_ptr<base::DictionaryValue> target(
HostConfigFromJsonFile(test_file));
@ -74,7 +74,7 @@ TEST_F(HostConfigTest, Read) {
TEST_F(HostConfigTest, Write) {
ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
base::FilePath test_file = test_dir_.path().AppendASCII("write.json");
base::FilePath test_file = test_dir_.GetPath().AppendASCII("write.json");
WriteTestFile(test_file);
std::unique_ptr<base::DictionaryValue> target(
HostConfigFromJsonFile(test_file));

@ -30,7 +30,7 @@ class AudioPipeReaderTest : public testing::Test,
void SetUp() override {
ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
pipe_path_ = test_dir_.path().AppendASCII("test_pipe");
pipe_path_ = test_dir_.GetPath().AppendASCII("test_pipe");
audio_thread_.reset(new base::Thread("TestAudioThread"));
audio_thread_->StartWithOptions(
base::Thread::Options(base::MessageLoop::TYPE_IO, 0));

@ -32,7 +32,7 @@ class CertificateWatcherTest : public testing::Test {
base::Unretained(this)),
task_runner_));
watcher_->SetDelayForTests(base::TimeDelta::FromSeconds(0));
watcher_->SetWatchPathForTests(temp_dir_.path());
watcher_->SetWatchPathForTests(temp_dir_.GetPath());
}
~CertificateWatcherTest() override {
@ -84,7 +84,7 @@ class CertificateWatcherTest : public testing::Test {
void TouchFileTask(const char* filename) {
std::string testWriteString = std::to_string(rand());
base::FilePath path = temp_dir_.path().AppendASCII(filename);
base::FilePath path = temp_dir_.GetPath().AppendASCII(filename);
if (base::PathExists(path)) {
EXPECT_TRUE(base::AppendToFile(path, testWriteString.c_str(),

@ -58,7 +58,7 @@ class SecurityKeyAuthHandlerPosixTest : public testing::Test {
: run_loop_(new base::RunLoop()),
file_thread_("SecurityKeyAuthHandlerPosixTest_FileThread") {
EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
socket_path_ = temp_dir_.path().Append(kSocketFilename);
socket_path_ = temp_dir_.GetPath().Append(kSocketFilename);
remoting::SecurityKeyAuthHandler::SetSecurityKeySocketName(socket_path_);
EXPECT_TRUE(file_thread_.StartWithOptions(

@ -847,8 +847,8 @@ class ReadonlyRlzDirectoryTest : public RlzLibTestNoMachineState {
void ReadonlyRlzDirectoryTest::SetUp() {
RlzLibTestNoMachineState::SetUp();
// Make the rlz directory non-writeable.
int chmod_result = chmod(m_rlz_test_helper_.temp_dir_.path().value().c_str(),
0500);
int chmod_result =
chmod(m_rlz_test_helper_.temp_dir_.GetPath().value().c_str(), 0500);
ASSERT_EQ(0, chmod_result);
}

@ -137,7 +137,7 @@ void RlzLibTestNoMachineStateHelper::SetUp() {
#endif // defined(OS_WIN)
#if defined(OS_POSIX)
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
rlz_lib::testing::SetRlzStoreDirectory(temp_dir_.path());
rlz_lib::testing::SetRlzStoreDirectory(temp_dir_.GetPath());
#endif // defined(OS_POSIX)
}

@ -33,7 +33,7 @@ int main(int argc, char **argv) {
// creates and owns RlzValueStore object for its lifetime.
base::ScopedTempDir temp_dir;
if (temp_dir.CreateUniqueTempDir())
rlz_lib::testing::SetRlzStoreDirectory(temp_dir.path());
rlz_lib::testing::SetRlzStoreDirectory(temp_dir.GetPath());
#endif
rlz_lib::SupplementaryBranding branding("TEST");
ret = RUN_ALL_TESTS();

@ -62,7 +62,8 @@ TEST_F(AddressSanitizerTests, TestAddressSanitizer) {
base::ScopedTempDir temp_directory;
base::FilePath temp_file_name;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
ASSERT_TRUE(CreateTemporaryFileInDir(temp_directory.path(), &temp_file_name));
ASSERT_TRUE(
CreateTemporaryFileInDir(temp_directory.GetPath(), &temp_file_name));
SECURITY_ATTRIBUTES attrs = {};
attrs.nLength = sizeof(attrs);

@ -23,7 +23,8 @@ TEST(HandleInheritanceTests, TestStdoutInheritance) {
base::ScopedTempDir temp_directory;
base::FilePath temp_file_name;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
ASSERT_TRUE(CreateTemporaryFileInDir(temp_directory.path(), &temp_file_name));
ASSERT_TRUE(
CreateTemporaryFileInDir(temp_directory.GetPath(), &temp_file_name));
SECURITY_ATTRIBUTES attrs = {};
attrs.nLength = sizeof(attrs);

@ -477,7 +477,7 @@ void TestWin10ImageLoadLowLabel(bool is_success_test) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
base::FilePath new_path = temp_dir.path();
base::FilePath new_path = temp_dir.GetPath();
new_path = new_path.Append(L"lowIL_calc.exe");
// Test file will be cleaned up by the ScopedTempDir.

@ -16,7 +16,7 @@ SQLTestBase::~SQLTestBase() {
}
base::FilePath SQLTestBase::db_path() {
return temp_dir_.path().AppendASCII("SQLTest.db");
return temp_dir_.GetPath().AppendASCII("SQLTest.db");
}
sql::Connection& SQLTestBase::db() {

@ -99,7 +99,7 @@ TEST(ChromiumEnv, DeleteBackupTables) {
base::ScopedTempDir scoped_temp_dir;
ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDir());
base::FilePath dir = scoped_temp_dir.path();
base::FilePath dir = scoped_temp_dir.GetPath();
DB* db;
Status status = DB::Open(options, dir.AsUTF8Unsafe(), &db);
@ -136,7 +136,7 @@ TEST(ChromiumEnv, DeleteBackupTables) {
TEST(ChromiumEnv, GetChildrenEmptyDir) {
base::ScopedTempDir scoped_temp_dir;
ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDir());
base::FilePath dir = scoped_temp_dir.path();
base::FilePath dir = scoped_temp_dir.GetPath();
Env* env = Env::Default();
std::vector<std::string> result;
@ -148,7 +148,7 @@ TEST(ChromiumEnv, GetChildrenEmptyDir) {
TEST(ChromiumEnv, GetChildrenPriorResults) {
base::ScopedTempDir scoped_temp_dir;
ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDir());
base::FilePath dir = scoped_temp_dir.path();
base::FilePath dir = scoped_temp_dir.GetPath();
base::FilePath new_file_dir = dir.Append(FPL("tmp_file"));
FILE* f = fopen(new_file_dir.AsUTF8Unsafe().c_str(), "w");

@ -121,7 +121,7 @@ class ZipReaderTest : public PlatformTest {
PlatformTest::SetUp();
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
test_dir_ = temp_dir_.path();
test_dir_ = temp_dir_.GetPath();
ASSERT_TRUE(GetTestDataDirectory(&test_data_dir_));

@ -37,7 +37,7 @@ class ZipTest : public PlatformTest {
PlatformTest::SetUp();
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
test_dir_ = temp_dir_.path();
test_dir_ = temp_dir_.GetPath();
base::FilePath zip_path(test_dir_);
zip_contents_.insert(zip_path.AppendASCII("foo.txt"));
@ -122,9 +122,9 @@ class ZipTest : public PlatformTest {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
base::FilePath zip_file = temp_dir.path().AppendASCII("out.zip");
base::FilePath src_dir = temp_dir.path().AppendASCII("input");
base::FilePath out_dir = temp_dir.path().AppendASCII("output");
base::FilePath zip_file = temp_dir.GetPath().AppendASCII("out.zip");
base::FilePath src_dir = temp_dir.GetPath().AppendASCII("input");
base::FilePath out_dir = temp_dir.GetPath().AppendASCII("output");
base::FilePath src_file = src_dir.AppendASCII("test.txt");
base::FilePath out_file = out_dir.AppendASCII("test.txt");
@ -220,7 +220,7 @@ TEST_F(ZipTest, Zip) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
base::FilePath zip_file = temp_dir.path().AppendASCII("out.zip");
base::FilePath zip_file = temp_dir.GetPath().AppendASCII("out.zip");
EXPECT_TRUE(zip::Zip(src_dir, zip_file, true));
TestUnzipFile(zip_file, true);
@ -233,7 +233,7 @@ TEST_F(ZipTest, ZipIgnoreHidden) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
base::FilePath zip_file = temp_dir.path().AppendASCII("out.zip");
base::FilePath zip_file = temp_dir.GetPath().AppendASCII("out.zip");
EXPECT_TRUE(zip::Zip(src_dir, zip_file, false));
TestUnzipFile(zip_file, false);
@ -247,11 +247,10 @@ TEST_F(ZipTest, ZipNonASCIIDir) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
// Append 'Тест' (in cyrillic).
base::FilePath src_dir_russian =
temp_dir.path().Append(base::FilePath::FromUTF8Unsafe(
"\xD0\xA2\xD0\xB5\xD1\x81\xD1\x82"));
base::FilePath src_dir_russian = temp_dir.GetPath().Append(
base::FilePath::FromUTF8Unsafe("\xD0\xA2\xD0\xB5\xD1\x81\xD1\x82"));
base::CopyDirectory(src_dir, src_dir_russian, true);
base::FilePath zip_file = temp_dir.path().AppendASCII("out_russian.zip");
base::FilePath zip_file = temp_dir.GetPath().AppendASCII("out_russian.zip");
EXPECT_TRUE(zip::Zip(src_dir_russian, zip_file, true));
TestUnzipFile(zip_file, true);
@ -287,7 +286,7 @@ TEST_F(ZipTest, ZipFiles) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
base::FilePath zip_name = temp_dir.path().AppendASCII("out.zip");
base::FilePath zip_name = temp_dir.GetPath().AppendASCII("out.zip");
base::File zip_file(zip_name,
base::File::FLAG_CREATE | base::File::FLAG_WRITE);
@ -321,7 +320,7 @@ TEST_F(ZipTest, UnzipFilesWithIncorrectSize) {
base::ScopedTempDir scoped_temp_dir;
ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDir());
const base::FilePath& temp_dir = scoped_temp_dir.path();
const base::FilePath& temp_dir = scoped_temp_dir.GetPath();
ASSERT_TRUE(zip::Unzip(test_zip_file, temp_dir));
EXPECT_TRUE(base::DirectoryExists(temp_dir.AppendASCII("d")));

@ -26,6 +26,7 @@ bool ExecPython(const std::string& command,
std::string* std_err,
int* exit_code) {
base::ScopedTempDir temp_dir;
CHECK(temp_dir.CreateUniqueTempDir());
base::CommandLine::StringVector args;
#if defined(OS_WIN)
args.push_back(L"python");
@ -36,8 +37,8 @@ bool ExecPython(const std::string& command,
args.push_back("-c");
args.push_back(command);
#endif
return ExecProcess(
base::CommandLine(args), temp_dir.path(), std_out, std_err, exit_code);
return ExecProcess(base::CommandLine(args), temp_dir.GetPath(), std_out,
std_err, exit_code);
}
} // namespace

@ -581,7 +581,7 @@ TEST(FilesystemUtils, ContentsEqual) {
std::string data = "foo";
base::FilePath file_path = temp_dir.path().AppendASCII("foo.txt");
base::FilePath file_path = temp_dir.GetPath().AppendASCII("foo.txt");
base::WriteFile(file_path, data.c_str(), static_cast<int>(data.size()));
EXPECT_TRUE(ContentsEqual(file_path, data));
@ -602,7 +602,7 @@ TEST(FilesystemUtils, WriteFileIfChanged) {
// Write if file doesn't exist. Create also directory.
base::FilePath file_path =
temp_dir.path().AppendASCII("bar").AppendASCII("foo.txt");
temp_dir.GetPath().AppendASCII("bar").AppendASCII("foo.txt");
EXPECT_TRUE(WriteFileIfChanged(file_path, data, nullptr));
base::File::Info file_info;

@ -40,7 +40,7 @@ TEST(WriteFile, WithData) {
// Make a real directory for writing the files.
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
setup.build_settings()->SetRootPath(temp_dir.path());
setup.build_settings()->SetRootPath(temp_dir.GetPath());
setup.build_settings()->SetBuildDir(SourceDir("//out/"));
Value some_string(nullptr, "some string contents");
@ -52,8 +52,9 @@ TEST(WriteFile, WithData) {
// Should be able to write to a new dir inside the out dir.
EXPECT_TRUE(CallWriteFile(setup.scope(), "//out/foo.txt", some_string));
base::FilePath foo_name = temp_dir.path().Append(FILE_PATH_LITERAL("out"))
.Append(FILE_PATH_LITERAL("foo.txt"));
base::FilePath foo_name = temp_dir.GetPath()
.Append(FILE_PATH_LITERAL("out"))
.Append(FILE_PATH_LITERAL("foo.txt"));
std::string result_contents;
EXPECT_TRUE(base::ReadFileToString(foo_name, &result_contents));
EXPECT_EQ(some_string.string_value(), result_contents);

@ -53,7 +53,7 @@ class HistoryDataStoreTest : public testing::Test {
}
void OpenStore(const std::string& file_name) {
data_file_ = temp_dir_.path().AppendASCII(file_name);
data_file_ = temp_dir_.GetPath().AppendASCII(file_name);
store_ = new HistoryDataStore(scoped_refptr<DictionaryDataStore>(
new DictionaryDataStore(data_file_, worker_pool_owner_.pool().get())));
Load();
@ -70,8 +70,8 @@ class HistoryDataStoreTest : public testing::Test {
}
void WriteDataFile(const std::string& file_name, const std::string& data) {
base::WriteFile(
temp_dir_.path().AppendASCII(file_name), data.c_str(), data.size());
base::WriteFile(temp_dir_.GetPath().AppendASCII(file_name), data.c_str(),
data.size());
}
HistoryDataStore* store() { return store_.get(); }

@ -35,7 +35,8 @@ extern const size_t kSampleCorruptPakSize;
TEST(DataPackTest, LoadFromPath) {
base::ScopedTempDir dir;
ASSERT_TRUE(dir.CreateUniqueTempDir());
base::FilePath data_path = dir.path().Append(FILE_PATH_LITERAL("sample.pak"));
base::FilePath data_path =
dir.GetPath().Append(FILE_PATH_LITERAL("sample.pak"));
// Dump contents into the pak file.
ASSERT_EQ(base::WriteFile(data_path, kSamplePakContents, kSamplePakSize),
@ -67,7 +68,8 @@ TEST(DataPackTest, LoadFromPath) {
TEST(DataPackTest, LoadFromFile) {
base::ScopedTempDir dir;
ASSERT_TRUE(dir.CreateUniqueTempDir());
base::FilePath data_path = dir.path().Append(FILE_PATH_LITERAL("sample.pak"));
base::FilePath data_path =
dir.GetPath().Append(FILE_PATH_LITERAL("sample.pak"));
// Dump contents into the pak file.
ASSERT_EQ(base::WriteFile(data_path, kSamplePakContents, kSamplePakSize),
@ -102,7 +104,8 @@ TEST(DataPackTest, LoadFromFile) {
TEST(DataPackTest, LoadFromFileRegion) {
base::ScopedTempDir dir;
ASSERT_TRUE(dir.CreateUniqueTempDir());
base::FilePath data_path = dir.path().Append(FILE_PATH_LITERAL("sample.pak"));
base::FilePath data_path =
dir.GetPath().Append(FILE_PATH_LITERAL("sample.pak"));
// Construct a file which has a non page-aligned zero-filled header followed
// by the actual pak file content.
@ -158,7 +161,7 @@ TEST(DataPackTest, LoadFileWithTruncatedHeader) {
TEST_P(DataPackTest, Write) {
base::ScopedTempDir dir;
ASSERT_TRUE(dir.CreateUniqueTempDir());
base::FilePath file = dir.path().Append(FILE_PATH_LITERAL("data.pak"));
base::FilePath file = dir.GetPath().Append(FILE_PATH_LITERAL("data.pak"));
std::string one("one");
std::string two("two");
@ -196,7 +199,8 @@ TEST_P(DataPackTest, Write) {
TEST(DataPackTest, ModifiedWhileUsed) {
base::ScopedTempDir dir;
ASSERT_TRUE(dir.CreateUniqueTempDir());
base::FilePath data_path = dir.path().Append(FILE_PATH_LITERAL("sample.pak"));
base::FilePath data_path =
dir.GetPath().Append(FILE_PATH_LITERAL("sample.pak"));
// Dump contents into the pak file.
ASSERT_EQ(base::WriteFile(data_path, kSamplePakContents, kSamplePakSize),

@ -372,7 +372,7 @@ class ResourceBundleImageTest : public ResourceBundleTest {
}
// Returns the path of temporary directory to write test data packs into.
const base::FilePath& dir_path() { return dir_.path(); }
const base::FilePath& dir_path() { return dir_.GetPath(); }
// Returns the number of DataPacks managed by |resource_bundle|.
size_t NumDataPacksInResourceBundle(ResourceBundle* resource_bundle) {

@ -72,40 +72,44 @@ class FontRenderParamsTest : public testing::Test {
TEST_F(FontRenderParamsTest, Default) {
ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf"));
ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
ASSERT_TRUE(LoadConfigDataIntoFontconfig(
temp_dir_.GetPath(),
std::string(kFontconfigFileHeader) +
// Specify the desired defaults via a font match rather than a pattern
// match (since this is the style generally used in /etc/fonts/conf.d).
kFontconfigMatchFontHeader +
CreateFontconfigEditStanza("antialias", "bool", "true") +
CreateFontconfigEditStanza("autohint", "bool", "true") +
CreateFontconfigEditStanza("hinting", "bool", "true") +
CreateFontconfigEditStanza("hintstyle", "const", "hintslight") +
CreateFontconfigEditStanza("rgba", "const", "rgb") +
kFontconfigMatchFooter +
// Add a font match for Arial. Since it specifies a family, it shouldn't
// take effect when querying default settings.
kFontconfigMatchFontHeader +
CreateFontconfigTestStanza("family", "eq", "string", "Arial") +
CreateFontconfigEditStanza("antialias", "bool", "true") +
CreateFontconfigEditStanza("autohint", "bool", "false") +
CreateFontconfigEditStanza("hinting", "bool", "true") +
CreateFontconfigEditStanza("hintstyle", "const", "hintfull") +
CreateFontconfigEditStanza("rgba", "const", "none") +
kFontconfigMatchFooter +
// Add font matches for fonts between 10 and 20 points or pixels. Since
// they specify sizes, they also should not affect the defaults.
kFontconfigMatchFontHeader +
CreateFontconfigTestStanza("size", "more_eq", "double", "10.0") +
CreateFontconfigTestStanza("size", "less_eq", "double", "20.0") +
CreateFontconfigEditStanza("antialias", "bool", "false") +
kFontconfigMatchFooter +
kFontconfigMatchFontHeader +
CreateFontconfigTestStanza("pixel_size", "more_eq", "double", "10.0") +
CreateFontconfigTestStanza("pixel_size", "less_eq", "double", "20.0") +
CreateFontconfigEditStanza("antialias", "bool", "false") +
kFontconfigMatchFooter +
kFontconfigFileFooter));
// Specify the desired defaults via a font match rather than a pattern
// match (since this is the style generally used in
// /etc/fonts/conf.d).
kFontconfigMatchFontHeader +
CreateFontconfigEditStanza("antialias", "bool", "true") +
CreateFontconfigEditStanza("autohint", "bool", "true") +
CreateFontconfigEditStanza("hinting", "bool", "true") +
CreateFontconfigEditStanza("hintstyle", "const", "hintslight") +
CreateFontconfigEditStanza("rgba", "const", "rgb") +
kFontconfigMatchFooter +
// Add a font match for Arial. Since it specifies a family, it
// shouldn't
// take effect when querying default settings.
kFontconfigMatchFontHeader +
CreateFontconfigTestStanza("family", "eq", "string", "Arial") +
CreateFontconfigEditStanza("antialias", "bool", "true") +
CreateFontconfigEditStanza("autohint", "bool", "false") +
CreateFontconfigEditStanza("hinting", "bool", "true") +
CreateFontconfigEditStanza("hintstyle", "const", "hintfull") +
CreateFontconfigEditStanza("rgba", "const", "none") +
kFontconfigMatchFooter +
// Add font matches for fonts between 10 and 20 points or pixels.
// Since
// they specify sizes, they also should not affect the defaults.
kFontconfigMatchFontHeader +
CreateFontconfigTestStanza("size", "more_eq", "double", "10.0") +
CreateFontconfigTestStanza("size", "less_eq", "double", "20.0") +
CreateFontconfigEditStanza("antialias", "bool", "false") +
kFontconfigMatchFooter + kFontconfigMatchFontHeader +
CreateFontconfigTestStanza("pixel_size", "more_eq", "double",
"10.0") +
CreateFontconfigTestStanza("pixel_size", "less_eq", "double",
"20.0") +
CreateFontconfigEditStanza("antialias", "bool", "false") +
kFontconfigMatchFooter + kFontconfigFileFooter));
FontRenderParams params = GetFontRenderParams(
FontRenderParamsQuery(), NULL);
@ -120,24 +124,21 @@ TEST_F(FontRenderParamsTest, Default) {
TEST_F(FontRenderParamsTest, Size) {
ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf"));
ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
std::string(kFontconfigFileHeader) +
kFontconfigMatchPatternHeader +
CreateFontconfigEditStanza("antialias", "bool", "true") +
CreateFontconfigEditStanza("hinting", "bool", "true") +
CreateFontconfigEditStanza("hintstyle", "const", "hintfull") +
CreateFontconfigEditStanza("rgba", "const", "none") +
kFontconfigMatchFooter +
kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("pixelsize", "less_eq", "double", "10") +
CreateFontconfigEditStanza("antialias", "bool", "false") +
kFontconfigMatchFooter +
kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("size", "more_eq", "double", "20") +
CreateFontconfigEditStanza("hintstyle", "const", "hintslight") +
CreateFontconfigEditStanza("rgba", "const", "rgb") +
kFontconfigMatchFooter +
kFontconfigFileFooter));
ASSERT_TRUE(LoadConfigDataIntoFontconfig(
temp_dir_.GetPath(),
std::string(kFontconfigFileHeader) + kFontconfigMatchPatternHeader +
CreateFontconfigEditStanza("antialias", "bool", "true") +
CreateFontconfigEditStanza("hinting", "bool", "true") +
CreateFontconfigEditStanza("hintstyle", "const", "hintfull") +
CreateFontconfigEditStanza("rgba", "const", "none") +
kFontconfigMatchFooter + kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("pixelsize", "less_eq", "double", "10") +
CreateFontconfigEditStanza("antialias", "bool", "false") +
kFontconfigMatchFooter + kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("size", "more_eq", "double", "20") +
CreateFontconfigEditStanza("hintstyle", "const", "hintslight") +
CreateFontconfigEditStanza("rgba", "const", "rgb") +
kFontconfigMatchFooter + kFontconfigFileFooter));
// The defaults should be used when the supplied size isn't matched by the
// second or third blocks.
@ -169,23 +170,20 @@ TEST_F(FontRenderParamsTest, Style) {
ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf"));
// Load a config that disables subpixel rendering for bold text and disables
// hinting for italic text.
ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
std::string(kFontconfigFileHeader) +
kFontconfigMatchPatternHeader +
CreateFontconfigEditStanza("antialias", "bool", "true") +
CreateFontconfigEditStanza("hinting", "bool", "true") +
CreateFontconfigEditStanza("hintstyle", "const", "hintslight") +
CreateFontconfigEditStanza("rgba", "const", "rgb") +
kFontconfigMatchFooter +
kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("weight", "eq", "const", "bold") +
CreateFontconfigEditStanza("rgba", "const", "none") +
kFontconfigMatchFooter +
kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("slant", "eq", "const", "italic") +
CreateFontconfigEditStanza("hinting", "bool", "false") +
kFontconfigMatchFooter +
kFontconfigFileFooter));
ASSERT_TRUE(LoadConfigDataIntoFontconfig(
temp_dir_.GetPath(),
std::string(kFontconfigFileHeader) + kFontconfigMatchPatternHeader +
CreateFontconfigEditStanza("antialias", "bool", "true") +
CreateFontconfigEditStanza("hinting", "bool", "true") +
CreateFontconfigEditStanza("hintstyle", "const", "hintslight") +
CreateFontconfigEditStanza("rgba", "const", "rgb") +
kFontconfigMatchFooter + kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("weight", "eq", "const", "bold") +
CreateFontconfigEditStanza("rgba", "const", "none") +
kFontconfigMatchFooter + kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("slant", "eq", "const", "italic") +
CreateFontconfigEditStanza("hinting", "bool", "false") +
kFontconfigMatchFooter + kFontconfigFileFooter));
FontRenderParamsQuery query;
query.style = Font::NORMAL;
@ -217,16 +215,14 @@ TEST_F(FontRenderParamsTest, Style) {
TEST_F(FontRenderParamsTest, Scalable) {
// Load a config that only enables antialiasing for scalable fonts.
ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
std::string(kFontconfigFileHeader) +
kFontconfigMatchPatternHeader +
CreateFontconfigEditStanza("antialias", "bool", "false") +
kFontconfigMatchFooter +
kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("scalable", "eq", "bool", "true") +
CreateFontconfigEditStanza("antialias", "bool", "true") +
kFontconfigMatchFooter +
kFontconfigFileFooter));
ASSERT_TRUE(LoadConfigDataIntoFontconfig(
temp_dir_.GetPath(),
std::string(kFontconfigFileHeader) + kFontconfigMatchPatternHeader +
CreateFontconfigEditStanza("antialias", "bool", "false") +
kFontconfigMatchFooter + kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("scalable", "eq", "bool", "true") +
CreateFontconfigEditStanza("antialias", "bool", "true") +
kFontconfigMatchFooter + kFontconfigFileFooter));
// Check that we specifically ask how scalable fonts should be rendered.
FontRenderParams params = GetFontRenderParams(
@ -237,16 +233,14 @@ TEST_F(FontRenderParamsTest, Scalable) {
TEST_F(FontRenderParamsTest, UseBitmaps) {
ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf"));
// Load a config that enables embedded bitmaps for fonts <= 10 pixels.
ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
std::string(kFontconfigFileHeader) +
kFontconfigMatchPatternHeader +
CreateFontconfigEditStanza("embeddedbitmap", "bool", "false") +
kFontconfigMatchFooter +
kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("pixelsize", "less_eq", "double", "10") +
CreateFontconfigEditStanza("embeddedbitmap", "bool", "true") +
kFontconfigMatchFooter +
kFontconfigFileFooter));
ASSERT_TRUE(LoadConfigDataIntoFontconfig(
temp_dir_.GetPath(),
std::string(kFontconfigFileHeader) + kFontconfigMatchPatternHeader +
CreateFontconfigEditStanza("embeddedbitmap", "bool", "false") +
kFontconfigMatchFooter + kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("pixelsize", "less_eq", "double", "10") +
CreateFontconfigEditStanza("embeddedbitmap", "bool", "true") +
kFontconfigMatchFooter + kFontconfigFileFooter));
FontRenderParamsQuery query;
FontRenderParams params = GetFontRenderParams(query, NULL);
@ -260,15 +254,14 @@ TEST_F(FontRenderParamsTest, UseBitmaps) {
TEST_F(FontRenderParamsTest, ForceFullHintingWhenAntialiasingIsDisabled) {
// Load a config that disables antialiasing and hinting while requesting
// subpixel rendering.
ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
std::string(kFontconfigFileHeader) +
kFontconfigMatchPatternHeader +
CreateFontconfigEditStanza("antialias", "bool", "false") +
CreateFontconfigEditStanza("hinting", "bool", "false") +
CreateFontconfigEditStanza("hintstyle", "const", "hintnone") +
CreateFontconfigEditStanza("rgba", "const", "rgb") +
kFontconfigMatchFooter +
kFontconfigFileFooter));
ASSERT_TRUE(LoadConfigDataIntoFontconfig(
temp_dir_.GetPath(),
std::string(kFontconfigFileHeader) + kFontconfigMatchPatternHeader +
CreateFontconfigEditStanza("antialias", "bool", "false") +
CreateFontconfigEditStanza("hinting", "bool", "false") +
CreateFontconfigEditStanza("hintstyle", "const", "hintnone") +
CreateFontconfigEditStanza("rgba", "const", "rgb") +
kFontconfigMatchFooter + kFontconfigFileFooter));
// Full hinting should be forced. See the comment in GetFontRenderParams() for
// more information.
@ -310,12 +303,11 @@ TEST_F(FontRenderParamsTest, OnlySetConfiguredValues) {
// Load a Fontconfig config that enables antialiasing but doesn't say anything
// about subpixel rendering.
ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
std::string(kFontconfigFileHeader) +
kFontconfigMatchPatternHeader +
CreateFontconfigEditStanza("antialias", "bool", "true") +
kFontconfigMatchFooter +
kFontconfigFileFooter));
ASSERT_TRUE(LoadConfigDataIntoFontconfig(
temp_dir_.GetPath(),
std::string(kFontconfigFileHeader) + kFontconfigMatchPatternHeader +
CreateFontconfigEditStanza("antialias", "bool", "true") +
kFontconfigMatchFooter + kFontconfigFileFooter));
// The subpixel rendering setting from the delegate should make it through.
FontRenderParams params = GetFontRenderParams(
@ -363,14 +355,14 @@ TEST_F(FontRenderParamsTest, SubstituteFamily) {
// Configure Fontconfig to use Verdana for both Helvetica and Arial.
ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf"));
ASSERT_TRUE(LoadSystemFontIntoFontconfig("verdana.ttf"));
ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
ASSERT_TRUE(LoadConfigDataIntoFontconfig(
temp_dir_.GetPath(),
std::string(kFontconfigFileHeader) +
CreateFontconfigAliasStanza("Helvetica", "Verdana") +
kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("family", "eq", "string", "Arial") +
CreateFontconfigEditStanza("family", "string", "Verdana") +
kFontconfigMatchFooter +
kFontconfigFileFooter));
CreateFontconfigAliasStanza("Helvetica", "Verdana") +
kFontconfigMatchPatternHeader +
CreateFontconfigTestStanza("family", "eq", "string", "Arial") +
CreateFontconfigEditStanza("family", "string", "Verdana") +
kFontconfigMatchFooter + kFontconfigFileFooter));
FontRenderParamsQuery query;
query.families.push_back("Helvetica");

@ -200,10 +200,10 @@ TEST_F(IconUtilTest, TestBitmapToIconInvalidParameters) {
TEST_F(IconUtilTest, TestCreateIconFileInvalidParameters) {
std::unique_ptr<SkBitmap> bitmap;
gfx::ImageFamily image_family;
base::FilePath valid_icon_filename = temp_directory_.path().AppendASCII(
kTempIconFilename);
base::FilePath invalid_icon_filename = temp_directory_.path().AppendASCII(
"<>?.ico");
base::FilePath valid_icon_filename =
temp_directory_.GetPath().AppendASCII(kTempIconFilename);
base::FilePath invalid_icon_filename =
temp_directory_.GetPath().AppendASCII("<>?.ico");
// Wrong bitmap format.
bitmap.reset(new SkBitmap);
@ -252,8 +252,8 @@ TEST_F(IconUtilTest, TestCreateIconFileInvalidParameters) {
// This test case makes sure IconUtil::CreateIconFileFromImageFamily fails if
// the image family is empty or invalid.
TEST_F(IconUtilTest, TestCreateIconFileEmptyImageFamily) {
base::FilePath icon_filename = temp_directory_.path().AppendASCII(
kTempIconFilename);
base::FilePath icon_filename =
temp_directory_.GetPath().AppendASCII(kTempIconFilename);
// Empty image family.
EXPECT_FALSE(IconUtil::CreateIconFileFromImageFamily(gfx::ImageFamily(),
@ -342,7 +342,7 @@ TEST_F(IconUtilTest, TestBasicCreateHICONFromSkBitmap) {
TEST_F(IconUtilTest, TestCreateIconFileFromImageFamily) {
gfx::ImageFamily image_family;
base::FilePath icon_filename =
temp_directory_.path().AppendASCII(kTempIconFilename);
temp_directory_.GetPath().AppendASCII(kTempIconFilename);
// Test with only a 16x16 icon. Should only scale up to 48x48.
image_family.Add(gfx::Image::CreateFrom1xBitmap(