Integrate OnExpirationUpdate and OnSessionKeysChange with Android

Also removes OnSessionExpiration which is no longer needed with
OnSessionKeysChange.

Bug: 19771612
Bug: 19771431

Merged from Widevine CDM repo:
https://widevine-internal-review.googlesource.com/#/c/13951/

Change-Id: I0603e808e8d50ff7bb1fb1d5e44fabd8d268ee8a
This commit is contained in:
Kongqun Yang
2015-04-01 15:02:38 -07:00
parent 4621028434
commit f7c449e93a
8 changed files with 142 additions and 102 deletions

View File

@@ -60,11 +60,10 @@ using video_widevine_server::sdk::OFFLINE;
// gmock methods
using ::testing::_;
using ::testing::AllOf;
using ::testing::AtLeast;
using ::testing::Field;
using ::testing::InSequence;
using ::testing::MockFunction;
using ::testing::Pair;
using ::testing::Return;
using ::testing::StrictMock;
using ::testing::UnorderedElementsAre;
@@ -72,11 +71,9 @@ using ::testing::UnorderedElementsAre;
class MockCdmEventListener : public WvCdmEventListener {
public:
MOCK_METHOD1(OnSessionRenewalNeeded, void(const CdmSessionId& session_id));
MOCK_METHOD1(OnSessionExpiration, void(const CdmSessionId& session_id));
MOCK_METHOD3(OnSessionKeysChange,
void(const CdmSessionId& session_id,
const std::vector<CdmKeyInformation>& cdm_keys_info,
bool has_new_usable_key));
MOCK_METHOD3(OnSessionKeysChange, void(const CdmSessionId& session_id,
const CdmKeyStatusMap& keys_status,
bool has_new_usable_key));
MOCK_METHOD2(OnExpirationUpdate,
void(const CdmSessionId& session_id, int64_t new_expiry_time));
};
@@ -149,11 +146,8 @@ class PolicyEngineTest : public ::testing::Test {
bool expected_has_new_usable_key) {
EXPECT_CALL(mock_event_listener_,
OnSessionKeysChange(
kSessionId,
UnorderedElementsAre(
AllOf(Field(&CdmKeyInformation::key_id, kKeyId),
Field(&CdmKeyInformation::key_status,
expected_key_status))),
kSessionId, UnorderedElementsAre(
Pair(kKeyId, expected_key_status)),
expected_has_new_usable_key));
}
@@ -162,14 +156,9 @@ class PolicyEngineTest : public ::testing::Test {
bool expected_has_new_usable_key) {
EXPECT_CALL(mock_event_listener_,
OnSessionKeysChange(
kSessionId,
UnorderedElementsAre(
AllOf(Field(&CdmKeyInformation::key_id, kKeyId),
Field(&CdmKeyInformation::key_status,
expected_key1_status)),
AllOf(Field(&CdmKeyInformation::key_id, kAnotherKeyId),
Field(&CdmKeyInformation::key_status,
expected_key2_status))),
kSessionId, UnorderedElementsAre(
Pair(kKeyId, expected_key1_status),
Pair(kAnotherKeyId, expected_key2_status)),
expected_has_new_usable_key));
}
@@ -242,7 +231,6 @@ TEST_F(PolicyEngineTest, PlaybackFails_RentalDurationExpired) {
OnExpirationUpdate(_, kLicenseStartTime + kLowDuration));
EXPECT_CALL(check_, Call(1));
ExpectSessionKeysChange(kKeyStatusExpired, false);
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(kSessionId));
EXPECT_CALL(check_, Call(2));
policy_engine_->SetLicense(license_);
@@ -278,7 +266,6 @@ TEST_F(PolicyEngineTest, PlaybackFails_PlaybackDurationExpired) {
OnExpirationUpdate(_, playback_start_time + kPlaybackDuration));
EXPECT_CALL(check_, Call(1));
ExpectSessionKeysChange(kKeyStatusExpired, false);
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
EXPECT_CALL(check_, Call(2));
policy_engine_->SetLicense(license_);
@@ -311,7 +298,6 @@ TEST_F(PolicyEngineTest, PlaybackFails_LicenseDurationExpired) {
OnExpirationUpdate(_, kLicenseStartTime + kLowDuration));
EXPECT_CALL(check_, Call(1));
ExpectSessionKeysChange(kKeyStatusExpired, false);
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
EXPECT_CALL(check_, Call(2));
policy_engine_->SetLicense(license_);
@@ -344,7 +330,6 @@ TEST_F(PolicyEngineTest, PlaybackFails_ExpiryBeforeRenewalDelay) {
OnExpirationUpdate(_, kLicenseStartTime + kLowDuration));
EXPECT_CALL(check_, Call(1));
ExpectSessionKeysChange(kKeyStatusExpired, false);
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
EXPECT_CALL(check_, Call(2));
policy_engine_->SetLicense(license_);
@@ -384,7 +369,6 @@ TEST_F(PolicyEngineTest, PlaybackOk_RentalDuration0) {
EXPECT_CALL(mock_event_listener_, OnSessionRenewalNeeded(_));
EXPECT_CALL(check_, Call(3));
ExpectSessionKeysChange(kKeyStatusExpired, false);
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
EXPECT_CALL(check_, Call(4));
policy_engine_->SetLicense(license_);
@@ -425,7 +409,6 @@ TEST_F(PolicyEngineTest, PlaybackOk_PlaybackDuration0) {
EXPECT_CALL(mock_event_listener_, OnSessionRenewalNeeded(_));
EXPECT_CALL(check_, Call(3));
ExpectSessionKeysChange(kKeyStatusExpired, false);
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
EXPECT_CALL(check_, Call(4));
policy_engine_->SetLicense(license_);
@@ -460,7 +443,6 @@ TEST_F(PolicyEngineTest, PlaybackOk_LicenseDuration0) {
OnExpirationUpdate(_, kLicenseStartTime + kLowDuration));
EXPECT_CALL(check_, Call(1));
ExpectSessionKeysChange(kKeyStatusExpired, false);
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
EXPECT_CALL(check_, Call(2));
policy_engine_->SetLicense(license_);
@@ -548,7 +530,6 @@ TEST_F(PolicyEngineTest, PlaybackFailed_CanRenewFalse) {
EXPECT_CALL(check_, Call(1));
EXPECT_CALL(check_, Call(2));
ExpectSessionKeysChange(kKeyStatusExpired, false);
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
EXPECT_CALL(check_, Call(3));
policy_engine_->SetLicense(license_);
@@ -689,7 +670,6 @@ TEST_F(PolicyEngineTest, PlaybackFailed_RenewFailedVersionNotUpdated) {
EXPECT_CALL(mock_event_listener_, OnSessionRenewalNeeded(_));
EXPECT_CALL(check_, Call(3));
ExpectSessionKeysChange(kKeyStatusExpired, false);
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
EXPECT_CALL(check_, Call(4));
policy_engine_->SetLicense(license_);
@@ -750,7 +730,6 @@ TEST_F(PolicyEngineTest, PlaybackFailed_RepeatedRenewFailures) {
EXPECT_CALL(check_, Call(6));
EXPECT_CALL(check_, Call(7));
ExpectSessionKeysChange(kKeyStatusExpired, false);
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
EXPECT_CALL(check_, Call(8));
policy_engine_->SetLicense(license_);
@@ -802,7 +781,6 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterExpiry) {
EXPECT_CALL(check_, Call(6));
EXPECT_CALL(check_, Call(7));
ExpectSessionKeysChange(kKeyStatusExpired, false);
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
EXPECT_CALL(check_, Call(8));
ExpectSessionKeysChange(kKeyStatusUsable, true);
EXPECT_CALL(