Source release v3.0.4

This commit is contained in:
Joey Parrish
2015-12-14 10:01:38 -08:00
parent 3d5571eaa1
commit 973eb25a17
21 changed files with 734 additions and 191 deletions

View File

@@ -161,6 +161,8 @@
'include_dirs': [
'include',
],
},
'link_settings': {
'libraries': [
'-lpthread',
],

View File

@@ -1,7 +1,6 @@
// Copyright 2015 Google Inc. All Rights Reserved.
// Based on the EME draft spec from 2015 June 01.
// https://rawgit.com/w3c/encrypted-media/1cbedad/index.html
// TODO: Verify behavior and update to June 12 draft.
// Based on the EME draft spec from 2015 November 20.
// https://rawgit.com/w3c/encrypted-media/1dab9e5/index.html
#ifndef WVCDM_CDM_CDM_H_
#define WVCDM_CDM_CDM_H_
@@ -49,7 +48,9 @@ class CDM_EXPORT Cdm : public ITimerClient {
// Session types defined by EME.
typedef enum {
kTemporary = 0,
kPersistent = 1,
kPersistentLicense = 1,
kPersistent = kPersistentLicense, // deprecated name from June 1 draft
kPersistentUsageRecord = 2,
} SessionType;
// Message types defined by EME.
@@ -67,11 +68,15 @@ class CDM_EXPORT Cdm : public ITimerClient {
kSessionNotFound = 2,
kDecryptError = 3,
kNoKey = 4,
// These are analogous to the errors used by EME:
kInvalidAccess = 5,
kTypeError = 5,
kInvalidAccess = kTypeError, // deprecated name from June 1 draft
kNotSupported = 6,
kInvalidState = 7,
kQuotaExceeded = 8,
kRangeError = 9,
// This covers errors that we do not expect (see logs for details):
kUnexpectedError = 99999,
} Status;
@@ -87,9 +92,11 @@ class CDM_EXPORT Cdm : public ITimerClient {
typedef enum {
kUsable = 0,
kExpired = 1,
kOutputNotAllowed = 2,
kOutputRestricted = 2,
kOutputNotAllowed = kOutputRestricted, // deprecated name from June 1 draft
kStatusPending = 3,
kInternalError = 4,
kReleased = 5,
} KeyStatus;
// These are defined by Widevine. The CDM can be configured to decrypt in
@@ -316,7 +323,7 @@ class CDM_EXPORT Cdm : public ITimerClient {
// license server.
// If |privacy_mode| was true in create() and setServerCertificate() is not
// called, the CDM will attempt to provision a server certificate through
// IEventListener::onMessage() with messageType == kIndividualizationRequest.
// IEventListener::onMessage() with messageType == kLicenseRequest.
// May not be called if |privacy_mode| was false.
virtual Status setServerCertificate(const std::string& certificate) = 0;
@@ -453,13 +460,13 @@ class CDM_EXPORT Cdm : public ITimerClient {
const std::string& value) = 0;
// Gets the current value in the custom app settings. If the key is
// not present, then kInvalidAccess is returned. The |key| cannot be
// not present, then kTypeError is returned. The |key| cannot be
// empty. |result| cannot be null. See setAppParameter().
virtual Status getAppParameter(const std::string& key,
std::string* result) = 0;
// Removes the value in the custom app settings. If the key is not
// present, then kInvalidAccess is returned. The |key| cannot be empty.
// present, then kTypeError is returned. The |key| cannot be empty.
// See setAppParameter().
virtual Status removeAppParameter(const std::string& key) = 0;

View File

@@ -1,2 +1,2 @@
// Widevine CE CDM Version
#define CDM_VERSION "v3.0.3-0-g226db8b-ce"
#define CDM_VERSION "v3.0.4-0-g4dee2a8-ce"

View File

@@ -2,6 +2,7 @@
#include "cdm.h"
#include <assert.h>
#include <limits.h> // LLONG_MAX
#include <string.h> // memcpy
#include <vector>
@@ -11,6 +12,7 @@
#include "cdm_engine.h"
#include "clock.h"
#include "crypto_session.h"
#include "device_files.h"
#include "file_store.h"
#include "license.h"
#include "log.h"
@@ -171,9 +173,18 @@ class CdmImpl : public Cdm,
PropertySet property_set_;
CdmAppParameterMap app_parameters_;
std::map<std::string, SessionType> new_session_types_;
std::map<std::string, int64_t> session_expirations_;
std::map<std::string, KeyStatusMap> session_key_statuses_;
struct SessionMetadata {
bool callable; // EME terminology: request generated or session loaded
SessionType type;
int64_t expiration;
KeyStatusMap key_statuses;
SessionMetadata()
: callable(false),
type((SessionType)-1),
expiration(0) {}
};
std::map<std::string, SessionMetadata> sessions_;
};
CdmImpl::CdmImpl(IEventListener* listener,
@@ -195,12 +206,12 @@ Cdm::Status CdmImpl::setServerCertificate(const std::string& certificate) {
if (certificate.empty()) {
LOGE("An empty server certificate is invalid.");
return kInvalidAccess;
return kTypeError;
}
if (CdmLicense::VerifySignedServiceCertificate(certificate) != NO_ERROR) {
LOGE("Invalid server certificate!");
return kInvalidAccess;
return kTypeError;
}
property_set_.set_service_certificate(certificate);
@@ -211,7 +222,7 @@ Cdm::Status CdmImpl::createSession(SessionType session_type,
std::string* session_id) {
if (!session_id) {
LOGE("Missing session ID pointer.");
return kInvalidAccess;
return kTypeError;
}
// Important! The caller may pass a pre-filled string, which must be cleared
// before being given to CdmEngine.
@@ -219,7 +230,8 @@ Cdm::Status CdmImpl::createSession(SessionType session_type,
switch (session_type) {
case kTemporary:
case kPersistent:
case kPersistentLicense:
case kPersistentUsageRecord:
break;
default:
LOGE("Unsupported session type: %d", session_type);
@@ -232,7 +244,7 @@ Cdm::Status CdmImpl::createSession(SessionType session_type,
NULL, session_id);
switch (result) {
case NO_ERROR:
new_session_types_[*session_id] = session_type;
sessions_[*session_id].type = session_type;
return kSuccess;
case NEED_PROVISIONING:
LOGE("A device certificate is needed.");
@@ -251,22 +263,23 @@ Cdm::Status CdmImpl::generateRequest(const std::string& session_id,
return kSessionNotFound;
}
std::map<std::string, SessionType>::iterator it =
new_session_types_.find(session_id);
if (it == new_session_types_.end()) {
if (sessions_[session_id].callable) {
LOGE("Request already generated: %s", session_id.c_str());
return kInvalidState;
}
SessionType session_type = it->second;
SessionType session_type = sessions_[session_id].type;
CdmLicenseType license_type;
switch (session_type) {
case kTemporary:
license_type = kLicenseTypeStreaming;
license_type = kLicenseTypeTemporary;
break;
case kPersistent:
case kPersistentLicense:
license_type = kLicenseTypeOffline;
break;
case kPersistentUsageRecord:
license_type = kLicenseTypeStreaming;
break;
default:
LOGE("Unexpected session type: %d", session_type);
return kUnexpectedError;
@@ -285,12 +298,12 @@ Cdm::Status CdmImpl::generateRequest(const std::string& session_id,
break;
default:
LOGE("Invalid init data type: %d", init_data_type);
return kInvalidAccess;
return kTypeError;
}
if (init_data.empty()) {
LOGE("Empty init data is not valid.");
return kInvalidAccess;
return kTypeError;
}
InitializationData init_data_obj(init_data_type_name, init_data);
@@ -316,26 +329,27 @@ Cdm::Status CdmImpl::generateRequest(const std::string& session_id,
return kUnexpectedError;
}
new_session_types_.erase(it);
sessions_[session_id].callable = true;
assert(key_request_type == kKeyRequestTypeInitial);
MessageType message_type = kLicenseRequest;
if (property_set_.use_privacy_mode() &&
property_set_.service_certificate().empty()) {
// We can deduce that this is a server cert request, even though CdmEgine
// cannot currently inform us of this.
message_type = kIndividualizationRequest;
// Previously, we used message type kIndividiualizationRequest for this.
// The EME editor has clarified that this was a misinterpretation of the
// spec, and that this should also be kLicenseRequest.
LOGI("A server certificate request has been generated.");
} else {
LOGI("A license request has been generated.");
}
listener_->onMessage(session_id, message_type, key_request);
listener_->onMessage(session_id, kLicenseRequest, key_request);
return kSuccess;
}
Cdm::Status CdmImpl::load(const std::string& session_id) {
if (session_id.empty()) {
LOGE("Empty session ID.");
return kInvalidAccess;
return kTypeError;
}
if (cdm_engine_.IsOpenSession(session_id)) {
@@ -359,11 +373,37 @@ Cdm::Status CdmImpl::load(const std::string& session_id) {
return kUnexpectedError;
}
DeviceFiles f;
if (!f.Init(kSecurityLevelUnknown)) {
LOGE("Unexpected error, failed to init DeviceFiles");
return kUnexpectedError;
}
if (!f.LicenseExists(session_id)) {
// This might be a usage record session which needs to be loaded.
CdmKeyMessage release_message;
result = cdm_engine_.LoadUsageSession(session_id, &release_message);
if (result == LOAD_USAGE_INFO_MISSING) {
LOGE("Unable to load license: %s", session_id.c_str());
cdm_engine_.CloseSession(session_id);
return kSessionNotFound;
} else if (result != KEY_MESSAGE) {
LOGE("Unexpected error %d", result);
cdm_engine_.CloseSession(session_id);
return kUnexpectedError;
}
LOGI("A usage record release has been generated.");
MessageType message_type = kLicenseRelease;
listener_->onMessage(session_id, message_type, release_message);
sessions_[session_id].type = kPersistentUsageRecord;
sessions_[session_id].callable = true;
return kSuccess;
}
result = cdm_engine_.RestoreKey(session_id, session_id);
if (result == GET_LICENSE_ERROR) {
LOGE("Unable to load license: %s", session_id.c_str());
return kSessionNotFound;
} else if (result == GET_RELEASED_LICENSE_ERROR) {
if (result == GET_RELEASED_LICENSE_ERROR) {
// This was partially removed already.
// The EME spec states that we should send a release message right away.
InitializationData empty_initialization_data;
@@ -388,6 +428,8 @@ Cdm::Status CdmImpl::load(const std::string& session_id) {
return kUnexpectedError;
}
sessions_[session_id].type = kPersistentLicense;
sessions_[session_id].callable = true;
return kSuccess;
}
@@ -398,14 +440,14 @@ Cdm::Status CdmImpl::update(const std::string& session_id,
return kSessionNotFound;
}
if (new_session_types_.find(session_id) != new_session_types_.end()) {
if (!sessions_[session_id].callable) {
LOGE("Request not yet generated: %s", session_id.c_str());
return kInvalidState;
}
if (response.empty()) {
LOGE("Empty response.");
return kInvalidAccess;
return kTypeError;
}
// NOTE: If the CdmSession object recognizes that this is not the first
@@ -444,6 +486,12 @@ Cdm::Status CdmImpl::update(const std::string& session_id,
MessageType message_type = kLicenseRequest;
listener_->onMessage(session_id, message_type, key_request);
return kSuccess;
} else if (result == OFFLINE_LICENSE_PROHIBITED) {
LOGE("A temporary session cannot be used for a persistent license.");
return kRangeError;
} else if (result == STORAGE_PROHIBITED) {
LOGE("A temporary session cannot be used for a persistent usage records.");
return kRangeError;
} else if (result != KEY_ADDED) {
LOGE("Unexpected error %d", result);
return kUnexpectedError;
@@ -457,6 +505,7 @@ Cdm::Status CdmImpl::update(const std::string& session_id,
}
if (cdm_engine_.IsReleaseSession(session_id)) {
sessions_.erase(session_id);
cdm_engine_.CloseSession(session_id);
listener_->onRemoveComplete(session_id);
}
@@ -470,7 +519,7 @@ Cdm::Status CdmImpl::getExpiration(const std::string& session_id,
return kSessionNotFound;
}
*expiration = session_expirations_[session_id];
*expiration = sessions_[session_id].expiration;
return kSuccess;
}
@@ -481,14 +530,14 @@ Cdm::Status CdmImpl::getKeyStatuses(const std::string& session_id,
return kSessionNotFound;
}
*key_statuses = session_key_statuses_[session_id];
*key_statuses = sessions_[session_id].key_statuses;
return kSuccess;
}
Cdm::Status CdmImpl::setAppParameter(const std::string& key,
const std::string& value) {
if (key.empty()) {
return kInvalidAccess;
return kTypeError;
}
app_parameters_[key] = value;
return kSuccess;
@@ -498,7 +547,7 @@ Cdm::Status CdmImpl::getAppParameter(const std::string& key,
std::string* result) {
if (NULL == result || key.empty() ||
app_parameters_.find(key) == app_parameters_.end()) {
return kInvalidAccess;
return kTypeError;
}
*result = app_parameters_[key];
return kSuccess;
@@ -506,11 +555,11 @@ Cdm::Status CdmImpl::getAppParameter(const std::string& key,
Cdm::Status CdmImpl::removeAppParameter(const std::string& key) {
if (key.empty()) {
return kInvalidAccess;
return kTypeError;
}
CdmAppParameterMap::iterator it = app_parameters_.find(key);
if (it == app_parameters_.end()) {
return kInvalidAccess;
return kTypeError;
}
app_parameters_.erase(it);
return kSuccess;
@@ -532,6 +581,7 @@ Cdm::Status CdmImpl::close(const std::string& session_id) {
LOGE("Unexpected error %d", result);
return kUnexpectedError;
}
sessions_.erase(session_id);
return kSuccess;
}
@@ -541,20 +591,28 @@ Cdm::Status CdmImpl::remove(const std::string& session_id) {
return kSessionNotFound;
}
if (new_session_types_.find(session_id) != new_session_types_.end()) {
if (!sessions_[session_id].callable) {
LOGE("Request not yet generated: %s", session_id.c_str());
return kInvalidState;
}
if (!cdm_engine_.IsOfflineSession(session_id)) {
if (sessions_[session_id].type == kTemporary) {
LOGE("Not a persistent session: %s", session_id.c_str());
return kInvalidAccess;
return kRangeError;
}
InitializationData empty_initialization_data;
CdmKeyMessage key_request;
std::string ignored_server_url;
// Mark all keys as released ahead of generating the release request.
// When released, cdm_engine_ will mark all keys as expired, which we will
// ignore in this interface.
KeyStatusMap& map = sessions_[session_id].key_statuses;
for (KeyStatusMap::iterator it = map.begin(); it != map.end(); ++it) {
it->second = kReleased;
}
CdmResponseType result = cdm_engine_.GenerateKeyRequest(
session_id, session_id, empty_initialization_data,
kLicenseTypeRelease, app_parameters_, &key_request, NULL,
@@ -575,7 +633,7 @@ Cdm::Status CdmImpl::decrypt(const InputBuffer& input,
const OutputBuffer& output) {
if (input.is_encrypted && input.iv_length != 16) {
LOGE("The IV must be 16 bytes long.");
return kInvalidAccess;
return kTypeError;
}
if (PropertiesCE::GetSecureOutputType() == kNoSecureOutput &&
output.is_secure) {
@@ -651,7 +709,7 @@ void CdmImpl::OnSessionRenewalNeeded(const CdmSessionId& session_id) {
void CdmImpl::OnSessionKeysChange(const CdmSessionId& session_id,
const CdmKeyStatusMap& keys_status,
bool has_new_usable_key) {
KeyStatusMap& map = session_key_statuses_[session_id];
KeyStatusMap& map = sessions_[session_id].key_statuses;
CdmKeyStatusMap::const_iterator it;
for (it = keys_status.begin(); it != keys_status.end(); ++it) {
@@ -659,11 +717,18 @@ void CdmImpl::OnSessionKeysChange(const CdmSessionId& session_id,
case kKeyStatusUsable:
map[it->first] = kUsable;
break;
case kKeyStatusExpired:
map[it->first] = kExpired;
case kKeyStatusExpired: {
KeyStatusMap::const_iterator it_old = map.find(it->first);
if (it_old != map.end() && it_old->second == kReleased) {
// This key has already been marked as "released".
// Ignore the internal "expired" status.
} else {
map[it->first] = kExpired;
}
break;
}
case kKeyStatusOutputNotAllowed:
map[it->first] = kOutputNotAllowed;
map[it->first] = kOutputRestricted;
break;
case kKeyStatusPending:
map[it->first] = kStatusPending;
@@ -683,7 +748,12 @@ void CdmImpl::OnSessionKeysChange(const CdmSessionId& session_id,
void CdmImpl::OnExpirationUpdate(const CdmSessionId& session_id,
int64_t new_expiry_time_seconds) {
session_expirations_[session_id] = new_expiry_time_seconds * 1000;
// "Never expires" in core is LLONG_MAX. In the CDM API, it's -1.
if (new_expiry_time_seconds == LLONG_MAX) {
sessions_[session_id].expiration = -1;
} else {
sessions_[session_id].expiration = new_expiry_time_seconds * 1000;
}
}
@@ -728,24 +798,24 @@ Cdm::Status Cdm::initialize(
break;
default:
LOGE("Invalid output type!");
return kInvalidAccess;
return kTypeError;
}
if (client_info.product_name.empty() ||
client_info.company_name.empty() ||
client_info.model_name.empty()) {
LOGE("Client info requires product_name, company_name, model_name!");
return kInvalidAccess;
return kTypeError;
}
if (!storage || !clock || !timer) {
LOGE("All interfaces are required!");
return kInvalidAccess;
return kTypeError;
}
if (!device_certificate_request) {
LOGE("Device certificate request pointer is required!");
return kInvalidAccess;
return kTypeError;
}
// Our enum values match those in core/include/log.h
@@ -811,7 +881,7 @@ Cdm::Status Cdm::DeviceCertificateRequest::acceptReply(
const std::string& reply) {
if (!host.provisioning_engine) {
LOGE("Provisioning reply received while not in a provisioning state!");
return kInvalidAccess;
return kTypeError;
}
std::string empty_origin;
@@ -901,7 +971,11 @@ void File::Close() {
}
bool File::Exists(const std::string& file_path) {
return host.storage->exists(file_path);
// An empty path is the "base directory" for CE CDM's file storage.
// Therefore, it should always be seen as existing.
// If it ever does not exist, CdmEngine detects this as a "factory reset"
// and wipes out all usage table data.
return file_path.empty() || host.storage->exists(file_path);
}
bool File::Remove(const std::string& file_path) {

View File

@@ -142,6 +142,11 @@ class CdmTest : public Test,
// Clear anything stored, load default device cert.
g_host->Reset();
// Clear anything stored by OEMCrypto.
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_Initialize());
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_DeleteUsageTable());
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_Terminate());
// Reinit the library.
Cdm::DeviceCertificateRequest cert_request;
Cdm::Status status = Cdm::initialize(
@@ -230,61 +235,40 @@ class CdmTest : public Test,
if (ok) ASSERT_EQ(expected_status_code, status_code);
}
void CreateTemporarySessionAndGenerateRequest(std::string* session_id,
std::string* message) {
Cdm::Status status = cdm_->createSession(Cdm::kTemporary, session_id);
void CreateSessionAndGenerateRequest(Cdm::SessionType session_type,
std::string* session_id,
std::string* message) {
Cdm::Status status = cdm_->createSession(session_type, session_id);
ASSERT_EQ(Cdm::kSuccess, status);
std::string init_data;
if (session_type == Cdm::kTemporary) {
init_data = kCencInitData;
} else {
init_data = kCencPersistentInitData;
}
EXPECT_CALL(*this, onMessage(*session_id, Cdm::kLicenseRequest, _)).
WillOnce(SaveArg<2>(message));
status = cdm_->generateRequest(*session_id, Cdm::kCenc, kCencInitData);
status = cdm_->generateRequest(*session_id, Cdm::kCenc, init_data);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
}
void CreatePersistentSessionAndGenerateRequest(std::string* session_id,
std::string* message) {
Cdm::Status status = cdm_->createSession(Cdm::kPersistent, session_id);
ASSERT_EQ(Cdm::kSuccess, status);
EXPECT_CALL(*this, onMessage(*session_id, Cdm::kLicenseRequest, _)).
WillOnce(SaveArg<2>(message));
status = cdm_->generateRequest(*session_id, Cdm::kCenc,
kCencPersistentInitData);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
}
void CreateTemporarySessionAndFetchLicense(std::string* session_id,
std::string* response) {
void CreateSessionAndFetchLicense(Cdm::SessionType session_type,
std::string* session_id,
std::string* response) {
std::string message;
ASSERT_NO_FATAL_FAILURE(CreateTemporarySessionAndGenerateRequest(
session_id, &message));
ASSERT_NO_FATAL_FAILURE(CreateSessionAndGenerateRequest(
session_type, session_id, &message));
FetchLicense(message, response);
}
void CreatePersistentSessionAndFetchLicense(std::string* session_id,
std::string* response) {
std::string message;
ASSERT_NO_FATAL_FAILURE(CreatePersistentSessionAndGenerateRequest(
session_id, &message));
FetchLicense(message, response);
}
void CreateTemporarySessionAndUpdate(std::string* session_id) {
void CreateSessionAndUpdate(Cdm::SessionType session_type,
std::string* session_id) {
std::string response;
ASSERT_NO_FATAL_FAILURE(CreateTemporarySessionAndFetchLicense(
session_id, &response));
EXPECT_CALL(*this, onKeyStatusesChange(*session_id));
Cdm::Status status = cdm_->update(*session_id, response);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
}
void CreatePersistentSessionAndUpdate(std::string* session_id) {
std::string response;
ASSERT_NO_FATAL_FAILURE(CreatePersistentSessionAndFetchLicense(
session_id, &response));
ASSERT_NO_FATAL_FAILURE(CreateSessionAndFetchLicense(
session_type, session_id, &response));
EXPECT_CALL(*this, onKeyStatusesChange(*session_id));
Cdm::Status status = cdm_->update(*session_id, response);
ASSERT_EQ(Cdm::kSuccess, status);
@@ -352,7 +336,7 @@ TEST_F(CdmTest, Initialize) {
static_cast<Cdm::SecureOutputType>(-1), PropertiesCE::GetClientInfo(),
g_host, g_host, g_host, &cert_request,
static_cast<Cdm::LogLevel>(g_cutoff));
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
// Try with various client info properties missing.
Cdm::ClientInfo working_client_info = PropertiesCE::GetClientInfo();
@@ -364,7 +348,7 @@ TEST_F(CdmTest, Initialize) {
Cdm::kNoSecureOutput, broken_client_info,
g_host, g_host, g_host, &cert_request,
static_cast<Cdm::LogLevel>(g_cutoff));
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
broken_client_info = working_client_info;
broken_client_info.company_name.clear();
@@ -372,7 +356,7 @@ TEST_F(CdmTest, Initialize) {
Cdm::kNoSecureOutput, broken_client_info,
g_host, g_host, g_host, &cert_request,
static_cast<Cdm::LogLevel>(g_cutoff));
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
broken_client_info = working_client_info;
broken_client_info.device_name.clear(); // Not required
@@ -388,7 +372,7 @@ TEST_F(CdmTest, Initialize) {
Cdm::kNoSecureOutput, broken_client_info,
g_host, g_host, g_host, &cert_request,
static_cast<Cdm::LogLevel>(g_cutoff));
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
broken_client_info = working_client_info;
broken_client_info.arch_name.clear(); // Not required
@@ -411,25 +395,25 @@ TEST_F(CdmTest, Initialize) {
Cdm::kNoSecureOutput, working_client_info,
NULL, g_host, g_host, &cert_request,
static_cast<Cdm::LogLevel>(g_cutoff));
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
status = Cdm::initialize(
Cdm::kNoSecureOutput, working_client_info,
g_host, NULL, g_host, &cert_request,
static_cast<Cdm::LogLevel>(g_cutoff));
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
status = Cdm::initialize(
Cdm::kNoSecureOutput, working_client_info,
g_host, g_host, NULL, &cert_request,
static_cast<Cdm::LogLevel>(g_cutoff));
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
status = Cdm::initialize(
Cdm::kNoSecureOutput, working_client_info,
g_host, g_host, g_host, NULL,
static_cast<Cdm::LogLevel>(g_cutoff));
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
// One last init with everything correct and working.
status = Cdm::initialize(
@@ -502,11 +486,11 @@ TEST_F(CdmTest, SetServerCertificate) {
// It is invalid to set an empty cert.
status = cdm_->setServerCertificate("");
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
// It is invalid to set a malformed cert.
status = cdm_->setServerCertificate("asdf");
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
}
TEST_F(CdmTest, CreateSession) {
@@ -524,12 +508,12 @@ TEST_F(CdmTest, CreateSession) {
EXPECT_NE(original_session_id, session_id);
// Create a persistent session.
status = cdm_->createSession(Cdm::kPersistent, &session_id);
status = cdm_->createSession(Cdm::kPersistentLicense, &session_id);
EXPECT_EQ(Cdm::kSuccess, status);
// Try a NULL pointer for session ID.
status = cdm_->createSession(Cdm::kTemporary, NULL);
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
// Try a bogus session type.
status = cdm_->createSession(kBogusSessionType, &session_id);
@@ -574,7 +558,7 @@ TEST_F(CdmTest, GenerateRequest) {
ASSERT_EQ(Cdm::kSuccess, status);
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRequest, _)).Times(0);
status = cdm_->generateRequest(session_id, kBogusInitDataType, "asdf");
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
Mock::VerifyAndClear(this);
// This same session should still be usable with a supported init data type
@@ -589,7 +573,7 @@ TEST_F(CdmTest, GenerateRequest) {
ASSERT_EQ(Cdm::kSuccess, status);
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRequest, _)).Times(0);
status = cdm_->generateRequest(session_id, Cdm::kCenc, "");
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
Mock::VerifyAndClear(this);
// Try to pass invalid CENC init data.
@@ -619,8 +603,8 @@ TEST_F(CdmTest, GenerateRequest) {
TEST_F(CdmTest, Update) {
std::string session_id;
std::string message;
ASSERT_NO_FATAL_FAILURE(CreateTemporarySessionAndGenerateRequest(
&session_id, &message));
ASSERT_NO_FATAL_FAILURE(CreateSessionAndGenerateRequest(
Cdm::kTemporary, &session_id, &message));
// Acquire a license.
std::string response;
@@ -638,7 +622,7 @@ TEST_F(CdmTest, Update) {
// Try updating with an empty response.
status = cdm_->update(session_id, "");
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kTypeError, status);
// Create a new session and try updating before generating a request.
status = cdm_->createSession(Cdm::kTemporary, &session_id);
@@ -675,8 +659,8 @@ TEST_F(CdmTest, Close) {
TEST_F(CdmTest, LoadTemporary) {
std::string session_id;
std::string response;
ASSERT_NO_FATAL_FAILURE(CreateTemporarySessionAndFetchLicense(
&session_id, &response));
ASSERT_NO_FATAL_FAILURE(CreateSessionAndFetchLicense(
Cdm::kTemporary, &session_id, &response));
// Update the temporary session.
EXPECT_CALL(*this, onKeyStatusesChange(session_id));
@@ -696,8 +680,8 @@ TEST_F(CdmTest, LoadTemporary) {
TEST_F(CdmTest, LoadPersistent) {
std::string session_id;
std::string response;
ASSERT_NO_FATAL_FAILURE(CreatePersistentSessionAndFetchLicense(
&session_id, &response));
ASSERT_NO_FATAL_FAILURE(CreateSessionAndFetchLicense(
Cdm::kPersistentLicense, &session_id, &response));
// Update the persistent session.
EXPECT_CALL(*this, onKeyStatusesChange(session_id));
@@ -731,6 +715,49 @@ TEST_F(CdmTest, LoadPersistent) {
Mock::VerifyAndClear(this);
}
TEST_F(CdmTest, LoadUsageRecord) {
std::string session_id;
std::string response;
ASSERT_NO_FATAL_FAILURE(CreateSessionAndFetchLicense(
Cdm::kPersistentUsageRecord, &session_id, &response));
// Update the session.
EXPECT_CALL(*this, onKeyStatusesChange(session_id));
Cdm::Status status = cdm_->update(session_id, response);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
// Should be able to load the session again after closing it.
status = cdm_->close(session_id);
ASSERT_EQ(Cdm::kSuccess, status);
// There should be no usable keys after loading this session.
EXPECT_CALL(*this, onKeyStatusesChange(session_id)).Times(0);
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRelease, _));
status = cdm_->load(session_id);
EXPECT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
// Should be able to load the session again after recreating the CDM.
ASSERT_NO_FATAL_FAILURE(RecreateCdm(true /* privacy_mode */));
ASSERT_NO_FATAL_FAILURE(SetDefaultServerCertificate());
EXPECT_CALL(*this, onKeyStatusesChange(session_id)).Times(0);
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRelease, _));
status = cdm_->load(session_id);
EXPECT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
// Should not be able to load the session again clearing storage.
status = cdm_->close(session_id);
ASSERT_EQ(Cdm::kSuccess, status);
g_host->Reset();
EXPECT_CALL(*this, onKeyStatusesChange(session_id)).Times(0);
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRelease, _)).Times(0);
status = cdm_->load(session_id);
EXPECT_EQ(Cdm::kSessionNotFound, status);
Mock::VerifyAndClear(this);
}
TEST_F(CdmTest, LoadBogus) {
EXPECT_CALL(*this, onKeyStatusesChange(_)).Times(0);
Cdm::Status status = cdm_->load(kBogusSessionId);
@@ -739,7 +766,7 @@ TEST_F(CdmTest, LoadBogus) {
TEST_F(CdmTest, GetKeyStatuses) {
std::string session_id;
ASSERT_NO_FATAL_FAILURE(CreateTemporarySessionAndUpdate(&session_id));
ASSERT_NO_FATAL_FAILURE(CreateSessionAndUpdate(Cdm::kTemporary, &session_id));
// We should be able to query status and see a usable key.
Cdm::KeyStatusMap map;
@@ -773,7 +800,7 @@ TEST_F(CdmTest, GetKeyStatuses) {
TEST_F(CdmTest, GetExpiration) {
std::string session_id;
ASSERT_NO_FATAL_FAILURE(CreateTemporarySessionAndUpdate(&session_id));
ASSERT_NO_FATAL_FAILURE(CreateSessionAndUpdate(Cdm::kTemporary, &session_id));
// We should be able to query expiration and get a value in the future.
int64_t expiration;
@@ -805,7 +832,8 @@ TEST_F(CdmTest, GetExpiration) {
TEST_F(CdmTest, Remove) {
std::string session_id;
ASSERT_NO_FATAL_FAILURE(CreatePersistentSessionAndUpdate(&session_id));
ASSERT_NO_FATAL_FAILURE(CreateSessionAndUpdate(
Cdm::kPersistentLicense, &session_id));
// Remove the session. This causes a release message to be generated.
std::string message;
@@ -820,7 +848,7 @@ TEST_F(CdmTest, Remove) {
Cdm::KeyStatusMap map;
status = cdm_->getKeyStatuses(session_id, &map);
ASSERT_EQ(Cdm::kSuccess, status);
EXPECT_EQ(Cdm::kExpired, map.begin()->second);
EXPECT_EQ(Cdm::kReleased, map.begin()->second);
// Post the release message to the license server.
std::string response;
@@ -843,20 +871,56 @@ TEST_F(CdmTest, Remove) {
EXPECT_EQ(Cdm::kSessionNotFound, status);
// Try a new session.
status = cdm_->createSession(Cdm::kPersistent, &session_id);
status = cdm_->createSession(Cdm::kPersistentLicense, &session_id);
ASSERT_EQ(Cdm::kSuccess, status);
status = cdm_->remove(session_id);
EXPECT_EQ(Cdm::kInvalidState, status);
// Try a temporary session.
ASSERT_NO_FATAL_FAILURE(CreateTemporarySessionAndUpdate(&session_id));
ASSERT_NO_FATAL_FAILURE(CreateSessionAndUpdate(Cdm::kTemporary, &session_id));
status = cdm_->remove(session_id);
EXPECT_EQ(Cdm::kInvalidAccess, status);
EXPECT_EQ(Cdm::kRangeError, status);
}
TEST_F(CdmTest, RemoveUsageRecord) {
std::string session_id;
ASSERT_NO_FATAL_FAILURE(CreateSessionAndUpdate(
Cdm::kPersistentUsageRecord, &session_id));
// Remove the session. This causes a release message to be generated.
std::string message;
EXPECT_CALL(*this, onKeyStatusesChange(session_id));
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRelease, _)).WillOnce(
SaveArg<2>(&message));
Cdm::Status status = cdm_->remove(session_id);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
// The keys should already be unusable.
Cdm::KeyStatusMap map;
status = cdm_->getKeyStatuses(session_id, &map);
ASSERT_EQ(Cdm::kSuccess, status);
EXPECT_EQ(Cdm::kReleased, map.begin()->second);
// Post the release message to the license server.
std::string response;
ASSERT_NO_FATAL_FAILURE(FetchLicense(message, &response));
// Update the session.
EXPECT_CALL(*this, onRemoveComplete(session_id));
status = cdm_->update(session_id, response);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
// The session is now completely gone.
status = cdm_->close(session_id);
ASSERT_EQ(Cdm::kSessionNotFound, status);
}
TEST_F(CdmTest, RemoveIncomplete) {
std::string session_id;
ASSERT_NO_FATAL_FAILURE(CreatePersistentSessionAndUpdate(&session_id));
ASSERT_NO_FATAL_FAILURE(CreateSessionAndUpdate(
Cdm::kPersistentLicense, &session_id));
// Remove the session. This causes a release message to be generated.
std::string message;
@@ -872,7 +936,64 @@ TEST_F(CdmTest, RemoveIncomplete) {
status = cdm_->getKeyStatuses(session_id, &map);
ASSERT_EQ(Cdm::kSuccess, status);
ASSERT_FALSE(map.empty());
EXPECT_EQ(Cdm::kExpired, map.begin()->second);
EXPECT_EQ(Cdm::kReleased, map.begin()->second);
// Recreate the CDM.
ASSERT_NO_FATAL_FAILURE(RecreateCdm(true /* privacy_mode */));
ASSERT_NO_FATAL_FAILURE(SetDefaultServerCertificate());
// Load the partially removed session, which will immediately generate a
// release message.
message.clear();
EXPECT_CALL(*this, onKeyStatusesChange(session_id)).Times(0);
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRelease, _)).WillOnce(
SaveArg<2>(&message));
status = cdm_->load(session_id);
ASSERT_EQ(Cdm::kSuccess, status);
ASSERT_FALSE(message.empty());
Mock::VerifyAndClear(this);
// This session has no keys.
status = cdm_->getKeyStatuses(session_id, &map);
ASSERT_EQ(Cdm::kSuccess, status);
EXPECT_TRUE(map.empty());
// Post the release message to the license server.
std::string response;
ASSERT_NO_FATAL_FAILURE(FetchLicense(message, &response));
// Update the session.
EXPECT_CALL(*this, onKeyStatusesChange(session_id)).Times(0);
EXPECT_CALL(*this, onRemoveComplete(session_id));
status = cdm_->update(session_id, response);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
// The session is now completely gone.
status = cdm_->load(session_id);
ASSERT_EQ(Cdm::kSessionNotFound, status);
}
TEST_F(CdmTest, RemoveUsageRecordIncomplete) {
std::string session_id;
ASSERT_NO_FATAL_FAILURE(CreateSessionAndUpdate(
Cdm::kPersistentUsageRecord, &session_id));
// Remove the session. This causes a release message to be generated.
std::string message;
EXPECT_CALL(*this, onKeyStatusesChange(session_id));
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRelease, _)).WillOnce(
SaveArg<2>(&message));
Cdm::Status status = cdm_->remove(session_id);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
// The keys should already be unusable, but they should still exist.
Cdm::KeyStatusMap map;
status = cdm_->getKeyStatuses(session_id, &map);
ASSERT_EQ(Cdm::kSuccess, status);
ASSERT_FALSE(map.empty());
EXPECT_EQ(Cdm::kReleased, map.begin()->second);
// Recreate the CDM.
ASSERT_NO_FATAL_FAILURE(RecreateCdm(true /* privacy_mode */));
@@ -913,7 +1034,8 @@ TEST_F(CdmTest, RemoveIncomplete) {
TEST_F(CdmTest, RemoveNotLoaded) {
// Create a persistent session and then close it.
std::string session_id;
ASSERT_NO_FATAL_FAILURE(CreatePersistentSessionAndUpdate(&session_id));
ASSERT_NO_FATAL_FAILURE(CreateSessionAndUpdate(
Cdm::kPersistentLicense, &session_id));
Cdm::Status status = cdm_->close(session_id);
ASSERT_EQ(Cdm::kSuccess, status);
@@ -945,7 +1067,7 @@ TEST_F(CdmTest, DecryptClear) {
// Create a session with the right keys.
std::string session_id;
ASSERT_NO_FATAL_FAILURE(CreateTemporarySessionAndUpdate(&session_id));
ASSERT_NO_FATAL_FAILURE(CreateSessionAndUpdate(Cdm::kTemporary, &session_id));
// Decrypt should now succeed.
status = cdm_->decrypt(input, output);
@@ -958,7 +1080,8 @@ TEST_F(CdmTest, RequestPersistentLicenseWithWrongInitData) {
// Generate a request for a persistent license without using the correct
// persistent content init data.
std::string session_id;
Cdm::Status status = cdm_->createSession(Cdm::kPersistent, &session_id);
Cdm::Status status = cdm_->createSession(Cdm::kPersistentLicense,
&session_id);
ASSERT_EQ(Cdm::kSuccess, status);
std::string message;
@@ -990,24 +1113,16 @@ TEST_F(CdmTest, RequestTemporaryLicenseWithWrongInitData) {
std::string response;
ASSERT_NO_FATAL_FAILURE(FetchLicense(message, &response));
// This license should be accepted.
// This license should not be accepted.
EXPECT_CALL(*this, onKeyStatusesChange(session_id));
status = cdm_->update(session_id, response);
EXPECT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
// Should not be able to load the session again after closing it.
status = cdm_->close(session_id);
ASSERT_EQ(Cdm::kSuccess, status);
EXPECT_CALL(*this, onKeyStatusesChange(session_id)).Times(0);
status = cdm_->load(session_id);
EXPECT_EQ(Cdm::kSessionNotFound, status);
EXPECT_EQ(Cdm::kRangeError, status);
Mock::VerifyAndClear(this);
}
TEST_F(CdmTest, Renewal) {
std::string session_id;
ASSERT_NO_FATAL_FAILURE(CreateTemporarySessionAndUpdate(&session_id));
ASSERT_NO_FATAL_FAILURE(CreateSessionAndUpdate(Cdm::kTemporary, &session_id));
// We should have a timer.
EXPECT_NE(0, g_host->NumTimers());
@@ -1044,9 +1159,10 @@ TEST_F(CdmTest, ServerCertificateProvisioning) {
Cdm::Status status = cdm_->createSession(Cdm::kTemporary, &session_id);
ASSERT_EQ(Cdm::kSuccess, status);
// Expect an individualization request.
// Expect a license request type message, but this is actually a server cert
// provisioning request.
std::string message;
EXPECT_CALL(*this, onMessage(session_id, Cdm::kIndividualizationRequest, _)).
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRequest, _)).
WillOnce(SaveArg<2>(&message));
status = cdm_->generateRequest(session_id, Cdm::kCenc, kCencInitData);
ASSERT_EQ(Cdm::kSuccess, status);
@@ -1058,7 +1174,7 @@ TEST_F(CdmTest, ServerCertificateProvisioning) {
// No keys will change, since this wasn't a license.
EXPECT_CALL(*this, onKeyStatusesChange(session_id)).Times(0);
// We should get an actual license request generated during update.
// We should get another license request generated during update.
message.clear();
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRequest, _)).WillOnce(
SaveArg<2>(&message));
@@ -1076,7 +1192,7 @@ TEST_F(CdmTest, ServerCertificateProvisioning) {
ASSERT_NO_FATAL_FAILURE(FetchLicense(message, &response));
// Update the session. The keys will change now.
EXPECT_CALL(*this, onKeyStatusesChange(session_id));
EXPECT_CALL(*this, onKeyStatusesChange(session_id)).Times(1);
status = cdm_->update(session_id, response);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
@@ -1087,17 +1203,30 @@ TEST_F(CdmTest, ServerCertificateProvisioning) {
ASSERT_FALSE(map.empty());
EXPECT_EQ(Cdm::kUsable, map.begin()->second);
// Create another session. This one should not require server certificate
// provisioning.
status = cdm_->createSession(Cdm::kTemporary, &session_id);
ASSERT_EQ(Cdm::kSuccess, status);
// Expect a license request, not an individualization request.
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRequest, _));
// Expect a license request.
message.clear();
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRequest, _)).WillOnce(
SaveArg<2>(&message));
status = cdm_->generateRequest(session_id, Cdm::kCenc, kCencInitData);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
// Relay it to the server.
ASSERT_NO_FATAL_FAILURE(FetchLicense(message, &response));
// Keys will change, since this was an actual license.
EXPECT_CALL(*this, onKeyStatusesChange(session_id)).Times(1);
status = cdm_->update(session_id, response);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
// Create a second CDM instance.
scoped_ptr<Cdm> cdm2;
CreateAdditionalCdm(true /* privacy_mode */, &cdm2);
@@ -1107,20 +1236,45 @@ TEST_F(CdmTest, ServerCertificateProvisioning) {
// instances.
status = cdm2->createSession(Cdm::kTemporary, &session_id);
ASSERT_EQ(Cdm::kSuccess, status);
EXPECT_CALL(*this, onMessage(session_id, Cdm::kIndividualizationRequest, _));
message.clear();
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRequest, _)).WillOnce(
SaveArg<2>(&message));
status = cdm2->generateRequest(session_id, Cdm::kCenc, kCencInitData);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
// Relay it to the server.
ASSERT_NO_FATAL_FAILURE(FetchLicense(message, &response));
// No keys will change, since this wasn't a license.
EXPECT_CALL(*this, onKeyStatusesChange(session_id)).Times(0);
// We should get another license request generated during update.
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRequest, _));
status = cdm2->update(session_id, response);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
// Create another session on the first CDM. This one should not require
// server certificate provisioning. This proves that the creation of the
// second CDM instance did not affect the state of the first.
status = cdm_->createSession(Cdm::kTemporary, &session_id);
ASSERT_EQ(Cdm::kSuccess, status);
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRequest, _));
message.clear();
EXPECT_CALL(*this, onMessage(session_id, Cdm::kLicenseRequest, _)).WillOnce(
SaveArg<2>(&message));
status = cdm_->generateRequest(session_id, Cdm::kCenc, kCencInitData);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
// Relay it to the server.
ASSERT_NO_FATAL_FAILURE(FetchLicense(message, &response));
// Keys will change, since this was an actual license.
EXPECT_CALL(*this, onKeyStatusesChange(session_id)).Times(1);
status = cdm_->update(session_id, response);
ASSERT_EQ(Cdm::kSuccess, status);
Mock::VerifyAndClear(this);
}
TEST_F(CdmTest, SetAppParameters) {
@@ -1140,19 +1294,19 @@ TEST_F(CdmTest, SetAppParameters) {
// Try to get using a null result.
status = cdm_->getAppParameter(kParamName, NULL);
ASSERT_EQ(Cdm::kInvalidAccess, status);
ASSERT_EQ(Cdm::kTypeError, status);
// Try to get using an empty key.
status = cdm_->getAppParameter("", &result);
ASSERT_EQ(Cdm::kInvalidAccess, status);
ASSERT_EQ(Cdm::kTypeError, status);
// Try to set using an empty key.
status = cdm_->setAppParameter("", kValue);
ASSERT_EQ(Cdm::kInvalidAccess, status);
ASSERT_EQ(Cdm::kTypeError, status);
// Try to remove using an empty key.
status = cdm_->removeAppParameter("");
ASSERT_EQ(Cdm::kInvalidAccess, status);
ASSERT_EQ(Cdm::kTypeError, status);
// Change an existing app parameter.
status = cdm_->setAppParameter(kParamName, kNewValue);
@@ -1165,11 +1319,11 @@ TEST_F(CdmTest, SetAppParameters) {
status = cdm_->removeAppParameter(kParamName);
ASSERT_EQ(Cdm::kSuccess, status);
status = cdm_->getAppParameter(kParamName, &result);
ASSERT_EQ(Cdm::kInvalidAccess, status);
ASSERT_EQ(Cdm::kTypeError, status);
// Try to remove an absent value.
status = cdm_->removeAppParameter(kParamName2);
ASSERT_EQ(Cdm::kInvalidAccess, status);
ASSERT_EQ(Cdm::kTypeError, status);
// Set some values to check for.
status = cdm_->setAppParameter(kParamName, kValue);
@@ -1198,9 +1352,9 @@ TEST_F(CdmTest, SetAppParameters) {
status = cdm_->clearAppParameters();
ASSERT_EQ(Cdm::kSuccess, status);
status = cdm_->getAppParameter(kParamName, &result);
ASSERT_EQ(Cdm::kInvalidAccess, status);
ASSERT_EQ(Cdm::kTypeError, status);
status = cdm_->getAppParameter(kParamName2, &result);
ASSERT_EQ(Cdm::kInvalidAccess, status);
ASSERT_EQ(Cdm::kTypeError, status);
}
} // namespace widevine

View File

@@ -32,7 +32,7 @@ void PrintTo(const Cdm::Status& value, ::std::ostream* os) {
break;
case Cdm::kNoKey: *os << "Cdm::kNoKey";
break;
case Cdm::kInvalidAccess: *os << "Cdm::kInvalidAccess";
case Cdm::kTypeError: *os << "Cdm::kTypeError";
break;
case Cdm::kNotSupported: *os << "Cdm::kNotSupported";
break;
@@ -40,6 +40,8 @@ void PrintTo(const Cdm::Status& value, ::std::ostream* os) {
break;
case Cdm::kQuotaExceeded: *os << "Cdm::kQuotaExceeded";
break;
case Cdm::kRangeError: *os << "Cdm::kRangeError";
break;
case Cdm::kUnexpectedError: *os << "Cdm::kUnexpectedError";
break;
default: *os << "Unknown Cdm::Status value " << value;
@@ -53,7 +55,7 @@ void PrintTo(const Cdm::KeyStatus& value, ::std::ostream* os) {
break;
case Cdm::kExpired: *os << "Cdm::kExpired";
break;
case Cdm::kOutputNotAllowed: *os << "Cdm::kOutputNotAllowed";
case Cdm::kOutputRestricted: *os << "Cdm::kOutputRestricted";
break;
case Cdm::kStatusPending: *os << "Cdm::kStatusPending";
break;