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

Side by Side Diff: components/ukm/test_ukm_service.h

Issue 2893943004: Refactor UKM interface for mojo-ification (Closed)
Patch Set: Fixed contextualsearch Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « components/ukm/test_ukm_recorder.cc ('k') | components/ukm/test_ukm_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_UKM_TEST_UKM_SERVICE_H_
6 #define COMPONENTS_UKM_TEST_UKM_SERVICE_H_
7
8 #include <stddef.h>
9 #include <memory>
10
11 #include "components/metrics/test_metrics_service_client.h"
12 #include "components/prefs/testing_pref_service.h"
13 #include "components/ukm/ukm_pref_names.h"
14 #include "components/ukm/ukm_service.h"
15
16 namespace ukm {
17
18 // Wraps an UkmService with additional accessors used for testing.
19 class TestUkmService : public UkmService {
20 public:
21 explicit TestUkmService(PrefService* pref_service);
22 ~TestUkmService() override;
23
24 size_t sources_count() const { return sources_for_testing().size(); }
25 const std::map<int32_t, std::unique_ptr<UkmSource>>& GetSources() const;
26 const UkmSource* GetSourceForUrl(const char* url) const;
27 const UkmSource* GetSourceForSourceId(int32_t source_id) const;
28
29 size_t entries_count() const { return entries_for_testing().size(); }
30 const UkmEntry* GetEntry(size_t entry_num) const;
31 const UkmEntry* GetEntryForEntryName(const char* entry_name) const;
32
33 private:
34 metrics::TestMetricsServiceClient test_metrics_service_client_;
35
36 DISALLOW_COPY_AND_ASSIGN(TestUkmService);
37 };
38
39 // Convenience harness used for testing; creates a TestUkmService and
40 // supplies it with a prefs service with a longer lifespan.
41 class UkmServiceTestingHarness {
42 public:
43 UkmServiceTestingHarness();
44 virtual ~UkmServiceTestingHarness();
45
46 TestUkmService* test_ukm_service() { return test_ukm_service_.get(); }
47
48 private:
49 TestingPrefServiceSimple test_prefs_;
50 std::unique_ptr<TestUkmService> test_ukm_service_;
51
52 DISALLOW_COPY_AND_ASSIGN(UkmServiceTestingHarness);
53 };
54
55 } // namespace ukm
56
57 #endif // COMPONENTS_UKM_TEST_UKM_SERVICE_H_
OLDNEW
« no previous file with comments | « components/ukm/test_ukm_recorder.cc ('k') | components/ukm/test_ukm_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698