Telemetry: Refactor Sampler and MetricReportQueue fakes.
Move Sampler and MetricReportQueue to their own files so
they can be used by other tests.
Bug: b:177847653
Change-Id: Ic8e166dc298c423cfe2cc2795abbdc955e29138e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3262396
Commit-Queue: Ahmed Nasr <[email protected]>
Reviewed-by: Leonid Baraz <[email protected]>
Cr-Commit-Position: refs/heads/main@{#940520}
diff --git a/components/reporting/metrics/fake_sampler.cc b/components/reporting/metrics/fake_sampler.cc
new file mode 100644
index 0000000..16c5d00
--- /dev/null
+++ b/components/reporting/metrics/fake_sampler.cc
@@ -0,0 +1,23 @@
+// Copyright 2021 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/reporting/metrics/fake_sampler.h"
+
+namespace reporting {
+namespace test {
+
+void FakeSampler::Collect(MetricCallback cb) {
+ num_calls_++;
+ std::move(cb).Run(std::move(metric_data_));
+}
+
+void FakeSampler::SetMetricData(MetricData metric_data) {
+ metric_data_ = std::move(metric_data);
+}
+
+int FakeSampler::GetNumCollectCalls() const {
+ return num_calls_;
+}
+} // namespace test
+} // namespace reporting