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

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

Issue 2649303004: UKM: Added support for navigation sources (Closed)
Patch Set: Removed redundant test steps 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 unified diff | Download patch
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 TestUkmService(PrefService* pref_service);
Alexei Svitkine (slow) 2017/01/25 15:35:04 explicit
oystein (OOO til 10th of July) 2017/01/25 18:38:04 Done.
22 ~TestUkmService() override;
23
24 size_t sources_count() const { return sources_for_testing().size(); }
25 const UkmSource* GetSource(size_t source_num) const;
26
27 private:
28 metrics::TestMetricsServiceClient test_metrics_service_client_;
29 DISALLOW_COPY_AND_ASSIGN(TestUkmService);
Alexei Svitkine (slow) 2017/01/25 15:35:04 Nit: Add an empty line above this.
oystein (OOO til 10th of July) 2017/01/25 18:38:04 Done.
30 };
31
32 // Convenience harness used for testing; creates a TestUkmService and
33 // supplies it with a prefs service with a longer lifespan.
34 class UkmServiceTestingHarness {
35 public:
36 UkmServiceTestingHarness();
37 virtual ~UkmServiceTestingHarness();
38
39 TestUkmService* test_ukm_service() const { return test_ukm_service_.get(); }
Alexei Svitkine (slow) 2017/01/25 15:35:04 Return by const& since I assume it can't be null?
oystein (OOO til 10th of July) 2017/01/25 18:38:04 Done.
40
41 private:
42 TestingPrefServiceSimple test_prefs_;
43 std::unique_ptr<TestUkmService> test_ukm_service_;
44 };
Alexei Svitkine (slow) 2017/01/25 15:35:04 Nit: DISALLOW_COPY_AND_ASSIGN()?
oystein (OOO til 10th of July) 2017/01/25 18:38:04 Done.
45
46 } // namespace ukm
47
48 #endif // COMPONENTS_UKM_TEST_UKM_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698