#include "components/ukm/test_ukm_recorder.h"
#include <iterator>
#include <string_view>
#include "base/check_op.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/metrics_hashes.h"
#include "base/ranges/algorithm.h"
#include "services/metrics/public/cpp/delegating_ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_source.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ukm {
namespace {
void MergeEntry(const mojom::UkmEntry* in, mojom::UkmEntry* out) { … }
}
TestUkmRecorder::TestUkmRecorder() { … }
TestUkmRecorder::~TestUkmRecorder() { … }
void TestUkmRecorder::AddEntry(mojom::UkmEntryPtr entry) { … }
const UkmSource* TestUkmRecorder::GetSourceForSourceId(
SourceId source_id) const { … }
const ukm::mojom::UkmEntry* TestUkmRecorder::GetDocumentCreatedEntryForSourceId(
ukm::SourceId source_id) const { … }
void TestUkmRecorder::SetOnAddEntryCallback(
std::string_view entry_name,
base::RepeatingClosure on_add_entry) { … }
std::vector<raw_ptr<const mojom::UkmEntry, VectorExperimental>>
TestUkmRecorder::GetEntriesByName(std::string_view entry_name) const { … }
std::map<ukm::SourceId, mojom::UkmEntryPtr>
TestUkmRecorder::GetMergedEntriesByName(std::string_view entry_name) const { … }
void TestUkmRecorder::ExpectEntrySourceHasUrl(const mojom::UkmEntry* entry,
const GURL& url) const { … }
bool TestUkmRecorder::EntryHasMetric(const mojom::UkmEntry* entry,
std::string_view metric_name) { … }
const int64_t* TestUkmRecorder::GetEntryMetric(const mojom::UkmEntry* entry,
std::string_view metric_name) { … }
void TestUkmRecorder::ExpectEntryMetric(const mojom::UkmEntry* entry,
std::string_view metric_name,
int64_t expected_value) { … }
TestAutoSetUkmRecorder::TestAutoSetUkmRecorder() { … }
TestAutoSetUkmRecorder::~TestAutoSetUkmRecorder() { … }
std::vector<TestUkmRecorder::HumanReadableUkmMetrics>
TestUkmRecorder::GetMetrics(
std::string entry_name,
const std::vector<std::string>& metric_names) const { … }
std::vector<int64_t> TestUkmRecorder::GetMetricsEntryValues(
const std::string& entry_name,
const std::string& metric_name) const { … }
std::vector<TestUkmRecorder::HumanReadableUkmEntry> TestUkmRecorder::GetEntries(
std::string entry_name,
const std::vector<std::string>& metric_names) const { … }
std::vector<ukm::TestAutoSetUkmRecorder::HumanReadableUkmMetrics>
TestUkmRecorder::FilteredHumanReadableMetricForEntry(
const std::string& entry_name,
const std::string& metric_name) const { … }
TestUkmRecorder::HumanReadableUkmEntry::HumanReadableUkmEntry() = default;
TestUkmRecorder::HumanReadableUkmEntry::HumanReadableUkmEntry(
ukm::SourceId source_id,
TestUkmRecorder::HumanReadableUkmMetrics ukm_metrics)
: … { … }
TestUkmRecorder::HumanReadableUkmEntry::HumanReadableUkmEntry(
const HumanReadableUkmEntry&) = default;
TestUkmRecorder::HumanReadableUkmEntry::~HumanReadableUkmEntry() = default;
bool TestUkmRecorder::HumanReadableUkmEntry::operator==(
const HumanReadableUkmEntry& other) const { … }
void PrintTo(const TestUkmRecorder::HumanReadableUkmEntry& entry,
std::ostream* os) { … }
}