From 12821d59688a5ea81ad643fa257d9e0a4a7c2db0 Mon Sep 17 00:00:00 2001 From: "John \"Juce\" Bruce" Date: Thu, 30 Oct 2014 23:38:48 -0700 Subject: [PATCH] Add Max-Res Decode Engine to CDM Core (This is a port of http://go/wvgerrit/11555 from the Widevine CDM repo.) Bug: 16034599 Change-Id: Ie69afac7d89e27623adbc84d2baebccf1d1ba6e6 --- .../build_and_run_all_unit_tests.sh | 1 + libwvdrmengine/cdm/Android.mk | 1 + .../cdm/core/include/max_res_engine.h | 102 ++++++ .../cdm/core/include/policy_engine.h | 9 +- libwvdrmengine/cdm/core/src/cdm_session.cpp | 6 +- .../cdm/core/src/max_res_engine.cpp | 182 ++++++++++ libwvdrmengine/cdm/core/src/policy_engine.cpp | 13 +- .../cdm/core/test/cdm_session_unittest.cpp | 4 +- .../cdm/core/test/license_unittest.cpp | 3 + .../cdm/core/test/max_res_engine_unittest.cpp | 327 ++++++++++++++++++ libwvdrmengine/cdm/core/test/mock_clock.h | 18 + .../cdm/core/test/policy_engine_unittest.cpp | 176 +++++----- libwvdrmengine/cdm/test/Android.mk | 4 + libwvdrmengine/run_all_unit_tests.sh | 1 + 14 files changed, 748 insertions(+), 99 deletions(-) create mode 100644 libwvdrmengine/cdm/core/include/max_res_engine.h create mode 100644 libwvdrmengine/cdm/core/src/max_res_engine.cpp create mode 100644 libwvdrmengine/cdm/core/test/max_res_engine_unittest.cpp create mode 100644 libwvdrmengine/cdm/core/test/mock_clock.h diff --git a/libwvdrmengine/build_and_run_all_unit_tests.sh b/libwvdrmengine/build_and_run_all_unit_tests.sh index 032c9c89..dd463e77 100755 --- a/libwvdrmengine/build_and_run_all_unit_tests.sh +++ b/libwvdrmengine/build_and_run_all_unit_tests.sh @@ -50,6 +50,7 @@ adb root && adb wait-for-device remount adb push $OUT/system/bin/oemcrypto_test /system/bin adb push $OUT/system/bin/request_license_test /system/bin adb push $OUT/system/bin/cdm_extended_duration_test /system/bin +adb push $OUT/system/bin/max_res_engine_unittest /system/bin adb push $OUT/system/bin/policy_engine_unittest /system/bin adb push $OUT/system/bin/libwvdrmmediacrypto_test /system/bin adb push $OUT/system/bin/libwvdrmdrmplugin_test /system/bin diff --git a/libwvdrmengine/cdm/Android.mk b/libwvdrmengine/cdm/Android.mk index 142d576d..9173c67c 100644 --- a/libwvdrmengine/cdm/Android.mk +++ b/libwvdrmengine/cdm/Android.mk @@ -30,6 +30,7 @@ LOCAL_SRC_FILES := \ $(CORE_SRC_DIR)/device_files.cpp \ $(CORE_SRC_DIR)/initialization_data.cpp \ $(CORE_SRC_DIR)/license.cpp \ + $(CORE_SRC_DIR)/max_res_engine.cpp \ $(CORE_SRC_DIR)/oemcrypto_adapter_dynamic.cpp \ $(CORE_SRC_DIR)/policy_engine.cpp \ $(CORE_SRC_DIR)/privacy_crypto.cpp \ diff --git a/libwvdrmengine/cdm/core/include/max_res_engine.h b/libwvdrmengine/cdm/core/include/max_res_engine.h new file mode 100644 index 00000000..e3cb7a3f --- /dev/null +++ b/libwvdrmengine/cdm/core/include/max_res_engine.h @@ -0,0 +1,102 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +#ifndef WVCDM_CORE_MAX_RES_ENGINE_H_ +#define WVCDM_CORE_MAX_RES_ENGINE_H_ + +#include + +#include "crypto_session.h" +#include "license_protocol.pb.h" +#include "lock.h" +#include "scoped_ptr.h" +#include "wv_cdm_types.h" + +namespace wvcdm { + +class Clock; +class MaxResEngineTest; + +// Similar to the Policy Engine, this acts as an oracle that basically says +// "Yes(true) you may still decrypt or no(false) you may not decrypt this data +// anymore." +class MaxResEngine { + public: + explicit MaxResEngine(CryptoSession* crypto_session); + virtual ~MaxResEngine(); + + // The value returned is computed during the last call to SetLicense/ + // SetResolution/OnTimerEvent and may be out of sync depending on the amount + // of time elapsed. The current decryption status is not calculated when this + // function is called to avoid overhead in the decryption path. + virtual bool CanDecrypt(const KeyId& key_id); + + // SetLicense is used in handling the initial license response. It stores + // an exact copy of the key constraints from the license. + virtual void SetLicense(const video_widevine_server::sdk::License& license); + + // SetResolution is called when the current output resolution is updated by + // the decoder. The max-res engine will recalculate the current resolution + // constraints, (if any) which may affect the results for CanDecrypt(). + virtual void SetResolution(uint32_t width, uint32_t height); + + // OnTimerEvent is called when a timer fires. The max-res engine may check the + // current HDCP level using the crypto session, which may affect the results + // for CanDecrypt(). + virtual void OnTimerEvent(); + + private: + typedef ::video_widevine_server::sdk::License::KeyContainer KeyContainer; + typedef ::video_widevine_server::sdk::License::KeyContainer::OutputProtection + OutputProtection; + typedef ::video_widevine_server::sdk::License::KeyContainer:: + VideoResolutionConstraint VideoResolutionConstraint; + typedef ::google::protobuf::RepeatedPtrField + ConstraintList; + + class KeyStatus { + public: + explicit KeyStatus(const ConstraintList& constraints); + KeyStatus(const ConstraintList& constraints, + const OutputProtection::HDCP& default_hdcp_level); + + bool can_decrypt() const { return can_decrypt_; } + + void Update(uint32_t res, + CryptoSession::OemCryptoHdcpVersion current_hdcp_level); + + private: + void Init(const ConstraintList& constraints); + + VideoResolutionConstraint* GetConstraintForRes(uint32_t res); + + static CryptoSession::OemCryptoHdcpVersion ProtobufHdcpToOemCryptoHdcp( + const OutputProtection::HDCP& input); + + bool can_decrypt_; + + scoped_ptr default_hdcp_level_; + ConstraintList constraints_; + }; + + void Init(CryptoSession* crypto_session, Clock* clock); + + void DeleteAllKeys(); + + Lock status_lock_; + std::map keys_; + uint32_t current_resolution_; + int64_t next_check_time_; + + scoped_ptr clock_; + CryptoSession* crypto_session_; + + // For testing + friend class MaxResEngineTest; + MaxResEngine(CryptoSession* crypto_session, Clock* clock); + + CORE_DISALLOW_COPY_AND_ASSIGN(MaxResEngine); +}; + +} // wvcdm + +#endif // WVCDM_CORE_MAX_RES_ENGINE_H_ diff --git a/libwvdrmengine/cdm/core/include/policy_engine.h b/libwvdrmengine/cdm/core/include/policy_engine.h index 088e6577..f9b87278 100644 --- a/libwvdrmengine/cdm/core/include/policy_engine.h +++ b/libwvdrmengine/cdm/core/include/policy_engine.h @@ -6,6 +6,7 @@ #include #include "license_protocol.pb.h" +#include "max_res_engine.h" #include "wv_cdm_types.h" namespace wvcdm { @@ -13,13 +14,14 @@ namespace wvcdm { using video_widevine_server::sdk::LicenseIdentification; class Clock; +class CryptoSession; class PolicyEngineTest; // This acts as an oracle that basically says "Yes(true) you may still decrypt // or no(false) you may not decrypt this data anymore." class PolicyEngine { public: - PolicyEngine(); + explicit PolicyEngine(CryptoSession* crypto_session); virtual ~PolicyEngine(); // The value returned should be taken as a hint rather than an absolute @@ -27,7 +29,7 @@ class PolicyEngine { // UpdateLicense/OnTimerEvent/BeginDecryption and may be out of sync // depending on the amount of time elapsed. The current decryption // status is not calculated to avoid overhead in the decryption path. - virtual bool can_decrypt() { return can_decrypt_; } + virtual bool CanDecrypt(const KeyId& key_id); // OnTimerEvent is called when a timer fires. It notifies the Policy Engine // that the timer has fired and that it should check whether any events have @@ -118,11 +120,12 @@ class PolicyEngine { int64_t next_renewal_time_; int64_t policy_max_duration_seconds_; + MaxResEngine max_res_engine_; Clock* clock_; // For testing friend class PolicyEngineTest; - PolicyEngine(Clock* clock); + PolicyEngine(CryptoSession* crypto_session, Clock* clock); CORE_DISALLOW_COPY_AND_ASSIGN(PolicyEngine); }; diff --git a/libwvdrmengine/cdm/core/src/cdm_session.cpp b/libwvdrmengine/cdm/core/src/cdm_session.cpp index 95c432cf..bc64ab76 100644 --- a/libwvdrmengine/cdm/core/src/cdm_session.cpp +++ b/libwvdrmengine/cdm/core/src/cdm_session.cpp @@ -26,7 +26,8 @@ namespace wvcdm { typedef std::set::iterator CdmEventListenerIter; CdmSession::CdmSession(const CdmClientPropertySet* cdm_client_property_set) { - Create(new CdmLicense(), new CryptoSession(), new PolicyEngine(), + CryptoSession* crypto_session = new CryptoSession(); + Create(new CdmLicense(), crypto_session, new PolicyEngine(crypto_session), new DeviceFiles(), cdm_client_property_set); } @@ -176,7 +177,6 @@ CdmResponseType CdmSession::RestoreOfflineSession( CdmResponseType CdmSession::RestoreUsageSession( const CdmKeyMessage& key_request, const CdmKeyResponse& key_response) { - key_request_ = key_request; key_response_ = key_response; @@ -345,7 +345,7 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) { if (crypto_session_.get() == NULL || !crypto_session_->IsOpen()) return UNKNOWN_ERROR; - if (params.is_encrypted && !policy_engine_->can_decrypt()) { + if (params.is_encrypted && !policy_engine_->CanDecrypt(*params.key_id)) { return policy_engine_->IsLicenseForFuture() ? KEY_ERROR : NEED_KEY; } diff --git a/libwvdrmengine/cdm/core/src/max_res_engine.cpp b/libwvdrmengine/cdm/core/src/max_res_engine.cpp new file mode 100644 index 00000000..5be5a2b4 --- /dev/null +++ b/libwvdrmengine/cdm/core/src/max_res_engine.cpp @@ -0,0 +1,182 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +#include "max_res_engine.h" + +#include "clock.h" +#include "log.h" + +namespace { + +typedef std::map::const_iterator + KeyIterator; + +const int64_t kHdcpCheckInterval = 10; +const uint32_t kNoResolution = 0; + +} // namespace + +namespace wvcdm { + +MaxResEngine::MaxResEngine(CryptoSession* crypto_session) : status_lock_() { + Init(crypto_session, new Clock()); +} + +MaxResEngine::MaxResEngine(CryptoSession* crypto_session, Clock* clock) + : status_lock_() { + Init(crypto_session, clock); +} + +MaxResEngine::~MaxResEngine() { + AutoLock lock(status_lock_); + DeleteAllKeys(); +} + +bool MaxResEngine::CanDecrypt(const KeyId& key_id) { + AutoLock lock(status_lock_); + if (keys_.count(key_id) > 0) { + return keys_[key_id]->can_decrypt(); + } else { + // If a Key ID is unknown to us, we don't know of any constraints for it, + // so never block decryption. + return true; + } +} + +void MaxResEngine::Init(CryptoSession* crypto_session, Clock* clock) { + AutoLock lock(status_lock_); + current_resolution_ = kNoResolution; + clock_.reset(clock); + next_check_time_ = clock_->GetCurrentTime(); + crypto_session_ = crypto_session; +} + +void MaxResEngine::SetLicense( + const video_widevine_server::sdk::License& license) { + AutoLock lock(status_lock_); + DeleteAllKeys(); + for (int32_t key_iter = 0; key_iter < license.key_size(); ++key_iter) { + const KeyContainer& key = license.key(key_iter); + if (key.type() == KeyContainer::CONTENT && key.has_id() && + key.video_resolution_constraints_size() > 0) { + const ConstraintList& constraints = key.video_resolution_constraints(); + const KeyId& key_id = key.id(); + if (key.has_required_protection()) { + keys_[key_id] = + new KeyStatus(constraints, key.required_protection().hdcp()); + } else { + keys_[key_id] = new KeyStatus(constraints); + } + } + } +} + +void MaxResEngine::SetResolution(uint32_t width, uint32_t height) { + AutoLock lock(status_lock_); + current_resolution_ = width * height; +} + +void MaxResEngine::OnTimerEvent() { + AutoLock lock(status_lock_); + int64_t current_time = clock_->GetCurrentTime(); + if (!keys_.empty() && current_resolution_ != kNoResolution && + current_time >= next_check_time_) { + CryptoSession::OemCryptoHdcpVersion current_hdcp_level; + CryptoSession::OemCryptoHdcpVersion ignored; + if (!crypto_session_->GetHdcpCapabilities(¤t_hdcp_level, &ignored)) { + current_hdcp_level = CryptoSession::kOemCryptoHdcpNotSupported; + } + for (KeyIterator i = keys_.begin(); i != keys_.end(); ++i) { + i->second->Update(current_resolution_, current_hdcp_level); + } + next_check_time_ = current_time + kHdcpCheckInterval; + } +} + +void MaxResEngine::DeleteAllKeys() { + // This helper method assumes that status_lock_ is already held. + for (KeyIterator i = keys_.begin(); i != keys_.end(); ++i) delete i->second; + keys_.clear(); +} + +MaxResEngine::KeyStatus::KeyStatus(const ConstraintList& constraints) + : default_hdcp_level_(NULL) { + Init(constraints); +} + +MaxResEngine::KeyStatus::KeyStatus( + const ConstraintList& constraints, + const OutputProtection::HDCP& default_hdcp_level) { + default_hdcp_level_.reset(new CryptoSession::OemCryptoHdcpVersion( + ProtobufHdcpToOemCryptoHdcp(default_hdcp_level))); + Init(constraints); +} + +void MaxResEngine::KeyStatus::Init(const ConstraintList& constraints) { + constraints_.Clear(); + constraints_.MergeFrom(constraints); + can_decrypt_ = true; +} + +void MaxResEngine::KeyStatus::Update( + uint32_t res, CryptoSession::OemCryptoHdcpVersion current_hdcp_level) { + VideoResolutionConstraint* current_constraint = GetConstraintForRes(res); + + if (current_constraint == NULL) { + can_decrypt_ = false; + return; + } + + CryptoSession::OemCryptoHdcpVersion desired_hdcp_level; + if (current_constraint->has_required_protection()) { + desired_hdcp_level = ProtobufHdcpToOemCryptoHdcp( + current_constraint->required_protection().hdcp()); + } else if (default_hdcp_level_.get() != NULL) { + desired_hdcp_level = *default_hdcp_level_; + } else { + // No constraint value and no default means there's nothing to enforce. + can_decrypt_ = true; + return; + } + + can_decrypt_ = (current_hdcp_level >= desired_hdcp_level); +} + +MaxResEngine::VideoResolutionConstraint* +MaxResEngine::KeyStatus::GetConstraintForRes(uint32_t res) { + typedef ConstraintList::pointer_iterator Iterator; + for (Iterator i = constraints_.pointer_begin(); + i != constraints_.pointer_end(); ++i) { + VideoResolutionConstraint* constraint = *i; + if (constraint->has_min_resolution_pixels() && + constraint->has_max_resolution_pixels() && + res >= constraint->min_resolution_pixels() && + res <= constraint->max_resolution_pixels()) { + return constraint; + } + } + return NULL; +} + +CryptoSession::OemCryptoHdcpVersion +MaxResEngine::KeyStatus::ProtobufHdcpToOemCryptoHdcp( + const OutputProtection::HDCP& input) { + switch (input) { + case OutputProtection::HDCP_NONE: + return CryptoSession::kOemCryptoHdcpNotSupported; + case OutputProtection::HDCP_V1: + return CryptoSession::kOemCryptoHdcpVersion1; + case OutputProtection::HDCP_V2: + return CryptoSession::kOemCryptoHdcpVersion2; + case OutputProtection::HDCP_V2_1: + return CryptoSession::kOemCryptoHdcpVersion2_1; + case OutputProtection::HDCP_V2_2: + return CryptoSession::kOemCryptoHdcpVersion2_2; + default: + LOGE( + "MaxResEngine::KeyStatus::ProtobufHdcpToOemCryptoHdcp: " + "Unknown HDCP Level"); + return CryptoSession::kOemCryptoNoHdcpDeviceAttached; + } +} + +} // wvcdm diff --git a/libwvdrmengine/cdm/core/src/policy_engine.cpp b/libwvdrmengine/cdm/core/src/policy_engine.cpp index dc3eca00..006331f0 100644 --- a/libwvdrmengine/cdm/core/src/policy_engine.cpp +++ b/libwvdrmengine/cdm/core/src/policy_engine.cpp @@ -16,11 +16,13 @@ namespace wvcdm { -PolicyEngine::PolicyEngine() { +PolicyEngine::PolicyEngine(CryptoSession* crypto_session) + : max_res_engine_(crypto_session) { Init(new Clock()); } -PolicyEngine::PolicyEngine(Clock* clock) { +PolicyEngine::PolicyEngine(CryptoSession* crypto_session, Clock* clock) + : max_res_engine_(crypto_session) { Init(clock); } @@ -40,6 +42,10 @@ void PolicyEngine::Init(Clock* clock) { clock_ = clock; } +bool PolicyEngine::CanDecrypt(const KeyId& key_id) { + return can_decrypt_ && max_res_engine_.CanDecrypt(key_id); +} + void PolicyEngine::OnTimerEvent(bool* event_occurred, CdmEventType* event) { *event_occurred = false; int64_t current_time = clock_->GetCurrentTime(); @@ -101,6 +107,8 @@ void PolicyEngine::OnTimerEvent(bool* event_occurred, CdmEventType* event) { *event = LICENSE_RENEWAL_NEEDED_EVENT; *event_occurred = true; } + + max_res_engine_.OnTimerEvent(); } void PolicyEngine::SetLicense( @@ -109,6 +117,7 @@ void PolicyEngine::SetLicense( license_id_.CopyFrom(license.id()); policy_.Clear(); UpdateLicense(license); + max_res_engine_.SetLicense(license); } void PolicyEngine::UpdateLicense( diff --git a/libwvdrmengine/cdm/core/test/cdm_session_unittest.cpp b/libwvdrmengine/cdm/core/test/cdm_session_unittest.cpp index 42f2bfa4..5bc8bf89 100644 --- a/libwvdrmengine/cdm/core/test/cdm_session_unittest.cpp +++ b/libwvdrmengine/cdm/core/test/cdm_session_unittest.cpp @@ -111,7 +111,9 @@ class MockCryptoSession : public CryptoSession { class MockPolicyEngine : public PolicyEngine { public: - // Leaving a place holder for when PolicyEngine methods need to be mocked + MockPolicyEngine() : PolicyEngine(NULL) {} + + // Leaving a place-holder for when PolicyEngine methods need to be mocked }; class MockCdmLicense : public CdmLicense { diff --git a/libwvdrmengine/cdm/core/test/license_unittest.cpp b/libwvdrmengine/cdm/core/test/license_unittest.cpp index 55326873..66cbd61b 100644 --- a/libwvdrmengine/cdm/core/test/license_unittest.cpp +++ b/libwvdrmengine/cdm/core/test/license_unittest.cpp @@ -51,6 +51,9 @@ const std::string kWebmMimeType = "video/webm"; namespace wvcdm { class LicenseTest : public ::testing::Test { + public: + LicenseTest() : policy_engine_(NULL) {} + protected: virtual void SetUp() { session_ = new CryptoSession(); diff --git a/libwvdrmengine/cdm/core/test/max_res_engine_unittest.cpp b/libwvdrmengine/cdm/core/test/max_res_engine_unittest.cpp new file mode 100644 index 00000000..119a279b --- /dev/null +++ b/libwvdrmengine/cdm/core/test/max_res_engine_unittest.cpp @@ -0,0 +1,327 @@ +// Copyright 2012 Google Inc. All Rights Reserved. + +#include "crypto_session.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "license.h" +#include "max_res_engine.h" +#include "mock_clock.h" +#include "scoped_ptr.h" +#include "wv_cdm_types.h" + +namespace wvcdm { + +typedef ::video_widevine_server::sdk::License License; +typedef ::video_widevine_server::sdk::License::KeyContainer KeyContainer; +typedef ::video_widevine_server::sdk::License::KeyContainer::OutputProtection + OutputProtection; +typedef ::video_widevine_server::sdk::License::KeyContainer:: + VideoResolutionConstraint VideoResolutionConstraint; +typedef ::google::protobuf::RepeatedPtrField KeyList; +typedef ::google::protobuf::RepeatedPtrField + ConstraintList; + +using namespace testing; + +namespace { + +const KeyId kKeyId1 = "357adc89f1673433c36c621f1b5c41ee"; +const KeyId kKeyId2 = "3d25f819250789ecfc9ed48cc99af164"; +const KeyId kKeyId3 = "fe3cf6b69e76c9a1c877922e1a661707"; +const KeyId kKeyId4 = "29a321b9886658078f916fdd41d6f570"; +const KeyId kKeyId5 = "cc5b031bcde371031c06822d935b9a63"; +const KeyId kKeyId6 = "90ac1332e4efc8acbaf929c8d321f50c"; + +const uint32_t kMinRes1 = 0; +const uint32_t kMaxRes1 = 2000; +const uint32_t kTargetRes1 = (kMinRes1 + kMaxRes1) / 2; +const uint32_t kMinRes2 = kMaxRes1; +const uint32_t kMaxRes2 = 4000; +const uint32_t kTargetRes2 = (kMinRes2 + kMaxRes2) / 2; +const uint32_t kTargetRes3 = kMaxRes2 + 1000; + +const OutputProtection::HDCP kHdcpDefault = OutputProtection::HDCP_V2; +const OutputProtection::HDCP kHdcpConstraint = OutputProtection::HDCP_V2_1; + +const int64_t kHdcpInterval = 10; + +} // namespace + +class HdcpOnlyMockCryptoSession : public CryptoSession { + public: + MOCK_METHOD2(GetHdcpCapabilities, + bool(OemCryptoHdcpVersion*, OemCryptoHdcpVersion*)); +}; + +ACTION_P2(IncrementAndReturnPointee, p, a) { + *p += a; + return *p; +} + +class MaxResEngineTest : public Test { + protected: + virtual void SetUp() { + mock_clock_ = new NiceMock(); + current_time_ = 0; + + ON_CALL(*mock_clock_, GetCurrentTime()) + .WillByDefault( + IncrementAndReturnPointee(¤t_time_, kHdcpInterval)); + + max_res_engine_.reset(new MaxResEngine(&crypto_session_, mock_clock_)); + + KeyList* keys = license_.mutable_key(); + + // Key 1 - Content key w/ ID, no HDCP, no constraints + { + KeyContainer* key1 = keys->Add(); + key1->set_type(KeyContainer::CONTENT); + key1->set_id(kKeyId1); + } + + // Key 2 - Content key w/ ID, HDCP, no constraints + { + KeyContainer* key2 = keys->Add(); + key2->set_type(KeyContainer::CONTENT); + key2->set_id(kKeyId2); + key2->mutable_required_protection()->set_hdcp(kHdcpDefault); + } + + // Key 3 - Content key w/ ID, no HDCP, constraints + { + KeyContainer* key3 = keys->Add(); + key3->set_type(KeyContainer::CONTENT); + key3->set_id(kKeyId3); + AddConstraints(key3->mutable_video_resolution_constraints()); + } + + // Key 4 - Content key w/ ID, HDCP, constraints + { + KeyContainer* key4 = keys->Add(); + key4->set_type(KeyContainer::CONTENT); + key4->set_id(kKeyId4); + key4->mutable_required_protection()->set_hdcp(kHdcpDefault); + AddConstraints(key4->mutable_video_resolution_constraints()); + } + + // Key 5 - Content key w/o ID, HDCP, constraints + { + KeyContainer* key5 = keys->Add(); + key5->set_type(KeyContainer::CONTENT); + key5->mutable_required_protection()->set_hdcp(kHdcpDefault); + AddConstraints(key5->mutable_video_resolution_constraints()); + } + + // Key 6 - Non-content key + { + KeyContainer* key6 = keys->Add(); + key6->set_type(KeyContainer::OPERATOR_SESSION); + } + } + + void AddConstraints(ConstraintList* constraints) { + // Constraint 1 - Low-res and no HDCP + { + VideoResolutionConstraint* constraint1 = constraints->Add(); + constraint1->set_min_resolution_pixels(kMinRes1); + constraint1->set_max_resolution_pixels(kMaxRes1); + } + + // Constraint 2 - High-res and stricter HDCP + { + VideoResolutionConstraint* constraint2 = constraints->Add(); + constraint2->set_min_resolution_pixels(kMinRes2); + constraint2->set_max_resolution_pixels(kMaxRes2); + constraint2->mutable_required_protection()->set_hdcp(kHdcpConstraint); + } + } + + MockClock* mock_clock_; + int64_t current_time_; + StrictMock crypto_session_; + scoped_ptr max_res_engine_; + License license_; +}; + +TEST_F(MaxResEngineTest, IsPermissiveByDefault) { + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId1)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId2)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId3)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId4)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId5)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId6)); + + max_res_engine_->OnTimerEvent(); + + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId1)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId2)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId3)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId4)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId5)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId6)); +} + +TEST_F(MaxResEngineTest, IsPermissiveWithoutALicense) { + max_res_engine_->SetResolution(1, kTargetRes1); + max_res_engine_->OnTimerEvent(); + + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId1)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId2)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId3)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId4)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId5)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId6)); +} + +TEST_F(MaxResEngineTest, IsPermissiveWithoutAResolution) { + max_res_engine_->SetLicense(license_); + max_res_engine_->OnTimerEvent(); + + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId1)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId2)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId3)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId4)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId5)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId6)); +} + +TEST_F(MaxResEngineTest, HandlesResolutionsBasedOnConstraints) { + EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _)) + .WillRepeatedly( + DoAll(SetArgPointee<0>(CryptoSession::kOemCryptoNoHdcpDeviceAttached), + Return(true))); + + max_res_engine_->SetLicense(license_); + + max_res_engine_->SetResolution(1, kTargetRes1); + max_res_engine_->OnTimerEvent(); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId1)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId2)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId3)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId4)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId5)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId6)); + + max_res_engine_->SetResolution(1, kTargetRes2); + max_res_engine_->OnTimerEvent(); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId1)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId2)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId3)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId4)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId5)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId6)); + + max_res_engine_->SetResolution(1, kTargetRes3); + max_res_engine_->OnTimerEvent(); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId1)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId2)); + EXPECT_FALSE(max_res_engine_->CanDecrypt(kKeyId3)); + EXPECT_FALSE(max_res_engine_->CanDecrypt(kKeyId4)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId5)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId6)); +} + +TEST_F(MaxResEngineTest, RequestsHdcpImmediatelyAndOnlyAfterInterval) { + int64_t start_time = current_time_; + + { + InSequence calls; + EXPECT_CALL(*mock_clock_, GetCurrentTime()) + .WillOnce(Return(start_time)); + EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _)) + .WillOnce( + DoAll(SetArgPointee<0>(CryptoSession::kOemCryptoHdcpVersion2_2), + Return(true))); + EXPECT_CALL(*mock_clock_, GetCurrentTime()) + .WillOnce(Return(start_time + kHdcpInterval / 2)) + .WillOnce(Return(start_time + kHdcpInterval)); + EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _)) + .WillOnce( + DoAll(SetArgPointee<0>(CryptoSession::kOemCryptoHdcpVersion2_2), + Return(true))); + } + + max_res_engine_->SetLicense(license_); + max_res_engine_->SetResolution(1, kTargetRes1); + max_res_engine_->OnTimerEvent(); + max_res_engine_->OnTimerEvent(); + max_res_engine_->OnTimerEvent(); +} + +TEST_F(MaxResEngineTest, DoesNotRequestHdcpWithoutALicense) { + EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _)) + .Times(0); + + max_res_engine_->OnTimerEvent(); +} + +TEST_F(MaxResEngineTest, HandlesConstraintOverridingHdcp) { + EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _)) + .WillRepeatedly( + DoAll(SetArgPointee<0>(CryptoSession::kOemCryptoHdcpVersion2), + Return(true))); + + max_res_engine_->SetLicense(license_); + + max_res_engine_->SetResolution(1, kTargetRes1); + max_res_engine_->OnTimerEvent(); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId1)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId2)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId3)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId4)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId5)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId6)); + + max_res_engine_->SetResolution(1, kTargetRes2); + max_res_engine_->OnTimerEvent(); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId1)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId2)); + EXPECT_FALSE(max_res_engine_->CanDecrypt(kKeyId3)); + EXPECT_FALSE(max_res_engine_->CanDecrypt(kKeyId4)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId5)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId6)); +} + +TEST_F(MaxResEngineTest, HandlesNoHdcp) { + EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _)) + .WillRepeatedly( + DoAll(SetArgPointee<0>(CryptoSession::kOemCryptoHdcpNotSupported), + Return(true))); + + max_res_engine_->SetLicense(license_); + + max_res_engine_->SetResolution(1, kTargetRes1); + max_res_engine_->OnTimerEvent(); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId1)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId2)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId3)); + EXPECT_FALSE(max_res_engine_->CanDecrypt(kKeyId4)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId5)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId6)); + + max_res_engine_->SetResolution(1, kTargetRes2); + max_res_engine_->OnTimerEvent(); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId1)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId2)); + EXPECT_FALSE(max_res_engine_->CanDecrypt(kKeyId3)); + EXPECT_FALSE(max_res_engine_->CanDecrypt(kKeyId4)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId5)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId6)); +} + +TEST_F(MaxResEngineTest, IgnoresHdcpWithoutAResolution) { + EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _)) + .Times(0); + + max_res_engine_->SetLicense(license_); + max_res_engine_->OnTimerEvent(); + + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId1)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId2)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId3)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId4)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId5)); + EXPECT_TRUE(max_res_engine_->CanDecrypt(kKeyId6)); +} + +} // wvcdm diff --git a/libwvdrmengine/cdm/core/test/mock_clock.h b/libwvdrmengine/cdm/core/test/mock_clock.h new file mode 100644 index 00000000..6aabbe90 --- /dev/null +++ b/libwvdrmengine/cdm/core/test/mock_clock.h @@ -0,0 +1,18 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +#ifndef CDM_TEST_MOCK_CLOCK_H_ +#define CDM_TEST_MOCK_CLOCK_H_ + +#include "clock.h" +#include "gmock/gmock.h" + +namespace wvcdm { + +class MockClock : public Clock { + public: + MOCK_METHOD0(GetCurrentTime, int64_t()); +}; + +} // wvcdm + +#endif // CDM_TEST_MOCK_CLOCK_H_ \ No newline at end of file diff --git a/libwvdrmengine/cdm/core/test/policy_engine_unittest.cpp b/libwvdrmengine/cdm/core/test/policy_engine_unittest.cpp index a093c8e0..cc332b6d 100644 --- a/libwvdrmengine/cdm/core/test/policy_engine_unittest.cpp +++ b/libwvdrmengine/cdm/core/test/policy_engine_unittest.cpp @@ -5,10 +5,10 @@ #include #include -#include "clock.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "license.h" +#include "mock_clock.h" #include "policy_engine.h" #include "wv_cdm_constants.h" @@ -32,6 +32,7 @@ const int64_t kHighDuration = kOfflineLicenseDuration); const char* kRenewalServerUrl = "https://test.google.com/license/GetCencLicense"; +const wvcdm::KeyId kKeyId = "357adc89f1673433c36c621f1b5c41ee"; int64_t GetLicenseRenewalDelay(int64_t license_duration) { return license_duration > kLicenseRenewalPeriod @@ -53,16 +54,11 @@ using video_widevine_server::sdk::OFFLINE; using ::testing::Return; using ::testing::AtLeast; -class MockClock : public Clock { - public: - MOCK_METHOD0(GetCurrentTime, int64_t()); -}; - class PolicyEngineTest : public ::testing::Test { protected: virtual void SetUp() { mock_clock_ = new MockClock(); - policy_engine_ = new PolicyEngine(mock_clock_); + policy_engine_ = new PolicyEngine(NULL, mock_clock_); license_.set_license_start_time(kLicenseStartTime); @@ -113,7 +109,7 @@ class PolicyEngineTest : public ::testing::Test { }; TEST_F(PolicyEngineTest, NoLicense) { - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackSuccess) { @@ -130,7 +126,7 @@ TEST_F(PolicyEngineTest, PlaybackSuccess) { EXPECT_FALSE(event_occurred); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackFailed_CanPlayFalse) { @@ -141,7 +137,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_CanPlayFalse) { .WillOnce(Return(kLicenseStartTime + 1)); policy_engine_->SetLicense(license_); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -149,7 +145,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_CanPlayFalse) { EXPECT_FALSE(event_occurred); policy_engine_->BeginDecryption(); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackFails_RentalDurationExpired) { @@ -168,7 +164,7 @@ TEST_F(PolicyEngineTest, PlaybackFails_RentalDurationExpired) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -179,7 +175,7 @@ TEST_F(PolicyEngineTest, PlaybackFails_RentalDurationExpired) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackFails_PlaybackDurationExpired) { @@ -197,7 +193,7 @@ TEST_F(PolicyEngineTest, PlaybackFails_PlaybackDurationExpired) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -208,7 +204,7 @@ TEST_F(PolicyEngineTest, PlaybackFails_PlaybackDurationExpired) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackFails_LicenseDurationExpired) { @@ -225,7 +221,7 @@ TEST_F(PolicyEngineTest, PlaybackFails_LicenseDurationExpired) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -236,7 +232,7 @@ TEST_F(PolicyEngineTest, PlaybackFails_LicenseDurationExpired) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackFails_ExpiryBeforeRenewalDelay) { @@ -253,7 +249,7 @@ TEST_F(PolicyEngineTest, PlaybackFails_ExpiryBeforeRenewalDelay) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -264,7 +260,7 @@ TEST_F(PolicyEngineTest, PlaybackFails_ExpiryBeforeRenewalDelay) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackOk_RentalDuration0) { @@ -284,7 +280,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RentalDuration0) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -303,7 +299,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RentalDuration0) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackOk_PlaybackDuration0) { @@ -324,7 +320,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_PlaybackDuration0) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -343,7 +339,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_PlaybackDuration0) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackOk_LicenseDuration0) { @@ -362,7 +358,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_LicenseDuration0) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -373,7 +369,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_LicenseDuration0) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackOk_Durations0) { @@ -392,7 +388,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_Durations0) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -402,7 +398,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_Durations0) { policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackOk_LicenseWithFutureStartTime) { @@ -418,14 +414,14 @@ TEST_F(PolicyEngineTest, PlaybackOk_LicenseWithFutureStartTime) { CdmEventType event; policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackFailed_CanRenewFalse) { @@ -444,7 +440,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_CanRenewFalse) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -458,7 +454,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_CanRenewFalse) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccess) { @@ -477,7 +473,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccess) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -488,7 +484,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccess) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); license_.set_license_start_time(kLicenseStartTime + license_renewal_delay + 15); @@ -499,7 +495,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccess) { policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccess_WithFutureStartTime) { @@ -518,7 +514,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccess_WithFutureStartTime) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -528,7 +524,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccess_WithFutureStartTime) { policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); license_.set_license_start_time(kLicenseStartTime + license_renewal_delay + 50); @@ -538,11 +534,11 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccess_WithFutureStartTime) { policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackFailed_RenewFailedVersionNotUpdated) { @@ -560,7 +556,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_RenewFailedVersionNotUpdated) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -571,7 +567,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_RenewFailedVersionNotUpdated) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); license_.set_license_start_time(kLicenseStartTime + license_renewal_delay + 15); @@ -581,13 +577,13 @@ TEST_F(PolicyEngineTest, PlaybackFailed_RenewFailedVersionNotUpdated) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackFailed_RepeatedRenewFailures) { @@ -609,7 +605,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_RepeatedRenewFailures) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -620,7 +616,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_RepeatedRenewFailures) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); @@ -629,7 +625,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_RepeatedRenewFailures) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); @@ -638,7 +634,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_RepeatedRenewFailures) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); @@ -647,7 +643,7 @@ TEST_F(PolicyEngineTest, PlaybackFailed_RepeatedRenewFailures) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterExpiry) { @@ -671,7 +667,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterExpiry) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -682,7 +678,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterExpiry) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); @@ -691,7 +687,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterExpiry) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); @@ -700,7 +696,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterExpiry) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); @@ -709,7 +705,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterExpiry) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); license_.set_license_start_time(kLicenseStartTime + kStreamingLicenseDuration + 20); @@ -725,7 +721,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterExpiry) { policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterFailures) { @@ -747,7 +743,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterFailures) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -758,7 +754,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterFailures) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); @@ -767,7 +763,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterFailures) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); @@ -781,12 +777,12 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterFailures) { policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, PlaybackOk_RenewedWithUsage) { @@ -807,10 +803,10 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewedWithUsage) { CdmEventType event; policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_TRUE(event_occurred); @@ -825,7 +821,7 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewedWithUsage) { policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); } TEST_F(PolicyEngineTest, QueryFailed_LicenseNotReceived) { @@ -934,7 +930,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_PlaybackBegun) { EXPECT_EQ(kRenewalServerUrl, query_info[QUERY_KEY_RENEWAL_SERVER_URL]); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -983,7 +979,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_Offline) { EXPECT_FALSE(event_occurred); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); CdmQueryMap query_info; EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); @@ -1020,7 +1016,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_CanPlayFalse) { .WillOnce(Return(kLicenseStartTime + 100)); policy_engine_->SetLicense(license_); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -1028,7 +1024,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_CanPlayFalse) { EXPECT_FALSE(event_occurred); policy_engine_->BeginDecryption(); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); CdmQueryMap query_info; EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); @@ -1066,7 +1062,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_RentalDurationExpired) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -1077,7 +1073,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_RentalDurationExpired) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); CdmQueryMap query_info; EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); @@ -1116,7 +1112,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_PlaybackDurationExpired) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -1127,7 +1123,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_PlaybackDurationExpired) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); CdmQueryMap query_info; EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); @@ -1163,7 +1159,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_LicenseDurationExpired) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -1174,7 +1170,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_LicenseDurationExpired) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); CdmQueryMap query_info; EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); @@ -1213,7 +1209,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_RentalDuration0) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -1232,7 +1228,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_RentalDuration0) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); CdmQueryMap query_info; EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); @@ -1273,7 +1269,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_PlaybackDuration0) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -1310,7 +1306,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_PlaybackDuration0) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); EXPECT_EQ(QUERY_VALUE_STREAMING, query_info[QUERY_KEY_LICENSE_TYPE]); @@ -1346,7 +1342,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_LicenseDuration0) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -1357,7 +1353,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_LicenseDuration0) { EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_EXPIRED_EVENT, event); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); CdmQueryMap query_info; EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); @@ -1395,7 +1391,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_Durations0) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -1405,7 +1401,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_Durations0) { policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); CdmQueryMap query_info; EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); @@ -1441,7 +1437,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_LicenseWithFutureStartTime) { CdmEventType event; policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); CdmQueryMap query_info; EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); @@ -1461,11 +1457,11 @@ TEST_F(PolicyEngineTest, QuerySuccess_LicenseWithFutureStartTime) { EXPECT_EQ(kPlaybackDuration, remaining_time); EXPECT_EQ(kRenewalServerUrl, query_info[QUERY_KEY_RENEWAL_SERVER_URL]); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); policy_engine_->BeginDecryption(); EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); @@ -1503,7 +1499,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_Renew) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -1513,7 +1509,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_Renew) { policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); license_.set_license_start_time(kLicenseStartTime + license_renewal_delay + 15); @@ -1523,7 +1519,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_Renew) { policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); CdmQueryMap query_info; EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); @@ -1569,7 +1565,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_RenewWithFutureStartTime) { policy_engine_->SetLicense(license_); policy_engine_->BeginDecryption(); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); bool event_occurred; CdmEventType event; @@ -1579,7 +1575,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_RenewWithFutureStartTime) { policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_TRUE(event_occurred); EXPECT_EQ(LICENSE_RENEWAL_NEEDED_EVENT, event); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); license_.set_license_start_time(kLicenseStartTime + license_renewal_delay + kLicenseRenewalRetryInterval + 20); @@ -1589,7 +1585,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_RenewWithFutureStartTime) { policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_FALSE(policy_engine_->can_decrypt()); + EXPECT_FALSE(policy_engine_->CanDecrypt(kKeyId)); CdmQueryMap query_info; EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); @@ -1613,7 +1609,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_RenewWithFutureStartTime) { policy_engine_->OnTimerEvent(&event_occurred, &event); EXPECT_FALSE(event_occurred); - EXPECT_TRUE(policy_engine_->can_decrypt()); + EXPECT_TRUE(policy_engine_->CanDecrypt(kKeyId)); EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info)); EXPECT_EQ(QUERY_VALUE_STREAMING, query_info[QUERY_KEY_LICENSE_TYPE]); diff --git a/libwvdrmengine/cdm/test/Android.mk b/libwvdrmengine/cdm/test/Android.mk index 9e66bac2..68bc4730 100644 --- a/libwvdrmengine/cdm/test/Android.mk +++ b/libwvdrmengine/cdm/test/Android.mk @@ -35,6 +35,10 @@ test_name := license_unittest test_src_dir := ../core/test include $(LOCAL_PATH)/unit-test.mk +test_name := max_res_engine_unittest +test_src_dir := ../core/test +include $(LOCAL_PATH)/unit-test.mk + test_name := policy_engine_unittest test_src_dir := ../core/test include $(LOCAL_PATH)/unit-test.mk diff --git a/libwvdrmengine/run_all_unit_tests.sh b/libwvdrmengine/run_all_unit_tests.sh index 4644070e..cb8cd9e9 100755 --- a/libwvdrmengine/run_all_unit_tests.sh +++ b/libwvdrmengine/run_all_unit_tests.sh @@ -10,6 +10,7 @@ adb root && adb wait-for-device remount adb shell /system/bin/oemcrypto_test adb shell /system/bin/request_license_test +adb shell /system/bin/max_res_engine_unittest adb shell /system/bin/policy_engine_unittest adb shell /system/bin/libwvdrmmediacrypto_test adb shell /system/bin/libwvdrmdrmplugin_test