#include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.h"
#include <stdint.h>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include "base/auto_reset.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/mock_entropy_provider.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_mock_time_message_loop_task_runner.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident_report_uploader.h"
#include "chrome/browser/safe_browsing/incident_reporting/last_download_finder.h"
#include "chrome/browser/safe_browsing/incident_reporting/tracked_preference_incident.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/safe_browsing/core/common/proto/csd.pb.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/test/browser_task_environment.h"
#include "extensions/browser/quota_service.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/base/attributes.h"
#if BUILDFLAG(IS_WIN)
#include "base/test/test_reg_util_win.h"
#endif
namespace {
class TestIncidentReportingService;
ABSL_CONST_INIT thread_local TestIncidentReportingService* test_instance = …;
constexpr char kFakeOsName[] = …;
constexpr char kFakeDownloadToken[] = …;
constexpr char kFakeDownloadHost[] = …;
constexpr char kTestTrackedPrefPath[] = …;
constexpr char kFakeExtensionId[] = …;
class TestIncidentReportingService
: public safe_browsing::IncidentReportingService { … };
class IncidentReportingServiceTest : public testing::Test { … };
void IncidentReportingServiceTest::ExpectTestIncidentUploadWithBinaryDownload(
int incident_count) { … }
void IncidentReportingServiceTest::
ExpectTestIncidentUploadWithNonBinaryDownload(int incident_count) { … }
void IncidentReportingServiceTest::ExpectTestIncidentUploadWithBothDownloads(
int incident_count) { … }
TEST_F(IncidentReportingServiceTest, AddIncident) { … }
TEST_F(IncidentReportingServiceTest, CoalesceIncidents) { … }
TEST_F(IncidentReportingServiceTest, NoSafeBrowsing) { … }
TEST_F(IncidentReportingServiceTest, NoUploadBeforeExtendedReporting) { … }
TEST_F(IncidentReportingServiceTest, NoDownloadNoUpload) { … }
TEST_F(IncidentReportingServiceTest, NoDownloadPrunedIncidentOneUpload) { … }
TEST_F(IncidentReportingServiceTest, NoDownloadPrunedSameIncidentNoUpload) { … }
TEST_F(IncidentReportingServiceTest, NoProfilesNoUpload) { … }
TEST_F(IncidentReportingServiceTest, OneIncidentOneUpload) { … }
TEST_F(IncidentReportingServiceTest, TwoIncidentsTwoUploads) { … }
TEST_F(IncidentReportingServiceTest, TwoProfilesTwoUploads) { … }
TEST_F(IncidentReportingServiceTest, ProfileDestroyedDuringUpload) { … }
TEST_F(IncidentReportingServiceTest, ProcessWideNoProfileNoUpload) { … }
TEST_F(IncidentReportingServiceTest, ProcessWideOneUpload) { … }
TEST_F(IncidentReportingServiceTest, ProcessWideTwoUploads) { … }
TEST_F(IncidentReportingServiceTest, ProcessWideNoUploadAfterProfile) { … }
TEST_F(IncidentReportingServiceTest, NoCollectionWithoutIncident) { … }
TEST_F(IncidentReportingServiceTest, AnalysisAfterProfile) { … }
TEST_F(IncidentReportingServiceTest, AnalysisWhenRegisteredWithProfile) { … }
TEST_F(IncidentReportingServiceTest, DelayedAnalysisNoProfileNoUpload) { … }
TEST_F(IncidentReportingServiceTest, DelayedAnalysisOneUpload) { … }
TEST_F(IncidentReportingServiceTest, NoDownloadNoWaiting) { … }
TEST_F(IncidentReportingServiceTest, NonBinaryDownloadStillUploads) { … }
TEST_F(IncidentReportingServiceTest, UploadsWithBothDownloadTypes) { … }
TEST_F(IncidentReportingServiceTest, CleanLegacyPruneState) { … }
TEST_F(IncidentReportingServiceTest, ProcessWideUploadClearUpload) { … }
TEST_F(IncidentReportingServiceTest, ClearProcessIncidentOnCleanState) { … }
}