chromium/chrome/browser/download/download_browsertest_utils.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "chrome/browser/download/download_browsertest_utils.h"

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/memory/raw_ptr.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/test_file_util.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/download_request_utils.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "third_party/blink/public/common/switches.h"
#include "ui/views/views_switches.h"

DownloadManager;
WebContents;
DownloadItem;
DownloadUrlParameters;
Extension;

DownloadManager* DownloadManagerForBrowser(Browser* browser) {}

void SetPromptForDownload(Browser* browser, bool prompt_for_download) {}

DownloadTestObserverResumable::DownloadTestObserverResumable(
    DownloadManager* download_manager,
    size_t transition_count)
    :{}

DownloadTestObserverResumable::~DownloadTestObserverResumable() = default;

bool DownloadTestObserverResumable::IsDownloadInFinalState(
    DownloadItem* download) {}

DownloadTestObserverNotInProgress::DownloadTestObserverNotInProgress(
    DownloadManager* download_manager,
    size_t count)
    :{}

DownloadTestObserverNotInProgress::~DownloadTestObserverNotInProgress() =
    default;

void DownloadTestObserverNotInProgress::StartObserving() {}

bool DownloadTestObserverNotInProgress::IsDownloadInFinalState(
    DownloadItem* download) {}

DownloadTestBase::DownloadTestBase() = default;

DownloadTestBase::~DownloadTestBase() = default;

void DownloadTestBase::SetUpOnMainThread() {}

void DownloadTestBase::SetUpCommandLine(base::CommandLine* command_line) {}

void DownloadTestBase::TearDownOnMainThread() {}

bool DownloadTestBase::CheckTestDir() {}

bool DownloadTestBase::InitialSetup() {}

base::FilePath DownloadTestBase::GetTestDataDirectory() {}

base::FilePath DownloadTestBase::OriginFile(const base::FilePath& file) {}

base::FilePath DownloadTestBase::DestinationFile(Browser* browser,
                                                 const base::FilePath& file) {}

content::TestDownloadResponseHandler*
DownloadTestBase::test_response_handler() {}

DownloadPrefs* DownloadTestBase::GetDownloadPrefs(Browser* browser) {}

base::FilePath DownloadTestBase::GetDownloadDirectory(Browser* browser) {}

content::DownloadTestObserver* DownloadTestBase::CreateWaiter(
    Browser* browser,
    int num_downloads) {}

content::DownloadTestObserver* DownloadTestBase::CreateInProgressWaiter(
    Browser* browser,
    int num_downloads) {}

content::DownloadTestObserver* DownloadTestBase::DangerousDownloadWaiter(
    Browser* browser,
    int num_downloads,
    content::DownloadTestObserver::DangerousDownloadAction
        dangerous_download_action) {}

void DownloadTestBase::CheckDownloadStatesForBrowser(
    Browser* browser,
    size_t num,
    DownloadItem::DownloadState state) {}

void DownloadTestBase::CheckDownloadStates(size_t num,
                                           DownloadItem::DownloadState state) {}

bool DownloadTestBase::VerifyNoDownloads() const {}

void DownloadTestBase::DownloadAndWaitWithDisposition(
    Browser* browser,
    const GURL& url,
    WindowOpenDisposition disposition,
    int browser_test_flags,
    bool prompt_for_download) {}

void DownloadTestBase::DownloadAndWait(Browser* browser,
                                       const GURL& url,
                                       bool prompt_for_download) {}

bool DownloadTestBase::CheckDownload(Browser* browser,
                                     const base::FilePath& downloaded_filename,
                                     const base::FilePath& origin_filename) {}

bool DownloadTestBase::CheckDownloadFullPaths(
    Browser* browser,
    const base::FilePath& downloaded_file,
    const base::FilePath& origin_file) {}

DownloadItem* DownloadTestBase::CreateSlowTestDownload(Browser* browser) {}

bool DownloadTestBase::RunSizeTest(Browser* browser,
                                   SizeTestType type,
                                   const std::string& partial_indication,
                                   const std::string& total_indication) {}

void DownloadTestBase::GetDownloads(
    Browser* browser,
    std::vector<raw_ptr<DownloadItem, VectorExperimental>>* downloads) const {}

// static
void DownloadTestBase::ExpectWindowCountAfterDownload(size_t expected) {}

void DownloadTestBase::EnableFileChooser(bool enable) {}

bool DownloadTestBase::DidShowFileChooser() {}

bool DownloadTestBase::VerifyFile(const base::FilePath& path,
                                  const std::string& value,
                                  const int64_t file_size) {}

void DownloadTestBase::DownloadFilesCheckErrorsSetup() {}

void DownloadTestBase::DownloadFilesCheckErrorsLoopBody(
    const DownloadInfo& download_info,
    size_t i) {}

void DownloadTestBase::DownloadFilesCheckErrors(size_t count,
                                                DownloadInfo* download_info) {}

void DownloadTestBase::DownloadInsertFilesErrorCheckErrorsLoopBody(
    scoped_refptr<content::TestFileErrorInjector> injector,
    const FileErrorInjectInfo& info,
    size_t i) {}

void DownloadTestBase::DownloadInsertFilesErrorCheckErrors(
    size_t count,
    FileErrorInjectInfo* info) {}

// Attempts to download a file to a read-only folder, based on information
// in |download_info|.
void DownloadTestBase::DownloadFilesToReadonlyFolder(
    size_t count,
    DownloadInfo* download_info) {}

DownloadItem* DownloadTestBase::StartMockDownloadAndInjectError(
    content::TestFileErrorInjector* error_injector,
    download::DownloadInterruptReason error) {}