fake_user_event_service.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #ifndef COMPONENTS_SYNC_USER_EVENTS_FAKE_USER_EVENT_SERVICE_H_
  5. #define COMPONENTS_SYNC_USER_EVENTS_FAKE_USER_EVENT_SERVICE_H_
  6. #include <memory>
  7. #include <vector>
  8. #include "components/sync/protocol/user_event_specifics.pb.h"
  9. #include "components/sync/test/fake_model_type_controller_delegate.h"
  10. #include "components/sync_user_events/user_event_service.h"
  11. namespace syncer {
  12. // This implementation is intended to be used in unit tests, with public
  13. // accessors that allow reading all data to verify expectations.
  14. class FakeUserEventService : public UserEventService {
  15. public:
  16. FakeUserEventService();
  17. FakeUserEventService(const FakeUserEventService&) = delete;
  18. FakeUserEventService& operator=(const FakeUserEventService&) = delete;
  19. ~FakeUserEventService() override;
  20. // UserEventService implementation.
  21. void RecordUserEvent(
  22. std::unique_ptr<sync_pb::UserEventSpecifics> specifics) override;
  23. void RecordUserEvent(const sync_pb::UserEventSpecifics& specifics) override;
  24. base::WeakPtr<syncer::ModelTypeControllerDelegate> GetControllerDelegate()
  25. override;
  26. const std::vector<sync_pb::UserEventSpecifics>& GetRecordedUserEvents() const;
  27. private:
  28. std::vector<sync_pb::UserEventSpecifics> recorded_user_events_;
  29. FakeModelTypeControllerDelegate fake_controller_delegate_;
  30. };
  31. } // namespace syncer
  32. #endif // COMPONENTS_SYNC_USER_EVENTS_FAKE_USER_EVENT_SERVICE_H_