chromium/components/enterprise/browser/reporting/report_uploader_unittest.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/enterprise/browser/reporting/report_uploader.h"

#include <utility>

#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/enterprise/browser/reporting/report_request.h"
#include "components/enterprise/browser/reporting/report_type.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
#include "device_management_backend.pb.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

_;
Eq;
InSequence;
Property;
WithArgs;

em;

namespace enterprise_reporting {
namespace {
constexpr const char* kBrowserVersionNames[] =;
constexpr char kResponseMetricsName[] =;

// Returns a function that schedules a callback it is passed as second parameter
// with the given result. Useful to test `UploadReport` function.
auto ScheduleResponse(policy::CloudPolicyClient::Result result) {}

}  // namespace

class ReportUploaderTest : public ::testing::Test {};

class ReportUploaderTestWithTransientError
    : public ReportUploaderTest,
      public ::testing::WithParamInterface<policy::DeviceManagementStatus> {};

class ReportUploaderTestWithReportType
    : public ReportUploaderTest,
      public ::testing::WithParamInterface<ReportType> {};

// TODO(crbug.com/40483507) This death test does not work on Android.
#if defined(GTEST_HAS_DEATH_TEST) && !BUILDFLAG(IS_ANDROID)
TEST_F(ReportUploaderTest, NotRegisteredCrashes) {}
#endif  // defined(GTEST_HAS_DEATH_TEST) && !BUILDFLAG(IS_ANDROID)

TEST_F(ReportUploaderTest, PersistentError) {}

TEST_F(ReportUploaderTest, RequestTooBigError) {}

TEST_F(ReportUploaderTest, RetryAndSuccess) {}

TEST_F(ReportUploaderTest, RetryAndFailedWithPersistentError) {}

TEST_F(ReportUploaderTest, RetryAndFailedWithTransientError) {}

TEST_F(ReportUploaderTest, MultipleReports) {}

// Verified three DM server error that is transient.
TEST_P(ReportUploaderTestWithTransientError, WithoutRetry) {}

INSTANTIATE_TEST_SUITE_P();

TEST_P(ReportUploaderTestWithReportType, Success) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace enterprise_reporting