#include "base/files/important_file_writer.h"
#include <optional>
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/sequence_checker.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "base/timer/mock_timer.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace {
std::string GetFileContent(const FilePath& path) { … }
class DataSerializer : public ImportantFileWriter::DataSerializer { … };
class FailingDataSerializer : public ImportantFileWriter::DataSerializer { … };
class BackgroundDataSerializer
: public ImportantFileWriter::BackgroundDataSerializer { … };
enum WriteCallbackObservationState { … };
class WriteCallbacksObserver { … };
void WriteCallbacksObserver::ObserveNextWriteCallbacks(
ImportantFileWriter* writer) { … }
WriteCallbackObservationState
WriteCallbacksObserver::GetAndResetObservationState() { … }
}
class ImportantFileWriterTest : public testing::Test { … };
TEST_F(ImportantFileWriterTest, Basic) { … }
TEST_F(ImportantFileWriterTest, WriteWithObserver) { … }
TEST_F(ImportantFileWriterTest, FailedWriteWithObserver) { … }
TEST_F(ImportantFileWriterTest, CallbackRunsOnWriterThread) { … }
TEST_F(ImportantFileWriterTest, ScheduleWrite) { … }
TEST_F(ImportantFileWriterTest, DoScheduledWrite) { … }
TEST_F(ImportantFileWriterTest, BatchingWrites) { … }
TEST_F(ImportantFileWriterTest, ScheduleWrite_FailToSerialize) { … }
TEST_F(ImportantFileWriterTest, ScheduleWrite_WriteNow) { … }
TEST_F(ImportantFileWriterTest, DoScheduledWrite_FailToSerialize) { … }
TEST_F(ImportantFileWriterTest, ScheduleWriteWithBackgroundDataSerializer) { … }
TEST_F(ImportantFileWriterTest,
ScheduleWriteWithBackgroundDataSerializer_FailToSerialize) { … }
TEST_F(ImportantFileWriterTest, WriteLargeFile) { … }
TEST_F(ImportantFileWriterTest, SerializationDuration) { … }
TEST_F(ImportantFileWriterTest, SerializationDurationWithCustomSuffix) { … }
}