Updated integration test to handle unlimited license durations.

[ Merge of http://go/wvgerrit/128046 ]

Test case WvCdmStreamingUsageReportTest.WvCdmStreamingUsageReportTest
was failing comparing "license duration" values returned when querying
for key information for licenses with unlimited "rental duration".

This is due to the new license duration model used for V16 licenses.

From the Widevine MediaDrm doc for "LicenseDurationRemaining":

  For OEMCrypto v16+ (Android 11 and later), license duration is no
  longer being enforced. If rental duration is set to never expire,
  ”9223372036854775807” (LLONG_MAX) will be returned.

Similarly, the test has been updated for "playback duration" queries
of the same case.

Bug: 163542905
Test: cdm_extended_duration_test

Change-Id: I57e0e435631a151fac45c963d865de256a773644
This commit is contained in:
Alex Dale
2021-06-25 13:18:19 -07:00
parent 61218ec6cf
commit a9e26bdc2b

View File

@@ -4,6 +4,8 @@
#include <errno.h> #include <errno.h>
#include <getopt.h> #include <getopt.h>
#include <limits.h>
#include <sstream> #include <sstream>
#include <gmock/gmock.h> #include <gmock/gmock.h>
@@ -43,6 +45,8 @@ const uint32_t kClockTolerance = 10;
const uint32_t kMaxUsageTableSize = 50; const uint32_t kMaxUsageTableSize = 50;
const std::string kEmptyServiceCertificate; const std::string kEmptyServiceCertificate;
constexpr int64_t kUnlimitedDurationValue = LLONG_MAX;
// TODO(rfrias): refactor to print out the decryption test names // TODO(rfrias): refactor to print out the decryption test names
struct SubSampleInfo { struct SubSampleInfo {
bool retrieve_key; bool retrieve_key;
@@ -1438,10 +1442,29 @@ TEST_P(WvCdmStreamingUsageReportTest, UsageTest) {
QueryKeyStatus(true, false, &license_duration_remaining, QueryKeyStatus(true, false, &license_duration_remaining,
&playback_duration_remaining); &playback_duration_remaining);
EXPECT_NEAR(initial_license_duration_remaining - license_duration_remaining, // For unlimited "rental durations", the "license duration" will
expected_seconds_since_license_received, kClockTolerance); // effectively be unlimited. Remaining license duration in this
EXPECT_NEAR(initial_playback_duration_remaining - playback_duration_remaining, // case is represented by |kUnlimitedDurationValue| and will not
expected_seconds_since_initial_playback, kClockTolerance); // change over time.
if (initial_license_duration_remaining == kUnlimitedDurationValue) {
EXPECT_EQ(license_duration_remaining, kUnlimitedDurationValue);
} else {
EXPECT_NEAR(initial_license_duration_remaining - license_duration_remaining,
expected_seconds_since_license_received, kClockTolerance)
<< "initial_license_duration_remaining = "
<< initial_license_duration_remaining
<< ", license_duration_remaining = " << license_duration_remaining;
}
if (initial_playback_duration_remaining == kUnlimitedDurationValue) {
EXPECT_EQ(playback_duration_remaining, kUnlimitedDurationValue);
} else {
EXPECT_NEAR(initial_playback_duration_remaining - playback_duration_remaining,
expected_seconds_since_initial_playback, kClockTolerance)
<< "initial_playback_duration_remaining = "
<< initial_playback_duration_remaining
<< ", playback_duration_remaining = " << playback_duration_remaining;
}
decryptor_->CloseSession(session_id_); decryptor_->CloseSession(session_id_);