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

Side by Side Diff: components/sync/user_events/fake_user_event_service.h

Issue 2909283003: [Sync] Split UserEventService into interface and impl, add fake impl, add unit tests. (Closed)
Patch Set: Added a NoOp service to handle OffTheRecord. Created 3 years, 6 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/sync/BUILD.gn ('k') | components/sync/user_events/fake_user_event_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_SYNC_USER_EVENTS_FAKE_USER_EVENT_SERVICE_H_
6 #define COMPONENTS_SYNC_USER_EVENTS_FAKE_USER_EVENT_SERVICE_H_
7
8 #include <map>
9 #include <memory>
10 #include <set>
11 #include <string>
12 #include <vector>
13
14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h"
16 #include "components/sync/protocol/user_event_specifics.pb.h"
17 #include "components/sync/user_events/user_event_service.h"
18
19 namespace syncer {
20
21 class ModelTypeSyncBridge;
22
23 // This implementation is intended to be used in unit tests, with public
24 // accessors that allow reading all data to verify expectations.
25 class FakeUserEventService : public UserEventService {
26 public:
27 FakeUserEventService();
28 ~FakeUserEventService() override;
29
30 // UserEventService implementation.
31 void RecordUserEvent(
32 std::unique_ptr<sync_pb::UserEventSpecifics> specifics) override;
33 void RecordUserEvent(const sync_pb::UserEventSpecifics& specifics) override;
34 void RegisterDependentFieldTrial(
35 const std::string& trial_name,
36 sync_pb::UserEventSpecifics::EventCase event_case) override;
37 base::WeakPtr<ModelTypeSyncBridge> GetSyncBridge() override;
38
39 const std::vector<sync_pb::UserEventSpecifics>& GetRecordedUserEvents() const;
40 const std::map<std::string, std::set<sync_pb::UserEventSpecifics::EventCase>>&
41 GetRegisteredDependentFieldTrials() const;
42
43 private:
44 std::vector<sync_pb::UserEventSpecifics> recorded_user_events_;
45 std::map<std::string, std::set<sync_pb::UserEventSpecifics::EventCase>>
46 registered_dependent_field_trials_;
47
48 DISALLOW_COPY_AND_ASSIGN(FakeUserEventService);
49 };
50
51 } // namespace syncer
52
53 #endif // COMPONENTS_SYNC_USER_EVENTS_FAKE_USER_EVENT_SERVICE_H_
OLDNEW
« no previous file with comments | « components/sync/BUILD.gn ('k') | components/sync/user_events/fake_user_event_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698