summaryrefslogtreecommitdiff
path: root/chromium/media/cdm/mock_helpers.h
blob: 9998a0c4e6bd2210248d41a034d05c955d0dc764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (c) 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_CDM_MOCK_HELPERS_H_
#define MEDIA_CDM_MOCK_HELPERS_H_

#include <stdint.h>

#include <memory>
#include <string>

#include "base/callback.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "media/cdm/cdm_allocator.h"
#include "media/cdm/cdm_auxiliary_helper.h"
#include "media/cdm/cdm_helpers.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace media {

class MockCdmAuxiliaryHelper : public CdmAuxiliaryHelper {
 public:
  // `allocator` is optional; can be null if no need to create buffers/frames.
  explicit MockCdmAuxiliaryHelper(std::unique_ptr<CdmAllocator> allocator);

  MockCdmAuxiliaryHelper(const MockCdmAuxiliaryHelper&) = delete;
  MockCdmAuxiliaryHelper& operator=(const MockCdmAuxiliaryHelper&) = delete;

  ~MockCdmAuxiliaryHelper() override;

  // CdmAuxiliaryHelper implementation.
  void SetFileReadCB(FileReadCB file_read_cb) override;
  MOCK_METHOD1(CreateCdmFileIO, cdm::FileIO*(cdm::FileIOClient* client));

  cdm::Buffer* CreateCdmBuffer(size_t capacity) override;
  std::unique_ptr<VideoFrameImpl> CreateCdmVideoFrame() override;

  // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>
  // parameters.
  MOCK_METHOD0(QueryStatusCalled, bool());
  void QueryStatus(QueryStatusCB callback) override;

  MOCK_METHOD1(EnableProtectionCalled, bool(uint32_t desired_protection_mask));
  void EnableProtection(uint32_t desired_protection_mask,
                        EnableProtectionCB callback) override;

  MOCK_METHOD2(ChallengePlatformCalled,
               bool(const std::string& service_id,
                    const std::string& challenge));
  void ChallengePlatform(const std::string& service_id,
                         const std::string& challenge,
                         ChallengePlatformCB callback) override;

  MOCK_METHOD1(GetStorageIdCalled, std::vector<uint8_t>(uint32_t version));
  void GetStorageId(uint32_t version, StorageIdCB callback) override;

#if defined(OS_WIN)
  MOCK_METHOD(void,
              GetMediaFoundationCdmData,
              (GetMediaFoundationCdmDataCB callback),
              (override));
#endif  // defined(OS_WIN)

 private:
  std::unique_ptr<CdmAllocator> allocator_;
};

}  // namespace media

#endif  // MEDIA_CDM_MOCK_HELPERS_H_