Commit 16e5f602 authored by vabr's avatar vabr Committed by Commit bot

misc files A-P: 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
TBR=rsleevi@chromium.org, alexclarke@chromium.org, vitalybuka@chromium.org, nyquist@chromium.org, boliu@chromium.org, benwells@chromium.org, sdefresne@chromium.org, rogerta@chromium.org, rockot@chromium.org, alokp@chromium.org

Review-Url: https://codereview.chromium.org/2322573002
Cr-Commit-Position: refs/heads/master@{#418904}
parent 965572be
......@@ -40,7 +40,7 @@ class AwFormDatabaseServiceTest : public Test {
ASSERT_TRUE(env_ != NULL);
ASSERT_TRUE(l10n_util::RegisterLocalizationUtil(env_));
service_.reset(new AwFormDatabaseService(temp_dir_.path()));
service_.reset(new AwFormDatabaseService(temp_dir_.GetPath()));
}
void TearDown() override { service_->Shutdown(); }
......
......@@ -117,13 +117,13 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, FileAccessIsSavedToPrefs) {
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
base::FilePath temp_file;
ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_directory.path(),
&temp_file));
ASSERT_TRUE(
base::CreateTemporaryFileInDir(temp_directory.GetPath(), &temp_file));
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&temp_file);
FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest(
"temp", temp_directory.path());
"temp", temp_directory.GetPath());
const Extension* extension = LoadAndLaunchPlatformApp(
"file_access_saved_to_prefs_test", "fileWritten");
......@@ -157,13 +157,13 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_FileAccessIsRestored) {
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
base::FilePath temp_file;
ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_directory.path(),
&temp_file));
ASSERT_TRUE(
base::CreateTemporaryFileInDir(temp_directory.GetPath(), &temp_file));
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&temp_file);
FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest(
"temp", temp_directory.path());
"temp", temp_directory.GetPath());
ExtensionTestMessageListener access_ok_listener(
"restartedFileAccessOK", false);
......
......@@ -58,7 +58,7 @@ class BlimpEngineConfigTest : public testing::Test {
base::FilePath GetFilepathForSwitch(
const std::string& filepath_switch) const {
return temp_dir_.path().Append(filepath_switch);
return temp_dir_.GetPath().Append(filepath_switch);
}
const std::vector<std::string> all_filepath_switches_ = {
......
......@@ -113,7 +113,7 @@ class CastCrashReporterClientTest : public testing::Test {
}
base::FilePath minidump_path() { return minidump_.path(); }
base::FilePath home_path() { return fake_home_dir_.path(); }
base::FilePath home_path() { return fake_home_dir_.GetPath(); }
private:
base::ScopedTempDir fake_home_dir_;
......
......@@ -24,10 +24,10 @@ class ErrorCodesTest : public testing::Test {
// Set up a temporary directory which will be used as our fake home dir.
ASSERT_TRUE(fake_home_dir_.CreateUniqueTempDir());
path_override_.reset(
new base::ScopedPathOverride(base::DIR_HOME, fake_home_dir_.path()));
new base::ScopedPathOverride(base::DIR_HOME, fake_home_dir_.GetPath()));
}
base::FilePath home_path() const { return fake_home_dir_.path(); }
base::FilePath home_path() const { return fake_home_dir_.GetPath(); }
private:
base::ScopedTempDir fake_home_dir_;
......
......@@ -22,8 +22,8 @@ TEST(DummyMinidumpGeneratorTest, GenerateFailsWithInvalidPath) {
// Attempt to generate a minidump from an invalid path.
DummyMinidumpGenerator generator("/path/does/not/exist/minidump.dmp");
ASSERT_FALSE(
generator.Generate(minidump_dir.path().Append("minidump.dmp").value()));
ASSERT_FALSE(generator.Generate(
minidump_dir.GetPath().Append("minidump.dmp").value()));
}
TEST(DummyMinidumpGeneratorTest, GenerateSucceedsWithSmallSource) {
......@@ -38,7 +38,7 @@ TEST(DummyMinidumpGeneratorTest, GenerateSucceedsWithSmallSource) {
base::WriteFile(fake_minidump.path(), data.c_str(), data.size()));
DummyMinidumpGenerator generator(fake_minidump.path().value());
base::FilePath new_minidump = minidump_dir.path().Append("minidump.dmp");
base::FilePath new_minidump = minidump_dir.GetPath().Append("minidump.dmp");
EXPECT_TRUE(generator.Generate(new_minidump.value()));
// Original file should not exist, and new file should contain original
......@@ -64,7 +64,7 @@ TEST(DummyMinidumpGeneratorTest, GenerateSucceedsWithLargeSource) {
ASSERT_EQ(static_cast<int>(data.size()),
base::WriteFile(fake_minidump.path(), data.c_str(), data.size()));
base::FilePath new_minidump = minidump_dir.path().Append("minidump.dmp");
base::FilePath new_minidump = minidump_dir.GetPath().Append("minidump.dmp");
DummyMinidumpGenerator generator(fake_minidump.path().value());
ASSERT_TRUE(generator.Generate(new_minidump.value()));
......
......@@ -75,9 +75,9 @@ class MinidumpUploaderTest : public testing::Test {
// Set up a temporary directory which will be used as our fake home dir.
ASSERT_TRUE(fake_home_dir_.CreateUniqueTempDir());
path_override_.reset(
new base::ScopedPathOverride(base::DIR_HOME, fake_home_dir_.path()));
new base::ScopedPathOverride(base::DIR_HOME, fake_home_dir_.GetPath()));
minidump_dir_ = fake_home_dir_.path().Append(kMinidumpSubdir);
minidump_dir_ = fake_home_dir_.GetPath().Append(kMinidumpSubdir);
lockfile_ = minidump_dir_.Append(kLockfileName);
metadata_ = minidump_dir_.Append(kMetadataName);
......
......@@ -51,9 +51,9 @@ class MinidumpWriterTest : public testing::Test {
// Set up a temporary directory which will be used as our fake home dir.
ASSERT_TRUE(fake_home_dir_.CreateUniqueTempDir());
home_.reset(
new base::ScopedPathOverride(base::DIR_HOME, fake_home_dir_.path()));
new base::ScopedPathOverride(base::DIR_HOME, fake_home_dir_.GetPath()));
minidump_dir_ = fake_home_dir_.path().Append(kMinidumpSubdir);
minidump_dir_ = fake_home_dir_.GetPath().Append(kMinidumpSubdir);
dumplog_file_ = minidump_dir_.Append(kDumplogFile);
lockfile_path_ = minidump_dir_.Append(kLockfileName);
metadata_path_ = minidump_dir_.Append(kMetadataName);
......
......@@ -147,9 +147,9 @@ class SynchronizedMinidumpManagerTest : public testing::Test {
// Set up a temporary directory which will be used as our fake home dir.
ASSERT_TRUE(fake_home_dir_.CreateUniqueTempDir());
path_override_.reset(
new base::ScopedPathOverride(base::DIR_HOME, fake_home_dir_.path()));
new base::ScopedPathOverride(base::DIR_HOME, fake_home_dir_.GetPath()));
minidump_dir_ = fake_home_dir_.path().Append(kMinidumpSubdir);
minidump_dir_ = fake_home_dir_.GetPath().Append(kMinidumpSubdir);
lockfile_ = minidump_dir_.Append(kLockfileName);
metadata_ = minidump_dir_.Append(kMetadataName);
......
......@@ -18,7 +18,7 @@ ScopedTestNSSChromeOSUser::ScopedTestNSSChromeOSUser(
// This opens a software DB in the given folder. In production code that is in
// the home folder, but for testing the temp folder is used.
constructed_successfully_ =
InitializeNSSForChromeOSUser(username_hash, temp_dir_.path());
InitializeNSSForChromeOSUser(username_hash, temp_dir_.GetPath());
}
ScopedTestNSSChromeOSUser::~ScopedTestNSSChromeOSUser() {
......
......@@ -24,7 +24,7 @@ ScopedTestNSSDB::ScopedTestNSSDB() {
return;
const char kTestDescription[] = "Test DB";
slot_ = OpenSoftwareNSSDB(temp_dir_.path(), kTestDescription);
slot_ = OpenSoftwareNSSDB(temp_dir_.GetPath(), kTestDescription);
}
ScopedTestNSSDB::~ScopedTestNSSDB() {
......
......@@ -55,7 +55,7 @@ class BaseRequestsServerTest : public testing::Test {
// Returns a temporary file path suitable for storing the cache file.
base::FilePath GetTestCachedFilePath(const base::FilePath& file_name) {
return temp_dir_.path().Append(file_name);
return temp_dir_.GetPath().Append(file_name);
}
base::MessageLoopForIO message_loop_; // Test server needs IO thread.
......
......@@ -1056,7 +1056,7 @@ TEST_F(DriveApiRequestsTest, UploadNewFileRequest) {
const char kTestContentType[] = "text/plain";
const std::string kTestContent(100, 'a');
const base::FilePath kTestFilePath =
temp_dir_.path().AppendASCII("upload_file.txt");
temp_dir_.GetPath().AppendASCII("upload_file.txt");
ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent));
DriveApiErrorCode error = DRIVE_OTHER_ERROR;
......@@ -1154,7 +1154,7 @@ TEST_F(DriveApiRequestsTest, UploadNewEmptyFileRequest) {
const char kTestContentType[] = "text/plain";
const char kTestContent[] = "";
const base::FilePath kTestFilePath =
temp_dir_.path().AppendASCII("empty_file.txt");
temp_dir_.GetPath().AppendASCII("empty_file.txt");
ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent));
DriveApiErrorCode error = DRIVE_OTHER_ERROR;
......@@ -1243,7 +1243,7 @@ TEST_F(DriveApiRequestsTest, UploadNewLargeFileRequest) {
const size_t kNumChunkBytes = 10; // Num bytes in a chunk.
const std::string kTestContent(100, 'a');
const base::FilePath kTestFilePath =
temp_dir_.path().AppendASCII("upload_file.txt");
temp_dir_.GetPath().AppendASCII("upload_file.txt");
ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent));
DriveApiErrorCode error = DRIVE_OTHER_ERROR;
......@@ -1476,7 +1476,7 @@ TEST_F(DriveApiRequestsTest, UploadExistingFileRequest) {
const char kTestContentType[] = "text/plain";
const std::string kTestContent(100, 'a');
const base::FilePath kTestFilePath =
temp_dir_.path().AppendASCII("upload_file.txt");
temp_dir_.GetPath().AppendASCII("upload_file.txt");
ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent));
DriveApiErrorCode error = DRIVE_OTHER_ERROR;
......@@ -1568,7 +1568,7 @@ TEST_F(DriveApiRequestsTest, UploadExistingFileRequestWithETag) {
const char kTestContentType[] = "text/plain";
const std::string kTestContent(100, 'a');
const base::FilePath kTestFilePath =
temp_dir_.path().AppendASCII("upload_file.txt");
temp_dir_.GetPath().AppendASCII("upload_file.txt");
ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent));
DriveApiErrorCode error = DRIVE_OTHER_ERROR;
......@@ -1702,7 +1702,7 @@ TEST_F(DriveApiRequestsTest,
const char kTestContentType[] = "text/plain";
const std::string kTestContent(100, 'a');
const base::FilePath kTestFilePath =
temp_dir_.path().AppendASCII("upload_file.txt");
temp_dir_.GetPath().AppendASCII("upload_file.txt");
ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent));
DriveApiErrorCode error = DRIVE_OTHER_ERROR;
......@@ -1851,7 +1851,7 @@ TEST_F(DriveApiRequestsTest, UploadExistingFileWithMetadataRequest) {
TEST_F(DriveApiRequestsTest, DownloadFileRequest) {
const base::FilePath kDownloadedFilePath =
temp_dir_.path().AppendASCII("cache_file");
temp_dir_.GetPath().AppendASCII("cache_file");
const std::string kTestId("dummyId");
DriveApiErrorCode result_code = DRIVE_OTHER_ERROR;
......@@ -1888,7 +1888,7 @@ TEST_F(DriveApiRequestsTest, DownloadFileRequest) {
TEST_F(DriveApiRequestsTest, DownloadFileRequest_GetContentCallback) {
const base::FilePath kDownloadedFilePath =
temp_dir_.path().AppendASCII("cache_file");
temp_dir_.GetPath().AppendASCII("cache_file");
const std::string kTestId("dummyId");
DriveApiErrorCode result_code = DRIVE_OTHER_ERROR;
......@@ -2001,7 +2001,7 @@ TEST_F(DriveApiRequestsTest, BatchUploadRequest) {
const char kTestContentType[] = "text/plain";
const std::string kTestContent(10, 'a');
const base::FilePath kTestFilePath =
temp_dir_.path().AppendASCII("upload_file.txt");
temp_dir_.GetPath().AppendASCII("upload_file.txt");
ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent));
// Create batch request.
......
......@@ -88,7 +88,7 @@ std::unique_ptr<GCMStoreImpl> GCMStoreImplTest::BuildGCMStore() {
// Pass an non-existent directory as store path to match the exact
// behavior in the production code. Currently GCMStoreImpl checks if
// the directory exist or not to determine the store existence.
temp_directory_.path().Append(FILE_PATH_LITERAL("GCM Store")),
temp_directory_.GetPath().Append(FILE_PATH_LITERAL("GCM Store")),
task_runner_, base::WrapUnique<Encryptor>(new FakeEncryptor)));
}
......
......@@ -205,7 +205,7 @@ void MCSClientTest::SetUp() {
void MCSClientTest::BuildMCSClient() {
gcm_store_.reset(
new GCMStoreImpl(temp_directory_.path(), message_loop_.task_runner(),
new GCMStoreImpl(temp_directory_.GetPath(), message_loop_.task_runner(),
base::WrapUnique<Encryptor>(new FakeEncryptor)));
mcs_client_.reset(new TestMCSClient(&clock_,
&connection_factory_,
......
......@@ -213,12 +213,12 @@ IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, UserDataDir) {
ASSERT_TRUE(user_data_dir.CreateUniqueTempDir());
// Newly created temp directory should be empty.
EXPECT_TRUE(base::IsDirectoryEmpty(user_data_dir.path()));
EXPECT_TRUE(base::IsDirectoryEmpty(user_data_dir.GetPath()));
HeadlessBrowserContext* browser_context =
browser()
->CreateBrowserContextBuilder()
.SetUserDataDir(user_data_dir.path())
.SetUserDataDir(user_data_dir.GetPath())
.SetIncognitoMode(false)
.Build();
......@@ -232,7 +232,7 @@ IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, UserDataDir) {
// Something should be written to this directory.
// If it is not the case, more complex page may be needed.
// ServiceWorkers may be a good option.
EXPECT_FALSE(base::IsDirectoryEmpty(user_data_dir.path()));
EXPECT_FALSE(base::IsDirectoryEmpty(user_data_dir.GetPath()));
}
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, IncognitoMode) {
......@@ -246,12 +246,12 @@ IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, IncognitoMode) {
ASSERT_TRUE(user_data_dir.CreateUniqueTempDir());
// Newly created temp directory should be empty.
EXPECT_TRUE(base::IsDirectoryEmpty(user_data_dir.path()));
EXPECT_TRUE(base::IsDirectoryEmpty(user_data_dir.GetPath()));
HeadlessBrowserContext* browser_context =
browser()
->CreateBrowserContextBuilder()
.SetUserDataDir(user_data_dir.path())
.SetUserDataDir(user_data_dir.GetPath())
.SetIncognitoMode(true)
.Build();
......@@ -264,7 +264,7 @@ IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, IncognitoMode) {
// Similar to test above, but now we are in incognito mode,
// so nothing should be written to this directory.
EXPECT_TRUE(base::IsDirectoryEmpty(user_data_dir.path()));
EXPECT_TRUE(base::IsDirectoryEmpty(user_data_dir.GetPath()));
}
} // namespace headless
......@@ -112,7 +112,7 @@ base::FilePath CreateTempBrowserStateDir(base::ScopedTempDir* temp_dir) {
CHECK(temp_dir->Set(system_tmp_dir));
}
}
return temp_dir->path();
return temp_dir->GetPath();
}
} // namespace
......
......@@ -820,8 +820,8 @@ TEST_F(IPCAttachmentBrokerMacTest, SendPosixFDAndMachPort) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
base::FilePath fp1, fp2;
ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.path(), &fp1));
ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.path(), &fp2));
ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.GetPath(), &fp1));
ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.GetPath(), &fp2));
CommonSetUp("SendPosixFDAndMachPort");
......
......@@ -255,7 +255,8 @@ class IPCAttachmentBrokerPrivilegedWinTest : public IPCTestBase {
void SetUp() override {
IPCTestBase::SetUp();
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &temp_path_));
ASSERT_TRUE(
base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &temp_path_));
}
void TearDown() override { IPCTestBase::TearDown(); }
......
......@@ -1378,7 +1378,7 @@ TEST_F(IPCChannelMojoTest, SendPlatformHandle) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
base::File file(HandleSendingHelper::GetSendingFilePath(temp_dir.path()),
base::File file(HandleSendingHelper::GetSendingFilePath(temp_dir.GetPath()),
base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE |
base::File::FLAG_READ);
HandleSendingHelper::WriteFileThenSend(channel(), file);
......@@ -1434,7 +1434,7 @@ TEST_F(IPCChannelMojoTest, SendPlatformHandleAndPipe) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
base::File file(HandleSendingHelper::GetSendingFilePath(temp_dir.path()),
base::File file(HandleSendingHelper::GetSendingFilePath(temp_dir.GetPath()),
base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE |
base::File::FLAG_READ);
TestingMessagePipe pipe;
......
......@@ -153,7 +153,7 @@ TEST_F(PlatformChannelPairPosixTest, SendReceiveFDs) {
for (size_t j = 1; j <= i; j++) {
base::FilePath unused;
base::ScopedFILE fp(
base::CreateAndOpenTemporaryFileInDir(temp_dir.path(), &unused));
base::CreateAndOpenTemporaryFileInDir(temp_dir.GetPath(), &unused));
ASSERT_TRUE(fp);
ASSERT_EQ(j, fwrite(std::string(j, c).data(), 1, j, fp.get()));
platform_handles->push_back(
......@@ -209,7 +209,7 @@ TEST_F(PlatformChannelPairPosixTest, AppendReceivedFDs) {
{
base::FilePath unused;
base::ScopedFILE fp(
base::CreateAndOpenTemporaryFileInDir(temp_dir.path(), &unused));
base::CreateAndOpenTemporaryFileInDir(temp_dir.GetPath(), &unused));
ASSERT_TRUE(fp);
ASSERT_EQ(file_contents.size(),
fwrite(file_contents.data(), 1, file_contents.size(), fp.get()));
......
......@@ -428,7 +428,7 @@ TEST_P(MultiprocessMessagePipeTestWithPipeCount, PlatformHandlePassing) {
for (size_t i = 0; i < pipe_count; ++i) {
base::FilePath unused;
base::ScopedFILE fp(
CreateAndOpenTemporaryFileInDir(temp_dir.path(), &unused));
CreateAndOpenTemporaryFileInDir(temp_dir.GetPath(), &unused));
const std::string world("world");
CHECK_EQ(fwrite(&world[0], 1, world.size(), fp.get()), world.size());
fflush(fp.get());
......
......@@ -28,7 +28,7 @@ TEST(PlatformHandleDispatcherTest, Basic) {
base::FilePath unused;
base::ScopedFILE fp(
CreateAndOpenTemporaryFileInDir(temp_dir.path(), &unused));
CreateAndOpenTemporaryFileInDir(temp_dir.GetPath(), &unused));
ASSERT_TRUE(fp);
EXPECT_EQ(sizeof(kHelloWorld),
fwrite(kHelloWorld, 1, sizeof(kHelloWorld), fp.get()));
......@@ -70,7 +70,7 @@ TEST(PlatformHandleDispatcherTest, Serialization) {
base::FilePath unused;
base::ScopedFILE fp(
CreateAndOpenTemporaryFileInDir(temp_dir.path(), &unused));
CreateAndOpenTemporaryFileInDir(temp_dir.GetPath(), &unused));
EXPECT_EQ(sizeof(kFooBar), fwrite(kFooBar, 1, sizeof(kFooBar), fp.get()));
scoped_refptr<PlatformHandleDispatcher> dispatcher =
......
......@@ -177,7 +177,7 @@ TEST(EmfTest, FileBackedEmf) {
base::ScopedTempDir scratch_metafile_dir;
ASSERT_TRUE(scratch_metafile_dir.CreateUniqueTempDir());
base::FilePath metafile_path;
EXPECT_TRUE(base::CreateTemporaryFileInDir(scratch_metafile_dir.path(),
EXPECT_TRUE(base::CreateTemporaryFileInDir(scratch_metafile_dir.GetPath(),
&metafile_path));
uint32_t size;
std::vector<char> data;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment