Add License::Policy::soft_enforce_playback_duration
[ Merge of http://go/wvgerrit/22564 ] b/34211676 Test: All unittests other than some oemcrypto, request_license_test passed. Those tests failed with or without this CL. Change-Id: I20474339aa1777da2db3677c10f186726505ecc8
This commit is contained in:
@@ -1040,6 +1040,89 @@ TEST_F(PolicyEngineTest, MultipleKeysInLicense) {
|
||||
EXPECT_FALSE(policy_engine_->CanDecryptContent(kSomeRandomKeyId));
|
||||
}
|
||||
|
||||
TEST_F(PolicyEngineTest, PlaybackOk_SoftEnforcePlaybackDuration) {
|
||||
License_Policy* policy = license_.mutable_policy();
|
||||
policy->set_soft_enforce_playback_duration(true);
|
||||
|
||||
EXPECT_CALL(*mock_clock_, GetCurrentTime())
|
||||
.WillOnce(Return(kLicenseStartTime + 1))
|
||||
.WillOnce(Return(kPlaybackStartTime))
|
||||
.WillOnce(Return(kPlaybackStartTime + kPlaybackDuration - 5))
|
||||
.WillOnce(Return(kPlaybackStartTime + kPlaybackDuration + 5))
|
||||
.WillOnce(Return(kLicenseStartTime + kLicenseDuration - 5))
|
||||
.WillOnce(Return(kLicenseStartTime + kLicenseDuration + 5));
|
||||
|
||||
InSequence seq;
|
||||
ExpectSessionKeysChange(kKeyStatusUsable, true);
|
||||
EXPECT_CALL(mock_event_listener_,
|
||||
OnExpirationUpdate(_, kLicenseStartTime + kRentalDuration));
|
||||
EXPECT_CALL(mock_event_listener_,
|
||||
OnExpirationUpdate(_, kLicenseStartTime + kLicenseDuration));
|
||||
EXPECT_CALL(check_, Call(1));
|
||||
EXPECT_CALL(check_, Call(2));
|
||||
EXPECT_CALL(check_, Call(3));
|
||||
ExpectSessionKeysChange(kKeyStatusExpired, false);
|
||||
EXPECT_CALL(check_, Call(4));
|
||||
|
||||
policy_engine_->SetLicense(license_);
|
||||
policy_engine_->BeginDecryption();
|
||||
|
||||
for (int i = 1; i <= 4; ++i) {
|
||||
EXPECT_TRUE(policy_engine_->CanDecryptContent(kKeyId));
|
||||
policy_engine_->OnTimerEvent();
|
||||
check_.Call(i);
|
||||
}
|
||||
|
||||
EXPECT_FALSE(policy_engine_->CanDecryptContent(kKeyId));
|
||||
}
|
||||
|
||||
TEST_F(PolicyEngineTest, LicenseExpired_SoftEnforceLoadBeforeExpire) {
|
||||
License_Policy* policy = license_.mutable_policy();
|
||||
policy->set_soft_enforce_playback_duration(true);
|
||||
|
||||
EXPECT_CALL(*mock_clock_, GetCurrentTime())
|
||||
.WillOnce(Return(kLicenseStartTime + 1))
|
||||
.WillOnce(Return(kPlaybackStartTime + kPlaybackDuration - 5))
|
||||
.WillOnce(Return(kPlaybackStartTime + kPlaybackDuration + 10));
|
||||
|
||||
InSequence seq;
|
||||
ExpectSessionKeysChange(kKeyStatusUsable, true);
|
||||
EXPECT_CALL(mock_event_listener_,
|
||||
OnExpirationUpdate(_, kLicenseStartTime + kRentalDuration));
|
||||
EXPECT_CALL(mock_event_listener_,
|
||||
OnExpirationUpdate(_, kLicenseStartTime + kLicenseDuration));
|
||||
|
||||
policy_engine_->SetLicense(license_);
|
||||
policy_engine_->RestorePlaybackTimes(kPlaybackStartTime, kPlaybackStartTime);
|
||||
policy_engine_->OnTimerEvent();
|
||||
|
||||
EXPECT_TRUE(policy_engine_->CanDecryptContent(kKeyId));
|
||||
}
|
||||
|
||||
TEST_F(PolicyEngineTest, LicenseExpired_SoftEnforceLoadAfterExpire) {
|
||||
License_Policy* policy = license_.mutable_policy();
|
||||
policy->set_soft_enforce_playback_duration(true);
|
||||
|
||||
EXPECT_CALL(*mock_clock_, GetCurrentTime())
|
||||
.WillOnce(Return(kLicenseStartTime + 1))
|
||||
.WillOnce(Return(kPlaybackStartTime + kPlaybackDuration + 5))
|
||||
.WillOnce(Return(kPlaybackStartTime + kPlaybackDuration + 10));
|
||||
|
||||
InSequence seq;
|
||||
ExpectSessionKeysChange(kKeyStatusUsable, true);
|
||||
EXPECT_CALL(mock_event_listener_,
|
||||
OnExpirationUpdate(_, kLicenseStartTime + kRentalDuration));
|
||||
EXPECT_CALL(mock_event_listener_,
|
||||
OnExpirationUpdate(_, kPlaybackStartTime + kPlaybackDuration));
|
||||
ExpectSessionKeysChange(kKeyStatusExpired, false);
|
||||
|
||||
policy_engine_->SetLicense(license_);
|
||||
policy_engine_->RestorePlaybackTimes(kPlaybackStartTime, kPlaybackStartTime);
|
||||
policy_engine_->OnTimerEvent();
|
||||
|
||||
EXPECT_FALSE(policy_engine_->CanDecryptContent(kKeyId));
|
||||
}
|
||||
|
||||
class PolicyEngineKeyAllowedUsageTest : public PolicyEngineTest {
|
||||
protected:
|
||||
enum KeyFlag {
|
||||
|
||||
Reference in New Issue
Block a user