chromium/remoting/host/file_transfer/local_file_operations_unittest.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "remoting/host/file_transfer/local_file_operations.h"

#include "base/containers/queue.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/path_service.h"
#include "base/test/scoped_path_override.h"
#include "base/test/task_environment.h"
#include "remoting/host/file_transfer/directory_helpers.h"
#include "remoting/host/file_transfer/ensure_user.h"
#include "remoting/host/file_transfer/fake_file_chooser.h"
#include "remoting/host/file_transfer/test_byte_vector_utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace remoting {

namespace {

// BindOnce disallows binding lambdas with captures. This is reasonable in
// production code, as it requires one to either explicitly pass owned objects
// or pointers using Owned, Unretained, et cetera. This helps to avoid use-
// after-free bugs in async code. In test code, though, where the lambda is
// immediately invoked in the test method using, e.g., RunUntilIdle, the ability
// to capture can make the code much easier to read and write.
template <typename T>
auto BindLambda(T lambda) {}

}  // namespace

class LocalFileOperationsTest : public testing::Test {};

LocalFileOperationsTest::LocalFileOperationsTest()
    :{}

void LocalFileOperationsTest::SetUp() {}

void LocalFileOperationsTest::TearDown() {}

base::FilePath LocalFileOperationsTest::TestDir() {}

void LocalFileOperationsTest::WriteFile(
    const base::FilePath& filename,
    base::queue<std::vector<std::uint8_t>> chunks,
    bool close) {}

void LocalFileOperationsTest::OnOperationComplete(
    base::queue<std::vector<std::uint8_t>> remaining_chunks,
    bool close,
    FileOperations::Writer::Result result) {}

void LocalFileOperationsTest::OnCloseComplete(
    FileOperations::Writer::Result result) {}

// Verifies that a file consisting of three chunks can be written successfully.
TEST_F(LocalFileOperationsTest, WritesThreeChunks) {}

// Verifies that a file with a small last chunk can be written successfully.
TEST_F(LocalFileOperationsTest, WritesSmallTail) {}

// Verifies that LocalFileOperations will write to a file named "file (1).txt"
// if "file.txt" already exists, and "file (2).txt" after that.
TEST_F(LocalFileOperationsTest, RenamesFileIfExists) {}

// Verifies that dropping early deletes the temporary file.
TEST_F(LocalFileOperationsTest, DroppingDeletesTemp) {}

// Verifies that dropping works while an operation is pending.
TEST_F(LocalFileOperationsTest, CancelsWhileOperationPending) {}

// Verifies that a file can be successfully opened for reading.
TEST_F(LocalFileOperationsTest, OpensReader) {}

// Verifies that a file can be successfully read in three chunks.
TEST_F(LocalFileOperationsTest, ReadsThreeChunks) {}

// Verifies proper EOF handling.
TEST_F(LocalFileOperationsTest, ReaderHandlesEof) {}

// Verifies cancellation is propagated.
TEST_F(LocalFileOperationsTest, ReaderCancels) {}

// Verifies failure when file doesn't exist.
TEST_F(LocalFileOperationsTest, FileNotFound) {}

}  // namespace remoting