#include "components/download/internal/background_service/controller_impl.h"
#include <stdint.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_util.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/test/test_simple_task_runner.h"
#include "base/uuid.h"
#include "components/download/internal/background_service/client_set.h"
#include "components/download/internal/background_service/config.h"
#include "components/download/internal/background_service/entry.h"
#include "components/download/internal/background_service/entry_utils.h"
#include "components/download/internal/background_service/file_monitor.h"
#include "components/download/internal/background_service/model_impl.h"
#include "components/download/internal/background_service/navigation_monitor_impl.h"
#include "components/download/internal/background_service/scheduler/scheduler.h"
#include "components/download/internal/background_service/stats.h"
#include "components/download/internal/background_service/test/black_hole_log_sink.h"
#include "components/download/internal/background_service/test/entry_utils.h"
#include "components/download/internal/background_service/test/mock_file_monitor.h"
#include "components/download/internal/background_service/test/test_device_status_listener.h"
#include "components/download/internal/background_service/test/test_download_driver.h"
#include "components/download/internal/background_service/test/test_store.h"
#include "components/download/public/background_service/test/empty_client.h"
#include "components/download/public/background_service/test/empty_logger.h"
#include "components/download/public/background_service/test/mock_client.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/resource_request_body.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
NiceMock;
Return;
SaveArg;
namespace download {
namespace {
const base::FilePath::CharType kDownloadDirPath[] = …);
constexpr char kKey[] = …;
constexpr char kValue[] = …;
bool GuidInEntryList(const std::vector<Entry>& entries,
const std::string& guid) { … }
DriverEntry BuildDriverEntry(const Entry& entry, DriverEntry::State state) { … }
class UploadClient : public test::MockClient { … };
void UploadClient::GetUploadData(const std::string& guid,
GetUploadDataCallback callback) { … }
void UploadClient::SetUploadResponseDelayForGuid(const std::string& guid,
unsigned int delay) { … }
class MockTaskScheduler : public TaskScheduler { … };
class MockScheduler : public Scheduler { … };
class DownloadServiceControllerImplTest : public testing::Test { … };
}
TEST_F(DownloadServiceControllerImplTest, SuccessfulInitModelFirst) { … }
TEST_F(DownloadServiceControllerImplTest, SuccessfulInitDriverFirst) { … }
TEST_F(DownloadServiceControllerImplTest, HardRecoveryAfterFailedModel) { … }
TEST_F(DownloadServiceControllerImplTest, HardRecoveryAfterFailedFileMonitor) { … }
TEST_F(DownloadServiceControllerImplTest, HardRecoveryFails) { … }
TEST_F(DownloadServiceControllerImplTest, SuccessfulInitWithExistingDownload) { … }
TEST_F(DownloadServiceControllerImplTest, UnknownFileDeletion) { … }
TEST_F(DownloadServiceControllerImplTest,
CleanupTaskCallsFileMonitorAndSchedulesNewTaskInFuture) { … }
TEST_F(DownloadServiceControllerImplTest,
OnStartScheduledTaskCallbackInvokedIfControllerNotReady) { … }
TEST_F(DownloadServiceControllerImplTest, GetOwnerOfDownload) { … }
TEST_F(DownloadServiceControllerImplTest, AddDownloadAccepted) { … }
TEST_F(DownloadServiceControllerImplTest, AddDownloadFailsWithBackoff) { … }
TEST_F(DownloadServiceControllerImplTest,
AddDownloadFailsWithDuplicateGuidInModel) { … }
TEST_F(DownloadServiceControllerImplTest, AddDownloadFailsWithDuplicateCall) { … }
TEST_F(DownloadServiceControllerImplTest, AddDownloadFailsWithBadClient) { … }
TEST_F(DownloadServiceControllerImplTest, AddDownloadFailsWithClientCancel) { … }
TEST_F(DownloadServiceControllerImplTest, AddDownloadFailsWithInternalError) { … }
TEST_F(DownloadServiceControllerImplTest, Pause) { … }
TEST_F(DownloadServiceControllerImplTest, Resume) { … }
TEST_F(DownloadServiceControllerImplTest, Cancel) { … }
TEST_F(DownloadServiceControllerImplTest, OnDownloadFailed) { … }
TEST_F(DownloadServiceControllerImplTest, OnDownloadFailedFromDriverCancel) { … }
TEST_F(DownloadServiceControllerImplTest, NoopResumeDoesNotHitAttemptCounts) { … }
TEST_F(DownloadServiceControllerImplTest, RetryOnFailure) { … }
TEST_F(DownloadServiceControllerImplTest, OnDownloadSucceeded) { … }
TEST_F(DownloadServiceControllerImplTest, CompletionInfoPropagated) { … }
TEST_F(DownloadServiceControllerImplTest, CleanupTaskScheduledAtEarliestTime) { … }
TEST_F(DownloadServiceControllerImplTest, OnDownloadUpdated) { … }
TEST_F(DownloadServiceControllerImplTest, DownloadCompletionTest) { … }
TEST_F(DownloadServiceControllerImplTest,
UploadTestForSuccessPauseCancelFailureTimeout) { … }
TEST_F(DownloadServiceControllerImplTest, StartupRecovery) { … }
TEST_F(DownloadServiceControllerImplTest, StartupRecoveryForUploadEntries) { … }
TEST_F(DownloadServiceControllerImplTest, StartupRecoveryNoResponseHeaders) { … }
TEST_F(DownloadServiceControllerImplTest, ExistingExternalDownload) { … }
TEST_F(DownloadServiceControllerImplTest, NewExternalDownload) { … }
TEST_F(DownloadServiceControllerImplTest, CancelTimeTest) { … }
TEST_F(DownloadServiceControllerImplTest, RemoveCleanupEligibleDownloads) { … }
TEST_F(DownloadServiceControllerImplTest, ThrottlingConfigMaxRunning) { … }
TEST_F(DownloadServiceControllerImplTest, ThrottlingConfigMaxConcurrent) { … }
TEST_F(DownloadServiceControllerImplTest, DownloadTaskQueuesAfterFinish) { … }
TEST_F(DownloadServiceControllerImplTest, CleanupTaskQueuesAfterFinish) { … }
}