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 5 #ifndef MEDIA_CDM_MOCK_HELPERS_H_ 6 #define MEDIA_CDM_MOCK_HELPERS_H_ 7 8 #include <stdint.h> 9 10 #include <memory> 11 #include <string> 12 13 #include "base/callback.h" 14 #include "base/macros.h" 15 #include "media/cdm/cdm_allocator.h" 16 #include "media/cdm/cdm_auxiliary_helper.h" 17 #include "media/cdm/cdm_helpers.h" 18 #include "testing/gmock/include/gmock/gmock.h" 19 20 namespace media { 21 22 class MockCdmAuxiliaryHelper : public CdmAuxiliaryHelper { 23 public: 24 explicit MockCdmAuxiliaryHelper(std::unique_ptr<CdmAllocator> allocator); 25 ~MockCdmAuxiliaryHelper() override; 26 27 // CdmAuxiliaryHelper implementation. 28 void SetFileReadCB(FileReadCB file_read_cb) override; 29 MOCK_METHOD1(CreateCdmFileIO, cdm::FileIO*(cdm::FileIOClient* client)); 30 31 cdm::Buffer* CreateCdmBuffer(size_t capacity) override; 32 std::unique_ptr<VideoFrameImpl> CreateCdmVideoFrame() override; 33 34 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<> 35 // parameters. 36 MOCK_METHOD0(QueryStatusCalled, bool()); 37 void QueryStatus(QueryStatusCB callback) override; 38 39 MOCK_METHOD1(EnableProtectionCalled, bool(uint32_t desired_protection_mask)); 40 void EnableProtection(uint32_t desired_protection_mask, 41 EnableProtectionCB callback) override; 42 43 MOCK_METHOD2(ChallengePlatformCalled, 44 bool(const std::string& service_id, 45 const std::string& challenge)); 46 void ChallengePlatform(const std::string& service_id, 47 const std::string& challenge, 48 ChallengePlatformCB callback) override; 49 50 MOCK_METHOD1(GetStorageIdCalled, std::vector<uint8_t>(uint32_t version)); 51 void GetStorageId(uint32_t version, StorageIdCB callback) override; 52 53 private: 54 std::unique_ptr<CdmAllocator> allocator_; 55 56 DISALLOW_COPY_AND_ASSIGN(MockCdmAuxiliaryHelper); 57 }; 58 59 } // namespace media 60 61 #endif // MEDIA_CDM_MOCK_HELPERS_H_ 62