Source release 15.0.0
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
#include "metrics.pb.h"
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "properties.h"
|
||||
#include "scoped_ptr.h"
|
||||
#include "string_conversions.h"
|
||||
#include "test_base.h"
|
||||
#include "test_printers.h"
|
||||
@@ -33,6 +32,7 @@ namespace wvcdm {
|
||||
|
||||
using drm_metrics::DistributionMetric;
|
||||
using drm_metrics::WvCdmMetrics;
|
||||
using metrics::EngineMetrics;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -41,17 +41,21 @@ const int kHttpOk = 200;
|
||||
|
||||
const std::string kCencMimeType = "video/mp4";
|
||||
const std::string kWebmMimeType = "video/webm";
|
||||
const std::string kEmptyString;
|
||||
const std::string kComma = ",";
|
||||
|
||||
} // namespace
|
||||
|
||||
class WvCdmEnginePreProvTest : public WvCdmTestBase {
|
||||
public:
|
||||
WvCdmEnginePreProvTest()
|
||||
: cdm_engine_(&file_system_), session_opened_(false) {}
|
||||
: dummy_engine_metrics_(new EngineMetrics),
|
||||
cdm_engine_(&file_system_, dummy_engine_metrics_),
|
||||
session_opened_(false) {}
|
||||
|
||||
virtual ~WvCdmEnginePreProvTest() {}
|
||||
~WvCdmEnginePreProvTest() override {}
|
||||
|
||||
virtual void SetUp() {
|
||||
void SetUp() override {
|
||||
WvCdmTestBase::SetUp();
|
||||
session_opened_ = false;
|
||||
}
|
||||
@@ -70,7 +74,7 @@ class WvCdmEnginePreProvTest : public WvCdmTestBase {
|
||||
session_opened_ = true;
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
void TearDown() override {
|
||||
if (cdm_engine_.IsProvisioned(kSecurityLevelL1)) {
|
||||
cdm_engine_.Unprovision(kSecurityLevelL1);
|
||||
}
|
||||
@@ -111,6 +115,7 @@ class WvCdmEnginePreProvTest : public WvCdmTestBase {
|
||||
}
|
||||
|
||||
FileSystem file_system_;
|
||||
shared_ptr<metrics::EngineMetrics> dummy_engine_metrics_;
|
||||
CdmEngine cdm_engine_;
|
||||
bool session_opened_;
|
||||
std::string key_msg_;
|
||||
@@ -151,21 +156,21 @@ class WvCdmEngineTest : public WvCdmEnginePreProvTest {
|
||||
public:
|
||||
WvCdmEngineTest() {}
|
||||
|
||||
virtual void SetUp() {
|
||||
CdmResponseType status =
|
||||
cdm_engine_.OpenSession(config_.key_system(), NULL, NULL, &session_id_);
|
||||
if (status == NEED_PROVISIONING) {
|
||||
Provision();
|
||||
status = cdm_engine_.OpenSession(config_.key_system(), NULL, NULL, &session_id_);
|
||||
}
|
||||
ASSERT_EQ(NO_ERROR, status);
|
||||
ASSERT_NE("", session_id_) << "Could not open CDM session.";
|
||||
ASSERT_TRUE(cdm_engine_.IsOpenSession(session_id_));
|
||||
void SetUp() override {
|
||||
WvCdmTestBase::SetUp();
|
||||
session_opened_ = false;
|
||||
WvCdmEnginePreProvTest::OpenSession();
|
||||
}
|
||||
|
||||
protected:
|
||||
void GenerateKeyRequest(const std::string& key_id,
|
||||
const std::string& init_data_type_string) {
|
||||
GenerateKeyRequest(key_id, init_data_type_string, kLicenseTypeStreaming);
|
||||
}
|
||||
|
||||
void GenerateKeyRequest(const std::string& key_id,
|
||||
const std::string& init_data_type_string,
|
||||
CdmLicenseType license_type) {
|
||||
CdmAppParameterMap app_parameters;
|
||||
CdmKeySetId key_set_id;
|
||||
|
||||
@@ -174,7 +179,7 @@ class WvCdmEngineTest : public WvCdmEnginePreProvTest {
|
||||
CdmKeyRequest key_request;
|
||||
|
||||
CdmResponseType result = cdm_engine_.GenerateKeyRequest(
|
||||
session_id_, key_set_id, init_data, kLicenseTypeStreaming,
|
||||
session_id_, key_set_id, init_data, license_type,
|
||||
app_parameters, &key_request);
|
||||
EXPECT_EQ(KEY_MESSAGE, result);
|
||||
|
||||
@@ -241,11 +246,21 @@ class WvCdmEngineTest : public WvCdmEnginePreProvTest {
|
||||
|
||||
void VerifyNewKeyResponse(const std::string& server_url,
|
||||
const std::string& client_auth) {
|
||||
VerifyNewKeyResponse(server_url, client_auth, kLicenseTypeStreaming);
|
||||
}
|
||||
void VerifyNewKeyResponse(const std::string& server_url,
|
||||
const std::string& client_auth,
|
||||
CdmLicenseType expected_license_type) {
|
||||
std::string resp = GetKeyRequestResponse(server_url, client_auth);
|
||||
CdmKeySetId key_set_id;
|
||||
EXPECT_EQ(KEY_ADDED, cdm_engine_.AddKey(session_id_, resp, &key_set_id));
|
||||
CdmLicenseType license_type;
|
||||
CdmResponseType status =
|
||||
cdm_engine_.AddKey(session_id_, resp, &license_type, &key_set_id);
|
||||
|
||||
EXPECT_EQ(KEY_ADDED, status);
|
||||
EXPECT_EQ(expected_license_type, license_type);
|
||||
VerifyLicenseRequestLatency(kKeyRequestTypeInitial,
|
||||
*cdm_engine_.GetMetrics());
|
||||
*dummy_engine_metrics_);
|
||||
}
|
||||
|
||||
void VerifyRenewalKeyResponse(const std::string& server_url,
|
||||
@@ -253,7 +268,7 @@ class WvCdmEngineTest : public WvCdmEnginePreProvTest {
|
||||
std::string resp = GetKeyRequestResponse(server_url, client_auth);
|
||||
EXPECT_EQ(KEY_ADDED, cdm_engine_.RenewKey(session_id_, resp));
|
||||
VerifyLicenseRequestLatency(kKeyRequestTypeRenewal,
|
||||
*cdm_engine_.GetMetrics());
|
||||
*dummy_engine_metrics_);
|
||||
}
|
||||
|
||||
void VerifyLicenseRequestLatency(
|
||||
@@ -304,8 +319,7 @@ TEST_F(WvCdmEnginePreProvTestUat, ProvisioningServiceCertificateInvalidTest) {
|
||||
|
||||
TEST_F(WvCdmEnginePreProvTestStaging, ProvisioningTest) { Provision(); }
|
||||
|
||||
// TODO(b/112046733): This test is broken. It should be fixed.
|
||||
TEST_F(WvCdmEnginePreProvTestUatBinary, DISABLED_ProvisioningTest) {
|
||||
TEST_F(WvCdmEnginePreProvTestUatBinary, ProvisioningTest) {
|
||||
Provision();
|
||||
}
|
||||
|
||||
@@ -342,6 +356,13 @@ TEST_F(WvCdmEngineTest, NormalDecryptionIsoBmff) {
|
||||
VerifyNewKeyResponse(config_.license_server(), config_.client_auth());
|
||||
}
|
||||
|
||||
// TODO(blueeyes): Add tests for different license types.
|
||||
TEST_F(WvCdmEngineTest, ReturnsLicenseTypeDetailStreaming) {
|
||||
GenerateKeyRequest(binary_key_id(), kCencMimeType, kLicenseTypeStreaming);
|
||||
VerifyNewKeyResponse(config_.license_server(), config_.client_auth(),
|
||||
kLicenseTypeStreaming);
|
||||
}
|
||||
|
||||
// TODO(juce): Set up with correct test data.
|
||||
TEST_F(WvCdmEngineTest, DISABLED_NormalDecryptionWebm) {
|
||||
// Extract the key ID from the PSSH box.
|
||||
@@ -373,4 +394,116 @@ TEST_F(WvCdmEngineTest, LicenseRenewal) {
|
||||
config_.client_auth());
|
||||
}
|
||||
|
||||
TEST_F(WvCdmEngineTest, ParseDecryptHashStringTest) {
|
||||
|
||||
CdmSessionId session_id;
|
||||
uint32_t frame_number;
|
||||
std::string hash;
|
||||
|
||||
const std::string test_session_id = "sample session id";
|
||||
uint32_t test_frame_number = 5;
|
||||
const std::string test_frame_number_string =
|
||||
std::to_string(test_frame_number);
|
||||
const std::string test_invalid_hash = "an invalid hash";
|
||||
std::vector<uint8_t> binary_hash{ 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38 };
|
||||
const std::string test_valid_decoded_hash(binary_hash.begin(),
|
||||
binary_hash.end());
|
||||
const std::string test_valid_hash = Base64Encode(binary_hash);
|
||||
const std::string test_invalid_hash_string = "sample hash string";
|
||||
const std::string test_valid_hash_string = test_session_id + kComma +
|
||||
test_frame_number_string + kComma + test_valid_hash;
|
||||
|
||||
// invalid parameters
|
||||
EXPECT_EQ(PARAMETER_NULL,
|
||||
CdmEngine::ParseDecryptHashString(test_valid_hash_string, nullptr,
|
||||
&frame_number, &hash));
|
||||
EXPECT_EQ(PARAMETER_NULL,
|
||||
CdmEngine::ParseDecryptHashString(test_valid_hash_string,
|
||||
&session_id, nullptr, &hash));
|
||||
EXPECT_EQ(PARAMETER_NULL,
|
||||
CdmEngine::ParseDecryptHashString(test_valid_hash_string,
|
||||
&session_id, &frame_number,
|
||||
nullptr));
|
||||
|
||||
// Too few or too many parameters
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(kEmptyString, &session_id,
|
||||
&frame_number, &hash));
|
||||
std::string hash_data = test_session_id;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
hash_data += kComma;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
hash_data += test_frame_number_string;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
hash_data += kComma;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
hash_data += test_valid_hash + kComma + test_valid_hash;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
|
||||
// No parameters
|
||||
hash_data = kComma;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
hash_data = kComma + kComma;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
hash_data = kComma + kComma + kComma;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
|
||||
// Missing parameters
|
||||
hash_data = kComma + test_frame_number_string + kComma + test_valid_hash;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
hash_data = test_session_id + kComma + kComma + test_valid_hash;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
hash_data = test_session_id + kComma + test_frame_number_string + kComma;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
hash_data = test_session_id + kComma + test_frame_number_string + kComma +
|
||||
kComma;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
|
||||
// Invalid parameters (frame number, hash)
|
||||
hash_data = test_session_id + kComma + test_session_id + kComma +
|
||||
test_valid_hash;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
hash_data = test_session_id + kComma + test_frame_number_string + kComma +
|
||||
test_invalid_hash;
|
||||
EXPECT_EQ(INVALID_DECRYPT_HASH_FORMAT,
|
||||
CdmEngine::ParseDecryptHashString(hash_data, &session_id,
|
||||
&frame_number, &hash));
|
||||
|
||||
// valid data
|
||||
EXPECT_EQ(NO_ERROR,
|
||||
CdmEngine::ParseDecryptHashString(test_valid_hash_string,
|
||||
&session_id, &frame_number,
|
||||
&hash));
|
||||
EXPECT_EQ(test_session_id, session_id);
|
||||
EXPECT_EQ(test_frame_number, frame_number);
|
||||
EXPECT_EQ(test_valid_decoded_hash, hash);
|
||||
}
|
||||
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
Reference in New Issue
Block a user