#include "components/download/public/common/base_file.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <utility>
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/test_file_util.h"
#include "build/build_config.h"
#include "components/download/public/common/download_interrupt_reasons.h"
#include "components/download/public/common/download_item.h"
#include "crypto/secure_hash.h"
#include "crypto/sha2.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_WIN)
#include "base/win/scoped_com_initializer.h"
#endif
namespace download {
namespace {
const char kTestData1[] = …;
const char kTestData2[] = …;
const char kTestData3[] = …;
const char kTestData4[] = …;
const int kTestDataLength1 = …;
const int kTestDataLength2 = …;
const int kTestDataLength3 = …;
const int kTestDataLength4 = …;
int64_t kTestDataBytesWasted = …;
const uint8_t kHashOfTestData1[] = …;
const uint8_t kHashOfTestData1To3[] = …;
}
class BaseFileTest : public testing::Test { … };
const unsigned char BaseFileTest::kEmptySha256Hash[] = …;
TEST_F(BaseFileTest, CreateDestroy) { … }
TEST_F(BaseFileTest, Cancel) { … }
TEST_F(BaseFileTest, WriteAndDetach) { … }
TEST_F(BaseFileTest, WriteWithHashAndDetach) { … }
TEST_F(BaseFileTest, WriteThenRenameAndDetach) { … }
TEST_F(BaseFileTest, SingleWrite) { … }
TEST_F(BaseFileTest, MultipleWrites) { … }
TEST_F(BaseFileTest, MultipleWritesInterruptedWithHash) { … }
TEST_F(BaseFileTest, WriteThenRename) { … }
TEST_F(BaseFileTest, RenameWhileInProgress) { … }
#if BUILDFLAG(IS_FUCHSIA)
#define MAYBE_RenameWithError …
#else
#define MAYBE_RenameWithError …
#endif
TEST_F(BaseFileTest, MAYBE_RenameWithError) { … }
#if BUILDFLAG(IS_FUCHSIA)
#define MAYBE_RenameWithErrorInProgress …
#else
#define MAYBE_RenameWithErrorInProgress …
#endif
TEST_F(BaseFileTest, MAYBE_RenameWithErrorInProgress) { … }
#if BUILDFLAG(IS_FUCHSIA)
#define MAYBE_WriteWithError …
#else
#define MAYBE_WriteWithError …
#endif
TEST_F(BaseFileTest, MAYBE_WriteWithError) { … }
TEST_F(BaseFileTest, UninitializedFile) { … }
TEST_F(BaseFileTest, DuplicateBaseFile) { … }
TEST_F(BaseFileTest, AppendToBaseFile) { … }
#if BUILDFLAG(IS_FUCHSIA)
#define MAYBE_ReadonlyBaseFile …
#else
#define MAYBE_ReadonlyBaseFile …
#endif
TEST_F(BaseFileTest, MAYBE_ReadonlyBaseFile) { … }
TEST_F(BaseFileTest, ExistingBaseFileKnownHash) { … }
TEST_F(BaseFileTest, ExistingBaseFileUnknownHash) { … }
TEST_F(BaseFileTest, ExistingBaseFileIncorrectHash) { … }
TEST_F(BaseFileTest, ExistingBaseFileLargeSizeKnownHash) { … }
TEST_F(BaseFileTest, ExistingBaseFileLargeSizeIncorrectHash) { … }
TEST_F(BaseFileTest, ExistingBaseFileTooShort) { … }
TEST_F(BaseFileTest, ExistingBaseFileKnownHashTooLong) { … }
TEST_F(BaseFileTest, ExistingBaseFileUnknownHashTooLong) { … }
TEST_F(BaseFileTest, ExistingBaseFileUnknownHashTooLongForLargeFile) { … }
TEST_F(BaseFileTest, CreatedInDefaultDirectory) { … }
TEST_F(BaseFileTest, NoDoubleDeleteAfterCancel) { … }
TEST_F(BaseFileTest, WriteDataToSparseFile) { … }
TEST_F(BaseFileTest, ValidateDataInFile) { … }
}