#include "chrome/browser/safe_browsing/incident_reporting/download_metadata_manager.h"
#include <stdint.h>
#include <memory>
#include <string>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "chrome/test/base/testing_profile.h"
#include "components/download/public/common/mock_download_item.h"
#include "components/download/public/common/simple_download_manager_coordinator.h"
#include "components/safe_browsing/core/common/proto/csd.pb.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_item_utils.h"
#include "content/public/browser/download_manager.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/mock_download_manager.h"
#include "content/public/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
AllOf;
Eq;
IsNull;
Ne;
NiceMock;
NotNull;
ResultOf;
Return;
SaveArg;
StrEq;
_;
namespace safe_browsing {
namespace {
const uint32_t kTestDownloadId = …;
const uint32_t kOtherDownloadId = …;
const uint32_t kCrazyDowloadId = …;
const uint32_t kUninitializedDowloadId = …;
const int64_t kTestDownloadTimeMsec = …;
const char kTestUrl[] = …;
const uint64_t kTestDownloadLength = …;
const double kTestDownloadEndTimeMs = …;
class DownloadDetailsGetter { … };
class MockDownloadDetailsGetter : public DownloadDetailsGetter { … };
class MockDownloadMetadataManager : public DownloadMetadataManager { … };
const std::string& GetDetailsDownloadUrl(
const ClientIncidentReport_DownloadDetails* details) { … }
int64_t GetDetailsOpenTime(
const ClientIncidentReport_DownloadDetails* details) { … }
class MockDownloadManager : public content::MockDownloadManager { … };
}
class DownloadMetadataManagerTestBase : public ::testing::Test { … };
class GetDetailsTest
: public DownloadMetadataManagerTestBase,
public ::testing::WithParamInterface<testing::tuple<const char*,
const char*,
const char*,
const char*,
const char*>> { … };
TEST_P(GetDetailsTest, GetDownloadDetails) { … }
INSTANTIATE_TEST_SUITE_P(…);
class SetRequestTest
: public DownloadMetadataManagerTestBase,
public ::testing::WithParamInterface<testing::tuple<const char*,
const char*,
const char*,
const char*,
const char*>> { … };
TEST_P(SetRequestTest, SetRequest) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(DownloadMetadataManagerTestBase, ActiveDownloadNoRequest) { … }
TEST_F(DownloadMetadataManagerTestBase, ActiveDownloadWithRequest) { … }
TEST_F(DownloadMetadataManagerTestBase, OpenItemWithZeroId) { … }
TEST_F(DownloadMetadataManagerTestBase, UninitializedActiveDownload) { … }
}