#include "components/metrics/structured/structured_metrics_recorder.h"
#include <cstdint>
#include <memory>
#include <utility>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/threading/scoped_blocking_call.h"
#include "components/metrics/structured/event.h"
#include "components/metrics/structured/proto/event_storage.pb.h"
#include "components/metrics/structured/recorder.h"
#include "components/metrics/structured/structured_events.h"
#include "components/metrics/structured/structured_metrics_client.h"
#include "components/metrics/structured/structured_metrics_features.h"
#include "components/metrics/structured/test/test_event_storage.h"
#include "components/metrics/structured/test/test_key_data_provider.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/metrics_proto/chrome_user_metrics_extension.pb.h"
namespace metrics::structured {
namespace {
constexpr uint64_t kProjectOneHash = …16881314472396226433);
constexpr uint64_t kProjectTwoHash = …5876808001962504629);
constexpr uint64_t kProjectThreeHash = …10860358748803291132);
constexpr uint64_t kProjectFourHash = …6801665881746546626);
constexpr uint64_t kProjectFiveHash = …3960582687892677139);
constexpr uint64_t kProjectSixHash = …6972396123792667134);
constexpr uint64_t kCrOSEventsProjectHash = …12657197978410187837);
constexpr uint64_t kEventOneHash = …13593049295042080097);
constexpr uint64_t kEventTwoHash = …8995967733561999410);
constexpr uint64_t kEventThreeHash = …5848687377041124372);
constexpr uint64_t kEventFiveHash = …7045523601811399253);
constexpr uint64_t kEventSixHash = …2873337042686447043);
constexpr uint64_t kEventSevenHash = …16749091071228286247);
constexpr uint64_t kEventEnumHash = …14837072141472316574);
constexpr uint64_t kNoMetricsEventHash = …5106854608989380457);
const uint64_t kEventEightHash = …16290206418240617738);
constexpr uint64_t kMetricOneHash = …637929385654885975);
constexpr uint64_t kMetricTwoHash = …14083999144141567134);
constexpr uint64_t kMetricThreeHash = …13469300759843809564);
constexpr uint64_t kMetricFiveHash = …8665976921794972190);
constexpr uint64_t kMetricSixHash = …3431522567539822144);
constexpr uint64_t kMetricSevenHash = …8395865158198697574);
constexpr uint64_t kMetricEnumHash = …16584986597633634829);
constexpr char kProjectOneId[] = …;
constexpr char kProjectTwoId[] = …;
constexpr char kProjectFourId[] = …;
constexpr char kValueOne[] = …;
constexpr char kValueTwo[] = …;
std::string HashToHex(const uint64_t hash) { … }
class TestRecorder : public StructuredMetricsClient::RecordingDelegate { … };
class TestSMRecorder : public StructuredMetricsRecorder { … };
}
class StructuredMetricsRecorderTest : public testing::Test { … };
TEST_F(StructuredMetricsRecorderTest, RecorderInitializesFromBlankSlate) { … }
TEST_F(StructuredMetricsRecorderTest, EventsNotReportedWhenRecordingDisabled) { … }
TEST_F(StructuredMetricsRecorderTest, EventsNotReportedWhenFeatureDisabled) { … }
TEST_F(StructuredMetricsRecorderTest, RecordingDisabledDuringInitialization) { … }
TEST_F(StructuredMetricsRecorderTest, RecordingDisabledByDefault) { … }
TEST_F(StructuredMetricsRecorderTest, RecordedEventAppearsInReport) { … }
TEST_F(StructuredMetricsRecorderTest, EventMetricsReportedCorrectly) { … }
TEST_F(StructuredMetricsRecorderTest, RawStringMetricsReportedCorrectly) { … }
TEST_F(StructuredMetricsRecorderTest, FloatMetricsReportedCorrectly) { … }
TEST_F(StructuredMetricsRecorderTest, DeviceKeysUsedForDeviceScopedProjects) { … }
TEST_F(StructuredMetricsRecorderTest, Int64MetricsNotTruncated) { … }
TEST_F(StructuredMetricsRecorderTest, EventsWithinProjectReportedWithSameID) { … }
TEST_F(StructuredMetricsRecorderTest, EventWithoutMetricsReportCorrectly) { … }
TEST_F(StructuredMetricsRecorderTest, EventsNotRecordedBeforeRecordingEnabled) { … }
TEST_F(StructuredMetricsRecorderTest, EventsRecordedBeforeKeysInitialized) { … }
TEST_F(StructuredMetricsRecorderTest,
ExistingEventsClearedWhenRecordingDisabled) { … }
TEST_F(StructuredMetricsRecorderTest, ReportingResumesWhenEnabled) { … }
TEST_F(StructuredMetricsRecorderTest,
ReportsNothingBeforeInitializationComplete) { … }
TEST_F(StructuredMetricsRecorderTest, EventsClone) { … }
TEST_F(StructuredMetricsRecorderTest, DisallowedProjectAreDropped) { … }
class TestProcessor : public EventsProcessorInterface { … };
TEST_F(StructuredMetricsRecorderTest, AppliesProcessorCorrectly) { … }
TEST_F(StructuredMetricsRecorderTest, ForceRecordedEvents) { … }
TEST_F(StructuredMetricsRecorderTest, EventMetadataLookupCorrectly) { … }
class TestWatcher : public StructuredMetricsRecorder::Observer { … };
TEST_F(StructuredMetricsRecorderTest, WatcherTest) { … }
TEST_F(StructuredMetricsRecorderTest, EnumRecordedCorrectly) { … }
TEST_F(StructuredMetricsRecorderTest, MultipleReports) { … }
}