#include <string>
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_WIN)
#include <shlobj.h>
#endif
namespace base {
TEST(ScopedTempDir, FullPath) { … }
TEST(ScopedTempDir, TempDir) { … }
TEST(ScopedTempDir, UniqueTempDirUnderPath) { … }
TEST(ScopedTempDir, MultipleInvocations) { … }
TEST(ScopedTempDir, Move) { … }
#if BUILDFLAG(IS_WIN)
TEST(ScopedTempDir, LockedTempDir) {
ScopedTempDir dir;
EXPECT_TRUE(dir.CreateUniqueTempDir());
File file(dir.GetPath().Append(FILE_PATH_LITERAL("temp")),
File::FLAG_CREATE_ALWAYS | File::FLAG_WRITE);
EXPECT_TRUE(file.IsValid());
EXPECT_EQ(File::FILE_OK, file.error_details());
EXPECT_FALSE(dir.Delete());
EXPECT_FALSE(dir.GetPath().empty());
file.Close();
EXPECT_TRUE(dir.Delete());
}
#endif
}