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
This commit is contained in:
John "Juce" Bruce
2014-10-30 23:38:48 -07:00
parent b3650a9661
commit 12821d5968
14 changed files with 748 additions and 99 deletions

View File

@@ -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 {

View File

@@ -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();

View File

@@ -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<KeyContainer> KeyList;
typedef ::google::protobuf::RepeatedPtrField<VideoResolutionConstraint>
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<MockClock>();
current_time_ = 0;
ON_CALL(*mock_clock_, GetCurrentTime())
.WillByDefault(
IncrementAndReturnPointee(&current_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<HdcpOnlyMockCryptoSession> crypto_session_;
scoped_ptr<MaxResEngine> 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

View File

@@ -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_

View File

@@ -5,10 +5,10 @@
#include <algorithm>
#include <sstream>
#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]);