mock_helpers.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright (c) 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 MEDIA_CDM_MOCK_HELPERS_H_
  5. #define MEDIA_CDM_MOCK_HELPERS_H_
  6. #include <stdint.h>
  7. #include <memory>
  8. #include <string>
  9. #include "base/callback.h"
  10. #include "build/build_config.h"
  11. #include "media/cdm/cdm_allocator.h"
  12. #include "media/cdm/cdm_auxiliary_helper.h"
  13. #include "media/cdm/cdm_helpers.h"
  14. #include "testing/gmock/include/gmock/gmock.h"
  15. namespace media {
  16. class MockCdmAuxiliaryHelper : public CdmAuxiliaryHelper {
  17. public:
  18. // `allocator` is optional; can be null if no need to create buffers/frames.
  19. explicit MockCdmAuxiliaryHelper(std::unique_ptr<CdmAllocator> allocator);
  20. MockCdmAuxiliaryHelper(const MockCdmAuxiliaryHelper&) = delete;
  21. MockCdmAuxiliaryHelper& operator=(const MockCdmAuxiliaryHelper&) = delete;
  22. ~MockCdmAuxiliaryHelper() override;
  23. // CdmAuxiliaryHelper implementation.
  24. void SetFileReadCB(FileReadCB file_read_cb) override;
  25. MOCK_METHOD1(CreateCdmFileIO, cdm::FileIO*(cdm::FileIOClient* client));
  26. cdm::Buffer* CreateCdmBuffer(size_t capacity) override;
  27. std::unique_ptr<VideoFrameImpl> CreateCdmVideoFrame() override;
  28. // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>
  29. // parameters.
  30. MOCK_METHOD0(QueryStatusCalled, bool());
  31. void QueryStatus(QueryStatusCB callback) override;
  32. MOCK_METHOD1(EnableProtectionCalled, bool(uint32_t desired_protection_mask));
  33. void EnableProtection(uint32_t desired_protection_mask,
  34. EnableProtectionCB callback) override;
  35. MOCK_METHOD2(ChallengePlatformCalled,
  36. bool(const std::string& service_id,
  37. const std::string& challenge));
  38. void ChallengePlatform(const std::string& service_id,
  39. const std::string& challenge,
  40. ChallengePlatformCB callback) override;
  41. MOCK_METHOD1(GetStorageIdCalled, std::vector<uint8_t>(uint32_t version));
  42. void GetStorageId(uint32_t version, StorageIdCB callback) override;
  43. #if BUILDFLAG(IS_WIN)
  44. MOCK_METHOD(void,
  45. GetMediaFoundationCdmData,
  46. (GetMediaFoundationCdmDataCB callback),
  47. (override));
  48. #endif // BUILDFLAG(IS_WIN)
  49. private:
  50. std::unique_ptr<CdmAllocator> allocator_;
  51. };
  52. } // namespace media
  53. #endif // MEDIA_CDM_MOCK_HELPERS_H_