#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/mojo/clients/mojo_cdm.h"
#include <stdint.h>
#include <memory>
#include "base/functional/bind.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/test/test_message_loop.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "media/base/cdm_config.h"
#include "media/base/cdm_factory.h"
#include "media/base/content_decryption_module.h"
#include "media/base/mock_filters.h"
#include "media/cdm/clear_key_cdm_common.h"
#include "media/cdm/default_cdm_factory.h"
#include "media/mojo/mojom/content_decryption_module.mojom.h"
#include "media/mojo/services/mojo_cdm_service.h"
#include "media/mojo/services/mojo_cdm_service_context.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
_;
DoAll;
Invoke;
Return;
ReturnNull;
ReturnPointee;
StrictMock;
WithArg;
WithArgs;
WithoutArgs;
MATCHER(NotEmpty, "") { … }
ACTION_P2(CdmCreated, cdm, status) { … }
namespace media {
namespace {
const uint8_t kKeyId[] = …;
}
class MojoCdmTest : public ::testing::Test { … };
TEST_F(MojoCdmTest, Create_Success) { … }
TEST_F(MojoCdmTest, Create_Failure) { … }
TEST_F(MojoCdmTest, Create_ConnectionErrorBefore) { … }
TEST_F(MojoCdmTest, SetServerCertificate_Success) { … }
TEST_F(MojoCdmTest, SetServerCertificate_Failure) { … }
TEST_F(MojoCdmTest, SetServerCertificate_Pending) { … }
TEST_F(MojoCdmTest, SetServerCertificate_ConnectionErrorBefore) { … }
TEST_F(MojoCdmTest, SetServerCertificate_ConnectionErrorDuring) { … }
TEST_F(MojoCdmTest, CreateSession_Success) { … }
TEST_F(MojoCdmTest, CreateSession_Failure) { … }
TEST_F(MojoCdmTest, CreateSession_Pending) { … }
TEST_F(MojoCdmTest, CreateSession_ConnectionErrorBefore) { … }
TEST_F(MojoCdmTest, CreateSession_ConnectionErrorDuring) { … }
TEST_F(MojoCdmTest, LoadSession_Success) { … }
TEST_F(MojoCdmTest, LoadSession_Failure) { … }
TEST_F(MojoCdmTest, LoadSession_Pending) { … }
TEST_F(MojoCdmTest, LoadSession_ConnectionErrorBefore) { … }
TEST_F(MojoCdmTest, LoadSession_ConnectionErrorDuring) { … }
TEST_F(MojoCdmTest, UpdateSession_Success) { … }
TEST_F(MojoCdmTest, UpdateSession_Failure) { … }
TEST_F(MojoCdmTest, UpdateSession_Pending) { … }
TEST_F(MojoCdmTest, UpdateSession_ConnectionErrorBefore) { … }
TEST_F(MojoCdmTest, UpdateSession_ConnectionErrorDuring) { … }
TEST_F(MojoCdmTest, CloseSession_Success) { … }
TEST_F(MojoCdmTest, CloseSession_Failure) { … }
TEST_F(MojoCdmTest, CloseSession_Pending) { … }
TEST_F(MojoCdmTest, CloseSession_ConnectionErrorBefore) { … }
TEST_F(MojoCdmTest, CloseSession_ConnectionErrorDuring) { … }
TEST_F(MojoCdmTest, RemoveSession_Success) { … }
TEST_F(MojoCdmTest, RemoveSession_Failure) { … }
TEST_F(MojoCdmTest, RemoveSession_Pending) { … }
TEST_F(MojoCdmTest, RemoveSession_ConnectionErrorBefore) { … }
TEST_F(MojoCdmTest, RemoveSession_ConnectionErrorDuring) { … }
TEST_F(MojoCdmTest, SessionMessageCB_Success) { … }
TEST_F(MojoCdmTest, SessionExpirationChangeCB_Success) { … }
TEST_F(MojoCdmTest, SessionKeysChangeCB_Success) { … }
TEST_F(MojoCdmTest, NoDecryptor) { … }
#if BUILDFLAG(IS_WIN)
TEST_F(MojoCdmTest, RequiresMediaFoundationRenderer) {
requires_media_foundation_renderer_ = true;
Initialize(SUCCESS);
auto* cdm_context = mojo_cdm_->GetCdmContext();
EXPECT_TRUE(cdm_context) << "All CDMs should support CdmContext";
EXPECT_TRUE(cdm_context->RequiresMediaFoundationRenderer());
}
TEST_F(MojoCdmTest, NotRequireMediaFoundationRenderer) {
requires_media_foundation_renderer_ = false;
Initialize(SUCCESS);
auto* cdm_context = mojo_cdm_->GetCdmContext();
EXPECT_TRUE(cdm_context) << "All CDMs should support CdmContext";
EXPECT_FALSE(cdm_context->RequiresMediaFoundationRenderer());
}
#endif
}