#include "components/enterprise/browser/reporting/report_scheduler.h"
#include <utility>
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/strcat.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/enterprise/reporting/prefs.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/upgrade_detector/build_state.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/enterprise/browser/controller/fake_browser_dm_token_storage.h"
#include "components/enterprise/browser/reporting/chrome_profile_request_generator.h"
#include "components/enterprise/browser/reporting/common_pref_names.h"
#include "components/enterprise/browser/reporting/report_generator.h"
#include "components/enterprise/browser/reporting/report_request.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
#include "components/reporting/client/report_queue_provider.h"
#include "components/reporting/proto/synced/record_constants.pb.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/version_info/version_info.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/enterprise/reporting/report_scheduler_android.h"
#include "chrome/browser/enterprise/reporting/reporting_delegate_factory_android.h"
#else
#include "chrome/browser/enterprise/reporting/report_scheduler_desktop.h"
#include "chrome/browser/enterprise/reporting/reporting_delegate_factory_desktop.h"
#endif
RunOnceCallback;
_;
ByMove;
DoAll;
Invoke;
InvokeWithoutArgs;
Return;
WithArgs;
em;
namespace enterprise_reporting {
namespace {
constexpr char kDMToken[] = …;
constexpr char kClientId[] = …;
constexpr base::TimeDelta kUploadFrequency = …;
constexpr base::TimeDelta kNewUploadFrequency = …;
constexpr char kUploadTriggerMetricName[] = …;
}
ACTION_P(ScheduleGeneratorCallback, request_number) { … }
ACTION(ScheduleProfileRequestGeneratorCallback) { … }
class MockReportGenerator : public ReportGenerator { … };
class MockReportUploader : public ReportUploader { … };
class MockChromeProfileRequestGenerator : public ChromeProfileRequestGenerator { … };
class ReportSchedulerTest : public ::testing::Test { … };
TEST_F(ReportSchedulerTest, NoReportWithoutPolicy) { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(ReportSchedulerTest, NoReportWithoutDMToken) { … }
TEST_F(ReportSchedulerTest, NoReportWithoutClientId) { … }
#endif
TEST_F(ReportSchedulerTest, UploadReportSucceeded) { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(ReportSchedulerTest, UploadReportSucceededForProfileReporting) { … }
#endif
TEST_F(ReportSchedulerTest, UploadReportTransientError) { … }
TEST_F(ReportSchedulerTest, UploadReportPersistentError) { … }
TEST_F(ReportSchedulerTest, NoReportGenerate) { … }
TEST_F(ReportSchedulerTest, TimerDelayWithLastUploadTimestamp) { … }
TEST_F(ReportSchedulerTest, TimerDelayWithoutLastUploadTimestamp) { … }
TEST_F(ReportSchedulerTest, TimerDelayUpdate) { … }
TEST_F(ReportSchedulerTest, IgnoreFrequencyWithoutReportEnabled) { … }
TEST_F(ReportSchedulerTest,
ReportingIsDisabledWhileNewReportIsScheduledButNotPosted) { … }
TEST_F(ReportSchedulerTest, ReportingIsDisabledWhileNewReportIsPosted) { … }
TEST_F(ReportSchedulerTest, ManualReport) { … }
TEST_F(ReportSchedulerTest, ScheduledReportAfterManualReport) { … }
TEST_F(ReportSchedulerTest, ManualReportWithRegularOneOngoing) { … }
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(ReportSchedulerTest, OnUpdate) { … }
TEST_F(ReportSchedulerTest, OnUpdateAndPersistentError) { … }
TEST_F(ReportSchedulerTest, DeferredTimer) { … }
TEST_F(ReportSchedulerTest, OnNewVersion) { … }
TEST_F(ReportSchedulerTest, OnNewVersionRegularReport) { … }
#endif
}