chromium/components/reporting/client/report_queue_impl_unittest.cc

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

#include "components/reporting/client/report_queue_impl.h"

#include <cstddef>
#include <memory>
#include <optional>
#include <utility>

#include "base/containers/queue.h"
#include "base/json/json_reader.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "base/test/gtest_util.h"
#include "base/test/task_environment.h"
#include "base/types/expected.h"
#include "base/values.h"
#include "components/reporting/client/mock_report_queue.h"
#include "components/reporting/client/report_queue_configuration.h"
#include "components/reporting/proto/synced/record_constants.pb.h"
#include "components/reporting/proto/test.pb.h"
#include "components/reporting/storage/storage_module_interface.h"
#include "components/reporting/storage/test_storage_module.h"
#include "components/reporting/util/rate_limiter_interface.h"
#include "components/reporting/util/status.h"
#include "components/reporting/util/status_macros.h"
#include "components/reporting/util/statusor.h"
#include "components/reporting/util/test_support_callbacks.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

_;
AllOf;
EndsWith;
Eq;
Invoke;
MockFunction;
NiceMock;
Not;
NotNull;
Property;
Return;
StrEq;
WithArg;

TestStorageModule;

namespace reporting {
namespace {

constexpr char kTestMessage[] =;

class MockRateLimiter : public RateLimiterInterface {};

// Creates a |ReportQueue| using |TestStorageModule| and
// |TestEncryptionModule|. Allows access to the storage module for checking
// stored values.
class ReportQueueImplTest : public testing::Test {};

// Enqueues a random string and ensures that the string arrives unaltered in the
// |StorageModuleInterface|.
TEST_F(ReportQueueImplTest, SuccessfulStringRecord) {}

// Enqueues a |base::Value| dictionary and ensures it arrives unaltered in the
// |StorageModuleInterface|.
TEST_F(ReportQueueImplTest, SuccessfulBaseValueRecord) {}

// Enqueues a |TestMessage| and ensures that it arrives unaltered in the
// |StorageModuleInterface|.
TEST_F(ReportQueueImplTest, SuccessfulProtoRecord) {}

// Verifies that records sent to `Destination::EVENT_METRIC` are `MetricData`
// protos.
TEST_F(ReportQueueImplTest,
       NonMetricDataFailsToEnqueueToEventMetricDestination) {}

// Verifies that records sent to `Destination::TELEMETRY_METRIC` are
// `MetricData` protos.
TEST_F(ReportQueueImplTest,
       NonMetricDataFailsToEnqueueToTelemetryMetricDestination) {}

// Verifies that records sent to `Destination::INFO_METRIC` are
// `MetricData` protos.
TEST_F(ReportQueueImplTest,
       NonMetricDataFailsToEnqueueToInfoMetricDestination) {}

TEST_F(ReportQueueImplTest, SuccessfulProtoRecordWithRateLimiter) {}

TEST_F(ReportQueueImplTest, SuccessfulProtoRecordWithReservedSpace) {}

TEST_F(ReportQueueImplTest, SuccessfulProtoRecordWithSource) {}

TEST_F(ReportQueueImplTest, SuccessfulProtoRecordWithSourceVersion) {}

// The call to enqueue should succeed, indicating that the storage operation has
// been scheduled. The callback should fail, indicating that storage was
// unsuccessful.
TEST_F(ReportQueueImplTest, CallSuccessCallbackFailure) {}

TEST_F(ReportQueueImplTest, EnqueueStringFailsOnPolicy) {}

TEST_F(ReportQueueImplTest, EnqueueProtoFailsOnPolicy) {}

TEST_F(ReportQueueImplTest, EnqueueValueFailsOnPolicy) {}

TEST_F(ReportQueueImplTest, EnqueueAndFlushSuccess) {}

TEST_F(ReportQueueImplTest, EnqueueSuccessFlushFailure) {}

// Enqueues a random string into speculative queue, then enqueues a sting,
// attaches actual one and ensures that the string arrives unaltered in the
// |StorageModuleInterface|.
TEST_F(ReportQueueImplTest, SuccessfulSpeculativeStringRecord) {}

TEST_F(ReportQueueImplTest, SuccessfulSpeculativeStringRecordWithRateLimiter) {}

TEST_F(ReportQueueImplTest,
       SuccessfulSpeculativeStringRecordWithReservedSpace) {}

TEST_F(ReportQueueImplTest, SuccessfulSpeculativeStringRecordWithSource) {}

TEST_F(ReportQueueImplTest,
       SuccessfulSpeculativeStringRecordWithSourceVersion) {}

TEST_F(ReportQueueImplTest, SpeculativeQueueMultipleRecordsAfterCreation) {}

TEST_F(ReportQueueImplTest, SpeculativeQueueCreationFailedToCreate) {}

TEST_F(ReportQueueImplTest, SpeculativeQueueEnqueueAndCreationFailed) {}

TEST_F(ReportQueueImplTest, EnqueueRecordWithInvalidPriority) {}

TEST_F(ReportQueueImplTest, FlushSpeculativeReportQueue) {}

TEST_F(ReportQueueImplTest, FlushUninitializedSpeculativeReportQueue) {}

TEST_F(ReportQueueImplTest, FlushFailedSpeculativeReportQueue) {}

TEST_F(ReportQueueImplTest, AsyncProcessingReportQueue) {}

TEST_F(ReportQueueImplTest, AsyncProcessingSpeculativeReportQueue) {}

TEST_F(ReportQueueImplTest, GetDestinationForReportQueue) {}

TEST_F(ReportQueueImplTest, GetDestinationForSpeculativeReportQueueBeforeInit) {}

TEST_F(ReportQueueImplTest, GetDestinationForSpeculativeReportQueueAfterInit) {}
}  // namespace
}  // namespace reporting