mock_dm_token_retriever.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2021 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_REPORTING_CLIENT_MOCK_DM_TOKEN_RETRIEVER_H_
  5. #define COMPONENTS_REPORTING_CLIENT_MOCK_DM_TOKEN_RETRIEVER_H_
  6. #include <cstddef>
  7. #include <string>
  8. #include "components/reporting/client/dm_token_retriever.h"
  9. #include "components/reporting/util/statusor.h"
  10. #include "testing/gmock/include/gmock/gmock.h"
  11. namespace reporting {
  12. // A mock |DMTokenRetriever| that stubs out functionality that retrieves the
  13. // DM token for testing purposes.
  14. class MockDMTokenRetriever : public DMTokenRetriever {
  15. public:
  16. MockDMTokenRetriever();
  17. MockDMTokenRetriever(const MockDMTokenRetriever&) = delete;
  18. MockDMTokenRetriever& operator=(const MockDMTokenRetriever&) = delete;
  19. ~MockDMTokenRetriever() override;
  20. // Ensures by mocking that RetrieveDMToken is expected to be triggered a
  21. // specific number of times and runs the completion callback with the
  22. // specified result on trigger.
  23. void ExpectRetrieveDMTokenAndReturnResult(
  24. size_t times,
  25. const StatusOr<std::string> dm_token_result);
  26. // Mocked stub that retrieves the DM token and triggers the specified callback
  27. MOCK_METHOD(void,
  28. RetrieveDMToken,
  29. (DMTokenRetriever::CompletionCallback completion_cb),
  30. (override));
  31. };
  32. } // namespace reporting
  33. #endif // COMPONENTS_REPORTING_CLIENT_MOCK_DM_TOKEN_RETRIEVER_H_