Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: components/ukm/test_ukm_service.h

Issue 2617883004: Initial UKMPageLoadMetricsObserver (Closed)
Patch Set: Class rename Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/ukm/test_ukm_service.h
diff --git a/components/ukm/test_ukm_service.h b/components/ukm/test_ukm_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..e7660b068031ba74460a2d07d66ae84679c2dbec
--- /dev/null
+++ b/components/ukm/test_ukm_service.h
@@ -0,0 +1,48 @@
+// Copyright 2017 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.
+
+#ifndef COMPONENTS_UKM_TEST_UKM_SERVICE_H_
+#define COMPONENTS_UKM_TEST_UKM_SERVICE_H_
+
+#include <stddef.h>
+#include <memory>
+
+#include "components/metrics/test_metrics_service_client.h"
+#include "components/prefs/testing_pref_service.h"
+#include "components/ukm/ukm_pref_names.h"
+#include "components/ukm/ukm_service.h"
+
+namespace ukm {
+
+// Wraps an UkmService with additional accessors used for testing.
+class TestUkmService : public UkmService {
+ public:
+ TestUkmService(PrefService* pref_service);
+ ~TestUkmService() override;
+
+ size_t sources_count() const { return sources_for_testing().size(); }
+ const UkmSource* GetSource(size_t source_num) const;
+
+ private:
+ metrics::TestMetricsServiceClient test_metrics_service_client_;
+ DISALLOW_COPY_AND_ASSIGN(TestUkmService);
+};
+
+// Convenience harness used for testing; creates a TestUkmService and
+// supplies it with a prefs service with a longer lifespan.
+class UkmServiceTestingHarness {
+ public:
+ UkmServiceTestingHarness();
+ virtual ~UkmServiceTestingHarness();
+
+ TestUkmService* test_ukm_service() const { return test_ukm_service_.get(); }
+
+ private:
+ TestingPrefServiceSimple test_prefs_;
+ std::unique_ptr<TestUkmService> test_ukm_service_;
+};
+
+} // namespace ukm
+
+#endif // COMPONENTS_UKM_TEST_UKM_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698