#include <optional>
#include <string_view>
#include "base/memory/scoped_refptr.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "base/types/expected.h"
#include "build/build_config.h"
#include "chrome/browser/enterprise/browser_management/management_service_factory.h"
#include "chrome/browser/policy/messaging_layer/proto/synced/log_upload_event.pb.h"
#include "chrome/browser/policy/messaging_layer/public/report_client_test_util.h"
#include "chrome/browser/policy/messaging_layer/upload/file_upload_job.h"
#include "chrome/browser/policy/messaging_layer/upload/file_upload_job_test_util.h"
#include "chrome/browser/policy/messaging_layer/upload/record_handler_impl.h"
#include "chrome/browser/policy/messaging_layer/upload/server_uploader.h"
#include "chrome/browser/policy/messaging_layer/util/reporting_server_connector.h"
#include "chrome/browser/policy/messaging_layer/util/reporting_server_connector_test_util.h"
#include "chrome/browser/policy/messaging_layer/util/test_request_payload.h"
#include "chrome/browser/policy/messaging_layer/util/test_response_payload.h"
#include "components/policy/core/common/management/scoped_management_service_override_for_testing.h"
#include "components/reporting/proto/synced/record.pb.h"
#include "components/reporting/proto/synced/record_constants.pb.h"
#include "components/reporting/proto/synced/status.pb.h"
#include "components/reporting/proto/synced/upload_tracker.pb.h"
#include "components/reporting/resources/resource_manager.h"
#include "components/reporting/storage/test_storage_module.h"
#include "components/reporting/util/status.h"
#include "components/reporting/util/statusor.h"
#include "components/reporting/util/test_support_callbacks.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_CHROMEOS)
#include "base/uuid.h"
#endif
_;
AllOf;
Between;
Eq;
Ge;
Gt;
Invoke;
IsEmpty;
Lt;
Not;
NotNull;
Property;
SizeIs;
StrEq;
WithArgs;
LogUploadEvent;
namespace reporting {
namespace {
constexpr char kUploadFileName[] = …;
constexpr char kSessionToken[] = …;
constexpr char kUploadParameters[] = …;
constexpr char kAccessParameters[] = …;
MATCHER_P(ResponseEquals,
expected,
"Compares StatusOr<response> to expected response") { … }
class MockFileUploadDelegate : public FileUploadJob::Delegate { … };
class RecordHandlerUploadTest : public ::testing::Test { … };
EncryptedRecord ComposeEncryptedRecord(
std::string_view data,
UploadSettings upload_settings,
std::optional<UploadTracker> upload_tracker) { … }
UploadSettings ComposeUploadSettings(int64_t retry_count = 1) { … }
UploadTracker ComposeUploadTracker(int64_t total, int64_t uploaded) { … }
UploadTracker ComposeDoneTracker(int64_t total) { … }
::testing::Matcher<LogUploadEvent> MatchSettings(int64_t retry_count = 1) { … }
::testing::Matcher<LogUploadEvent> MatchTrackerInProgress(
int64_t uploaded,
int64_t total,
std::string_view session_token) { … }
::testing::Matcher<LogUploadEvent> MatchTrackerFinished(
int64_t total,
std::string_view access_parameters) { … }
::testing::Matcher<LogUploadEvent> MatchError(Status status) { … }
TEST_F(RecordHandlerUploadTest, SuccessfulInitiation) { … }
TEST_F(RecordHandlerUploadTest, SuccessfulNextStep) { … }
TEST_F(RecordHandlerUploadTest, SuccessfulFinalize) { … }
TEST_F(RecordHandlerUploadTest, AlreadyFinalized) { … }
TEST_F(RecordHandlerUploadTest, FailedProcessing) { … }
TEST_F(RecordHandlerUploadTest, RepeatedInitiationAttempts) { … }
TEST_F(RecordHandlerUploadTest, InitiationFailureTriggersRetry) { … }
TEST_F(RecordHandlerUploadTest, RepeatedNextStepAttempts) { … }
TEST_F(RecordHandlerUploadTest, NextStepFailureTriggersRetry) { … }
TEST_F(RecordHandlerUploadTest, RepeatedFinalizeAttempts) { … }
TEST_F(RecordHandlerUploadTest, FinalizeFailureTriggersRetry) { … }
}
}