| Index: media/remoting/rpc/rpc_unittest.cc
|
| diff --git a/media/remoting/rpc/rpc_unittest.cc b/media/remoting/rpc/rpc_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..813155dbfe899dae00aabdb1d1886a46444e7eff
|
| --- /dev/null
|
| +++ b/media/remoting/rpc/rpc_unittest.cc
|
| @@ -0,0 +1,613 @@
|
| +// Copyright 2016 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.
|
| +
|
| +#include "media/remoting/rpc/rpc.h"
|
| +
|
| +#include <memory>
|
| +#include <string>
|
| +#include <utility>
|
| +#include <vector>
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "media/base/audio_decoder_config.h"
|
| +#include "media/base/cdm_config.h"
|
| +#include "media/base/cdm_key_information.h"
|
| +#include "media/base/demuxer_stream.h"
|
| +#include "media/base/eme_constants.h"
|
| +#include "media/base/media_keys.h"
|
| +#include "media/base/video_decoder_config.h"
|
| +#include "media/remoting/remoting_rpc_message.pb.h"
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +using testing::_;
|
| +using testing::Invoke;
|
| +using testing::Return;
|
| +
|
| +namespace media {
|
| +namespace remoting {
|
| +
|
| +class RemotingRpcTest : public testing::Test {
|
| + protected:
|
| + void SetUp() override {}
|
| +};
|
| +
|
| +TEST_F(RemotingRpcTest, GarbageInput) {
|
| + std::string proto_buffer_string("$%@#$@$%$&%^&^%*^&^&....");
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(!to_rpc);
|
| +}
|
| +
|
| +// Test RPC message which has single integer message.
|
| +TEST_F(RemotingRpcTest, AcquireRendererRpc) {
|
| + int rpc_handle = 3;
|
| +
|
| + // Convert RPC data structure into proto buffer string
|
| + int value = 0;
|
| + scoped_refptr<Rpc> from_rpc(new AcquireRendererRpc(rpc_handle, value));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + AcquireRendererRpc* actual_to_rpc =
|
| + static_cast<AcquireRendererRpc*>(to_rpc.get());
|
| + ASSERT_EQ(value, actual_to_rpc->value());
|
| +}
|
| +
|
| +// Test RPC message which has single double message.
|
| +TEST_F(RemotingRpcTest, RendererSetPlaybackRateRpc) {
|
| + int rpc_handle = 3;
|
| +
|
| + // Convert RPC data structure into proto buffer string
|
| + double value = 1.1;
|
| + scoped_refptr<Rpc> from_rpc(
|
| + new RendererSetPlaybackRateRpc(rpc_handle, value));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + RendererSetPlaybackRateRpc* actual_to_rpc =
|
| + static_cast<RendererSetPlaybackRateRpc*>(to_rpc.get());
|
| + ASSERT_EQ(value, actual_to_rpc->value());
|
| +}
|
| +
|
| +// Test RPC message which has single boolean message.
|
| +TEST_F(RemotingRpcTest, RendererInitializeCallbackRpc) {
|
| + int rpc_handle = 3;
|
| +
|
| + // Convert RPC data structure into proto buffer string
|
| + bool value = true;
|
| + scoped_refptr<Rpc> from_rpc(
|
| + new RendererInitializeCallbackRpc(rpc_handle, value));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + RendererInitializeCallbackRpc* actual_to_rpc =
|
| + static_cast<RendererInitializeCallbackRpc*>(to_rpc.get());
|
| + ASSERT_EQ(value, actual_to_rpc->value());
|
| +}
|
| +
|
| +// Test RPC message which has no additional message.
|
| +TEST_F(RemotingRpcTest, RendererFlushCallbackRpc) {
|
| + int rpc_handle = 3;
|
| +
|
| + // Convert RPC data structure into proto buffer string
|
| + scoped_refptr<Rpc> from_rpc(new RendererFlushCallbackRpc(rpc_handle));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +}
|
| +
|
| +// Following are the RPC message which have various data structure.
|
| +TEST_F(RemotingRpcTest, RendererInitializeRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + int client_handle = 4;
|
| + int audio_demuxer_handle = 5;
|
| + int video_demuxer_handle = 6;
|
| + int callback_handle = 7;
|
| + scoped_refptr<Rpc> from_rpc(
|
| + new RendererInitializeRpc(rpc_handle, client_handle, audio_demuxer_handle,
|
| + video_demuxer_handle, callback_handle));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + RendererInitializeRpc* actual_to_rpc =
|
| + static_cast<RendererInitializeRpc*>(to_rpc.get());
|
| + ASSERT_EQ(client_handle, actual_to_rpc->client_handle());
|
| + ASSERT_EQ(audio_demuxer_handle, actual_to_rpc->audio_demuxer_handle());
|
| + ASSERT_EQ(video_demuxer_handle, actual_to_rpc->video_demuxer_handle());
|
| + ASSERT_EQ(callback_handle, actual_to_rpc->callback_handle());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, RendererSetCdmRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + int cdm_id = 2;
|
| + int callback_handle = 1;
|
| + scoped_refptr<Rpc> from_rpc(
|
| + new RendererSetCdmRpc(rpc_handle, cdm_id, callback_handle));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + RendererSetCdmRpc* actual_to_rpc =
|
| + static_cast<RendererSetCdmRpc*>(to_rpc.get());
|
| + ASSERT_EQ(cdm_id, actual_to_rpc->cdm_id());
|
| + ASSERT_EQ(callback_handle, actual_to_rpc->callback_handle());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, RendererClientOnTimeUpdateRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + int time_usec = 2;
|
| + int max_time_usec = 1;
|
| + scoped_refptr<Rpc> from_rpc(
|
| + new RendererClientOnTimeUpdateRpc(rpc_handle, time_usec, max_time_usec));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + RendererClientOnTimeUpdateRpc* actual_to_rpc =
|
| + static_cast<RendererClientOnTimeUpdateRpc*>(to_rpc.get());
|
| + ASSERT_EQ(time_usec, actual_to_rpc->time_usec());
|
| + ASSERT_EQ(max_time_usec, actual_to_rpc->max_time_usec());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, RendererClientOnVideoNaturalSizeChangeRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + gfx::Size size(640, 480);
|
| + scoped_refptr<Rpc> from_rpc(
|
| + new RendererClientOnVideoNaturalSizeChangeRpc(rpc_handle, size));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + RendererClientOnVideoNaturalSizeChangeRpc* actual_to_rpc =
|
| + static_cast<RendererClientOnVideoNaturalSizeChangeRpc*>(to_rpc.get());
|
| + ASSERT_EQ(size, actual_to_rpc->size());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, DemuxerStreamReadUntilRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + uint32_t frame_id = 2;
|
| + int callback_handle = 1;
|
| + scoped_refptr<Rpc> from_rpc(
|
| + new DemuxerStreamReadUntilRpc(rpc_handle, frame_id, callback_handle));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + DemuxerStreamReadUntilRpc* actual_to_rpc =
|
| + static_cast<DemuxerStreamReadUntilRpc*>(to_rpc.get());
|
| + ASSERT_EQ(frame_id, actual_to_rpc->frame_id());
|
| + ASSERT_EQ(callback_handle, actual_to_rpc->callback_handle());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, DemuxerStreamInitializeCallbackRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + ::media::DemuxerStream::Type type = ::media::DemuxerStream::VIDEO;
|
| + ::media::AudioDecoderConfig audio_config;
|
| + ::media::VideoDecoderConfig video_config;
|
| + scoped_refptr<Rpc> from_rpc(new DemuxerStreamInitializeCallbackRpc(
|
| + rpc_handle, type, audio_config, video_config));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + DemuxerStreamInitializeCallbackRpc* actual_to_rpc =
|
| + static_cast<DemuxerStreamInitializeCallbackRpc*>(to_rpc.get());
|
| + ASSERT_EQ(type, actual_to_rpc->type());
|
| + // TODO(erickung) compare |audio_config| and |video_config|;
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, DemuxerStreamReadUntilCallbackRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + uint32_t frame_id = 100;
|
| + ::media::DemuxerStream::Status status = ::media::DemuxerStream::kOk;
|
| + ::media::AudioDecoderConfig audio_config;
|
| + ::media::VideoDecoderConfig video_config;
|
| + scoped_refptr<Rpc> from_rpc(new DemuxerStreamReadUntilCallbackRpc(
|
| + rpc_handle, frame_id, status, audio_config, video_config));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + DemuxerStreamReadUntilCallbackRpc* actual_to_rpc =
|
| + static_cast<DemuxerStreamReadUntilCallbackRpc*>(to_rpc.get());
|
| + ASSERT_EQ(frame_id, actual_to_rpc->frame_id());
|
| + ASSERT_EQ(status, actual_to_rpc->status());
|
| + // TODO(erickung) compare |audio_config| and |video_config|;
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, CdmInitializeRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + std::string key_system;
|
| + std::string security_origin;
|
| + ::media::CdmConfig cdm_config;
|
| + cdm_config.allow_distinctive_identifier = true;
|
| + cdm_config.allow_persistent_state = false;
|
| + cdm_config.use_hw_secure_codecs = true;
|
| + int callback_handle = 4;
|
| + scoped_refptr<Rpc> from_rpc(new CdmInitializeRpc(
|
| + rpc_handle, key_system, security_origin, cdm_config, callback_handle));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + CdmInitializeRpc* actual_to_rpc =
|
| + static_cast<CdmInitializeRpc*>(to_rpc.get());
|
| + ASSERT_EQ(key_system, actual_to_rpc->key_system());
|
| + ASSERT_EQ(security_origin, actual_to_rpc->security_origin());
|
| + ::media::CdmConfig cdm_config_out = actual_to_rpc->cdm_config();
|
| + ASSERT_EQ(cdm_config.allow_distinctive_identifier,
|
| + cdm_config_out.allow_distinctive_identifier);
|
| + ASSERT_EQ(cdm_config.allow_persistent_state,
|
| + cdm_config_out.allow_persistent_state);
|
| + ASSERT_EQ(cdm_config.use_hw_secure_codecs,
|
| + cdm_config_out.use_hw_secure_codecs);
|
| + ASSERT_EQ(callback_handle, actual_to_rpc->callback_handle());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, CdmSetServerCertificateRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + std::string data_blob("HereIsTestBlob");
|
| + std::vector<uint8_t> certificate_data(data_blob.begin(), data_blob.end());
|
| + int callback_handle = 4;
|
| + scoped_refptr<Rpc> from_rpc(
|
| + new CdmSetServerCertificateRpc(rpc_handle, &certificate_data[0],
|
| + certificate_data.size(), callback_handle));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + CdmSetServerCertificateRpc* actual_to_rpc =
|
| + static_cast<CdmSetServerCertificateRpc*>(to_rpc.get());
|
| + ASSERT_EQ(certificate_data.size(), actual_to_rpc->certificate_data_size());
|
| + std::string data_out_blob(actual_to_rpc->certificate_data(),
|
| + actual_to_rpc->certificate_data() +
|
| + actual_to_rpc->certificate_data_size());
|
| + ASSERT_EQ(data_blob, data_out_blob);
|
| + ASSERT_EQ(callback_handle, actual_to_rpc->callback_handle());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, CdmCreateSessionAndGenerateRequestRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + ::media::MediaKeys::SessionType session_type =
|
| + ::media::MediaKeys::TEMPORARY_SESSION;
|
| + ::media::EmeInitDataType init_data_type = ::media::EmeInitDataType::CENC;
|
| + std::string data_blob("Arbitrary##Data@@@");
|
| + std::vector<uint8_t> init_data(data_blob.begin(), data_blob.end());
|
| + int callback_handle = 4;
|
| + scoped_refptr<Rpc> from_rpc(new CdmCreateSessionAndGenerateRequestRpc(
|
| + rpc_handle, session_type, init_data_type, &init_data[0], init_data.size(),
|
| + callback_handle));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + CdmCreateSessionAndGenerateRequestRpc* actual_to_rpc =
|
| + static_cast<CdmCreateSessionAndGenerateRequestRpc*>(to_rpc.get());
|
| + ASSERT_EQ(session_type, actual_to_rpc->session_type());
|
| + ASSERT_EQ(init_data_type, actual_to_rpc->init_data_type());
|
| + ASSERT_EQ(init_data.size(), actual_to_rpc->init_data_size());
|
| + std::string data_out_blob(
|
| + actual_to_rpc->init_data(),
|
| + actual_to_rpc->init_data() + actual_to_rpc->init_data_size());
|
| + ASSERT_EQ(data_blob, data_out_blob);
|
| + ASSERT_EQ(callback_handle, actual_to_rpc->callback_handle());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, CdmUpdateSessionRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + std::string session_id;
|
| + std::string data_blob("___!!AS#HGSTU");
|
| + std::vector<uint8_t> response(data_blob.begin(), data_blob.end());
|
| + int callback_handle = 4;
|
| + scoped_refptr<Rpc> from_rpc(new CdmUpdateSessionRpc(
|
| + rpc_handle, session_id, &response[0], response.size(), callback_handle));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + CdmUpdateSessionRpc* actual_to_rpc =
|
| + static_cast<CdmUpdateSessionRpc*>(to_rpc.get());
|
| + ASSERT_EQ(session_id, actual_to_rpc->session_id());
|
| + ASSERT_EQ(response.size(), actual_to_rpc->response_size());
|
| + std::string data_out_blob(
|
| + actual_to_rpc->response(),
|
| + actual_to_rpc->response() + actual_to_rpc->response_size());
|
| + ASSERT_EQ(data_blob, data_out_blob);
|
| + ASSERT_EQ(callback_handle, actual_to_rpc->callback_handle());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, CdmSetServerCertificateCallbackRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + bool success = false;
|
| + CdmPromiseResult result(::media::MediaKeys::UNKNOWN_ERROR, 3, "");
|
| + scoped_refptr<Rpc> from_rpc(
|
| + new CdmSetServerCertificateCallbackRpc(rpc_handle, result));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + CdmSetServerCertificateCallbackRpc* actual_to_rpc =
|
| + static_cast<CdmSetServerCertificateCallbackRpc*>(to_rpc.get());
|
| + const CdmPromiseResult result_out = actual_to_rpc->result();
|
| + ASSERT_EQ(success, result_out.success());
|
| + ASSERT_EQ(result.exception(), result_out.exception());
|
| + ASSERT_EQ(result.system_code(), result_out.system_code());
|
| + ASSERT_EQ(result.error_message(), result_out.error_message());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, CdmCreateSessionAndGenerateRequestCallbackRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + bool success = true;
|
| + std::string session_id;
|
| + CdmPromiseResult result(CdmPromiseResult::SuccessResult());
|
| + scoped_refptr<Rpc> from_rpc(new CdmCreateSessionAndGenerateRequestCallbackRpc(
|
| + rpc_handle, result, session_id));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + CdmCreateSessionAndGenerateRequestCallbackRpc* actual_to_rpc =
|
| + static_cast<CdmCreateSessionAndGenerateRequestCallbackRpc*>(to_rpc.get());
|
| + const CdmPromiseResult result_out = actual_to_rpc->result();
|
| + ASSERT_EQ(success, result_out.success());
|
| + ASSERT_EQ(session_id, actual_to_rpc->session_id());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, CdmInitializeCallbackRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + bool success = true;
|
| + CdmPromiseResult result(CdmPromiseResult::SuccessResult());
|
| + int cdm_id = 4;
|
| + int decryptor_handle = 5;
|
| + scoped_refptr<Rpc> from_rpc(new CdmInitializeCallbackRpc(
|
| + rpc_handle, result, cdm_id, decryptor_handle));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + CdmInitializeCallbackRpc* actual_to_rpc =
|
| + static_cast<CdmInitializeCallbackRpc*>(to_rpc.get());
|
| + const CdmPromiseResult result_out = actual_to_rpc->result();
|
| + ASSERT_EQ(success, result_out.success());
|
| + ASSERT_EQ(cdm_id, actual_to_rpc->cdm_id());
|
| + ASSERT_EQ(decryptor_handle, actual_to_rpc->decryptor_handle());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, CdmClientOnSessionMessageRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + std::string session_id;
|
| + ::media::MediaKeys::MessageType message_type =
|
| + ::media::MediaKeys::LICENSE_RELEASE;
|
| + std::string legacy_destination_url;
|
| + uint8_t message[1] = {0xAB};
|
| + scoped_refptr<Rpc> from_rpc(new CdmClientOnSessionMessageRpc(
|
| + rpc_handle, session_id, message_type, message, sizeof(message),
|
| + legacy_destination_url));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + CdmClientOnSessionMessageRpc* actual_to_rpc =
|
| + static_cast<CdmClientOnSessionMessageRpc*>(to_rpc.get());
|
| + ASSERT_EQ(session_id, actual_to_rpc->session_id());
|
| + ASSERT_EQ(message_type, actual_to_rpc->message_type());
|
| + ASSERT_EQ(message[0], actual_to_rpc->message()[0]);
|
| + ASSERT_EQ(size_t(1), actual_to_rpc->message_size());
|
| + ASSERT_EQ(legacy_destination_url, actual_to_rpc->legacy_destination_url());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, CdmClientOnLegacySessionErrorRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + std::string session_id;
|
| + ::media::MediaKeys::Exception exception = ::media::MediaKeys::UNKNOWN_ERROR;
|
| + uint32_t system_code = 23;
|
| + std::string error_message;
|
| + scoped_refptr<Rpc> from_rpc(new CdmClientOnLegacySessionErrorRpc(
|
| + rpc_handle, session_id, exception, system_code, error_message));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + CdmClientOnLegacySessionErrorRpc* actual_to_rpc =
|
| + static_cast<CdmClientOnLegacySessionErrorRpc*>(to_rpc.get());
|
| + ASSERT_EQ(session_id, actual_to_rpc->session_id());
|
| + ASSERT_EQ(exception, actual_to_rpc->exception());
|
| + ASSERT_EQ(system_code, actual_to_rpc->system_code());
|
| + ASSERT_EQ(error_message, actual_to_rpc->error_message());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, CdmClientOnSessionKeysChangeRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + std::string session_id;
|
| + bool has_additional_usable_key = false;
|
| + scoped_refptr<Rpc> from_rpc(new CdmClientOnSessionKeysChangeRpc(
|
| + rpc_handle, session_id, has_additional_usable_key, nullptr, 0));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + CdmClientOnSessionKeysChangeRpc* actual_to_rpc =
|
| + static_cast<CdmClientOnSessionKeysChangeRpc*>(to_rpc.get());
|
| + ASSERT_EQ(session_id, actual_to_rpc->session_id());
|
| + ASSERT_EQ(has_additional_usable_key,
|
| + actual_to_rpc->has_additional_usable_key());
|
| + ASSERT_EQ(nullptr, actual_to_rpc->key_information());
|
| + ASSERT_EQ(static_cast<size_t>(0), actual_to_rpc->key_information_size());
|
| +}
|
| +
|
| +TEST_F(RemotingRpcTest, CdmClientOnSessionExpirationUpdateRpc) {
|
| + // Convert RPC data structure into proto buffer string
|
| + int rpc_handle = 3;
|
| + std::string session_id;
|
| + double new_expiry_time_sec = 3600.2;
|
| + scoped_refptr<Rpc> from_rpc(new CdmClientOnSessionExpirationUpdateRpc(
|
| + rpc_handle, session_id, new_expiry_time_sec));
|
| + ASSERT_EQ(rpc_handle, from_rpc->handle());
|
| + int proc = from_rpc->GetProc();
|
| + std::string proto_buffer_string = from_rpc->ToMessage();
|
| +
|
| + // Convert proto buffer string back to RPC data structure.
|
| + scoped_refptr<remoting::Rpc> to_rpc = Rpc::FromMessage(proto_buffer_string);
|
| + DCHECK(to_rpc);
|
| + ASSERT_EQ(proc, to_rpc->GetProc());
|
| + ASSERT_EQ(rpc_handle, to_rpc->handle());
|
| +
|
| + CdmClientOnSessionExpirationUpdateRpc* actual_to_rpc =
|
| + static_cast<CdmClientOnSessionExpirationUpdateRpc*>(to_rpc.get());
|
| + ASSERT_EQ(session_id, actual_to_rpc->session_id());
|
| + ASSERT_EQ(new_expiry_time_sec, actual_to_rpc->new_expiry_time_sec());
|
| +}
|
| +
|
| +} // namespace remoting
|
| +} // namespace media
|
|
|