OLD | NEW |
(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_ |
OLD | NEW |