Merge of the widevine change: https://widevine-internal-review.googlesource.com/#/c/11632 Several unit tests in cdm_engine_test.cpp and request_license_test.cpp were failing regularly. These were caused by either: 1) The device was not provisioned. This has been fixed by adding a certificate provisioning step in the test setup for the cdm engine tests and changing the existing provision steop in the request license tests to provision for both security levels. 2) The device was hitting a flaky server. This has been fixed by switching from the GooglePlayServer to the Widevine server. 3) A null pointer introduced when testing secure stops with an app id. This has been fixed by directly injecting the app id in the unit tests. 4) Flaky network connections. The unit tests were requesting data from the server and were timing out after 3 seconds. I changed that to 12 seconds. 5) The tests were searching for an end-of-line marker to find the GLS header in the license response message. The end-of-line marker was present in a valid DRM message for almost 1% of the test cases. This code has been replaced by searching for the string "GLS/1" at the begining of the HTML body. I also added test_printers.cpp that defines functions used by GTest to print error codes by name instead of numeric value. This CL changes unit tests only. It does not change any production code. bug: 18316036 Change-Id: I3398580059a03114e782ac7ac59e6b0944012df4
94 lines
3.0 KiB
C++
94 lines
3.0 KiB
C++
// Copyright 2013 Google Inc. All Rights Reserved.
|
|
// This file adds some print methods so that when unit tests fail, the
|
|
// will print the name of an enumeration instead of the numeric value.
|
|
|
|
#include "test_printers.h"
|
|
|
|
namespace wvcdm {
|
|
|
|
void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
|
|
switch(value) {
|
|
case NO_ERROR: *os << "NO_ERROR";
|
|
break;
|
|
case UNKNOWN_ERROR: *os << "UNKNOWN_ERROR";
|
|
break;
|
|
case KEY_ADDED: *os << "KEY_ADDED";
|
|
break;
|
|
case KEY_ERROR: *os << "KEY_ERROR";
|
|
break;
|
|
case KEY_MESSAGE: *os << "KEY_MESSAGE";
|
|
break;
|
|
case NEED_KEY: *os << "NEED_KEY";
|
|
break;
|
|
case KEY_CANCELED: *os << "KEY_CANCELED";
|
|
break;
|
|
case NEED_PROVISIONING: *os << "NEED_PROVISIONING";
|
|
break;
|
|
case DEVICE_REVOKED: *os << "DEVICE_REVOKED";
|
|
break;
|
|
case INSUFFICIENT_CRYPTO_RESOURCES: *os << "INSUFFICIENT_CRYPTO_RESOURCES";
|
|
break;
|
|
default:
|
|
*os << "Unknown CdmResponseType";
|
|
break;
|
|
}
|
|
}
|
|
|
|
void PrintTo(const enum CdmEventType& value, ::std::ostream* os) {
|
|
switch(value) {
|
|
case LICENSE_EXPIRED_EVENT: *os << "LICENSE_EXPIRED_EVENT";
|
|
break;
|
|
case LICENSE_RENEWAL_NEEDED_EVENT: *os << "LICENSE_RENEWAL_NEEDED_EVENT";
|
|
break;
|
|
default:
|
|
*os << "Unknown CdmEventType";
|
|
break;
|
|
}
|
|
};
|
|
|
|
void PrintTo(const enum CdmLicenseType& value, ::std::ostream* os) {
|
|
switch(value) {
|
|
case kLicenseTypeOffline: *os << "kLicenseTypeOffline";
|
|
break;
|
|
case kLicenseTypeStreaming: *os << "kLicenseTypeStreaming";
|
|
break;
|
|
case kLicenseTypeRelease: *os << "kLicenseTypeRelease";
|
|
break;
|
|
default:
|
|
*os << "Unknown CdmLicenseType";
|
|
break;
|
|
}
|
|
};
|
|
|
|
void PrintTo(const enum CdmSecurityLevel& value, ::std::ostream* os) {
|
|
switch(value) {
|
|
case kSecurityLevelUninitialized: *os << "kSecurityLevelUninitialized";
|
|
break;
|
|
case kSecurityLevelL1: *os << "kSecurityLevelL1";
|
|
break;
|
|
case kSecurityLevelL2: *os << "kSecurityLevelL2";
|
|
break;
|
|
case kSecurityLevelL3: *os << "kSecurityLevelL3";
|
|
break;
|
|
case kSecurityLevelUnknown: *os << "kSecurityLevelUnknown";
|
|
break;
|
|
default:
|
|
*os << "Unknown CdmSecurityLevel";
|
|
break;
|
|
}
|
|
};
|
|
|
|
void PrintTo(const enum CdmCertificateType& value, ::std::ostream* os) {
|
|
switch(value) {
|
|
case kCertificateWidevine: *os << "kCertificateWidevine";
|
|
break;
|
|
case kCertificateX509: *os << "kCertificateX509";
|
|
break;
|
|
default:
|
|
*os << "Unknown CdmCertificateType";
|
|
break;
|
|
}
|
|
};
|
|
|
|
}; // namespace wvcdm
|