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

media / base / android / mock_media_crypto_context.h [blame]

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_BASE_ANDROID_MOCK_MEDIA_CRYPTO_CONTEXT_H_
#define MEDIA_BASE_ANDROID_MOCK_MEDIA_CRYPTO_CONTEXT_H_

#include "media/base/android/media_crypto_context.h"
#include "media/base/cdm_context.h"
#include "media/base/media_export.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace media {

class MEDIA_EXPORT MockMediaCryptoContext
    : public CdmContext,
      public testing::NiceMock<MediaCryptoContext> {
 public:
  explicit MockMediaCryptoContext(bool has_media_crypto_context);

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

  ~MockMediaCryptoContext() override;

  // CdmContext implementation.
  MediaCryptoContext* GetMediaCryptoContext() override;

  // MediaCryptoContext implementation.
  void SetMediaCryptoReadyCB(
      MediaCryptoReadyCB media_crypto_ready_cb) override {
    SetMediaCryptoReadyCB_(media_crypto_ready_cb);
  }
  MOCK_METHOD1(SetMediaCryptoReadyCB_,
               void(MediaCryptoReadyCB& media_crypto_ready_cb));

  MediaCryptoReadyCB media_crypto_ready_cb_;

  // To be set to true when |media_crypto_ready_cb_| is consumed and run.
  bool ran_media_crypto_ready_cb_ = false;

 private:
  bool has_media_crypto_context_;
};

}  // namespace media

#endif  // MEDIA_BASE_ANDROID_MOCK_MEDIA_CRYPTO_CONTEXT_H_