chromium/chrome/browser/safe_browsing/cloud_content_scanning/file_analysis_request_unittest.cc

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

#include "chrome/browser/safe_browsing/cloud_content_scanning/file_analysis_request.h"

#include "base/containers/span.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/callback_helpers.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "build/build_config.h"
#include "chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.h"
#include "chrome/browser/enterprise/connectors/common.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/binary_upload_service.h"
#include "chrome/common/chrome_paths.h"
#include "components/enterprise/connectors/core/service_provider_config.h"
#include "components/file_access/scoped_file_access.h"
#include "components/file_access/scoped_file_access_delegate.h"
#include "components/file_access/test/mock_scoped_file_access_delegate.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace safe_browsing {

namespace {

// Helper to cast base::DoNothing.
BinaryUploadService::ContentAnalysisCallback DoNothingConnector() {}

// The mime type detected for each file can vary based on the platform/builder,
// so helper functions are used to validate that at least the returned type is
// one of multiple values.
bool IsDocMimeType(const std::string& mime_type) {}

bool IsZipMimeType(const std::string& mime_type) {}

}  // namespace

class FileAnalysisRequestTest : public testing::Test {};

TEST_F(FileAnalysisRequestTest, InvalidFiles) {}

TEST_F(FileAnalysisRequestTest, NormalFiles) {}

TEST_F(FileAnalysisRequestTest, NormalFilesDataControls) {}

// Disabled due to flakiness on Mac https://crbug.com/1229051
#if BUILDFLAG(IS_MAC)
#define MAYBE_LargeFiles
#else
#define MAYBE_LargeFiles
#endif

TEST_F(FileAnalysisRequestTest, MAYBE_LargeFiles) {}

TEST_F(FileAnalysisRequestTest, PopulatesDigest) {}

TEST_F(FileAnalysisRequestTest, PopulatesFilename) {}

TEST_F(FileAnalysisRequestTest, CachesResults) {}

TEST_F(FileAnalysisRequestTest, CachesResultsWithKnownMimetype) {}

TEST_F(FileAnalysisRequestTest, DelayedFileOpening) {}

TEST_F(FileAnalysisRequestTest, SuccessWithCorrectPassword) {}

TEST_F(FileAnalysisRequestTest, FileEncryptedWithIncorrectPassword) {}

// Class used to validate that an archive file is correctly detected and checked
// for encryption, even without a .zip/.rar extension.
class FileAnalysisRequestZipTest
    : public FileAnalysisRequestTest,
      public testing::WithParamInterface<const char*> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(FileAnalysisRequestZipTest, Encrypted) {}

}  // namespace safe_browsing