Only one function for reporting usage support.
[ Merge of http://go/wvgerrit/121567 ] Replaced the two usage support functions GetUsageSupportType() and UsageInformationSupport() into a single function HasUsageInfoSupport(). Since moving to only supporting a single usage info system (usage table header + usage entries), the different usage support functions have lost their purpose. One version of the method works on an open session and will use a cached value of the property if previously set. The other can be called without opening the session (as used for query calls). This is part of larger fix for the usage table initialization process. Bug: 169195093 Test: CE CDM unit tests Change-Id: I637c24dd143e995dbb0f8848850e3c71ff1018eb
This commit is contained in:
@@ -136,10 +136,10 @@ class MockCryptoSession : public TestCryptoSession {
|
||||
public:
|
||||
MockCryptoSession(metrics::CryptoMetrics* crypto_metrics)
|
||||
: TestCryptoSession(crypto_metrics) {
|
||||
// By default, call the concrete implementation of GetUsageSupportType.
|
||||
ON_CALL(*this, GetUsageSupportType(_))
|
||||
// By default, call the concrete implementation of HasUsageInfoSupport.
|
||||
ON_CALL(*this, HasUsageInfoSupport(_))
|
||||
.WillByDefault(
|
||||
Invoke(this, &MockCryptoSession::BaseGetUsageSupportType));
|
||||
Invoke(this, &MockCryptoSession::BaseHasUsageInfoSupport));
|
||||
}
|
||||
MOCK_METHOD1(GetClientToken, bool(std::string*));
|
||||
MOCK_METHOD1(GetProvisioningToken, CdmResponseType(std::string*));
|
||||
@@ -150,11 +150,11 @@ class MockCryptoSession : public TestCryptoSession {
|
||||
MOCK_METHOD1(LoadCertificatePrivateKey,
|
||||
CdmResponseType(const CryptoWrappedKey&));
|
||||
MOCK_METHOD0(DeleteAllUsageReports, CdmResponseType());
|
||||
MOCK_METHOD1(GetUsageSupportType, CdmResponseType(CdmUsageSupportType* type));
|
||||
MOCK_METHOD1(HasUsageInfoSupport, bool(bool*));
|
||||
MOCK_METHOD0(GetUsageTableHeader, UsageTableHeader*());
|
||||
|
||||
CdmResponseType BaseGetUsageSupportType(CdmUsageSupportType* type) {
|
||||
return CryptoSession::GetUsageSupportType(type);
|
||||
bool BaseHasUsageInfoSupport(bool* has_support) {
|
||||
return CryptoSession::HasUsageInfoSupport(has_support);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -291,17 +291,15 @@ TEST_F(CdmSessionTest, UpdateUsageEntry) {
|
||||
.WillOnce(Return(true));
|
||||
|
||||
// Set up mocks and expectations for the UpdateUsageEntryInformation call.
|
||||
EXPECT_CALL(*crypto_session_, GetUsageSupportType(_))
|
||||
.WillRepeatedly(
|
||||
DoAll(SetArgPointee<0>(kUsageEntrySupport), Return(NO_ERROR)));
|
||||
EXPECT_CALL(*crypto_session_, HasUsageInfoSupport(_))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<0>(true), Return(true)));
|
||||
EXPECT_CALL(*license_parser_, provider_session_token())
|
||||
.WillRepeatedly(Return("Mock provider session token"));
|
||||
EXPECT_CALL(usage_table_header_, UpdateEntry(_, NotNull(), NotNull()))
|
||||
.WillRepeatedly(Return(NO_ERROR));
|
||||
|
||||
EXPECT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
EXPECT_EQ(kUsageEntrySupport, cdm_session_->get_usage_support_type())
|
||||
<< "Usage support type: " << cdm_session_->get_usage_support_type();
|
||||
EXPECT_TRUE(cdm_session_->supports_usage_info());
|
||||
EXPECT_EQ(NO_ERROR, cdm_session_->UpdateUsageEntryInformation());
|
||||
|
||||
// Verify the UsageEntry metric is set.
|
||||
|
||||
@@ -291,8 +291,8 @@ TEST_F(CryptoSessionMetricsTest, OpenSessionValidMetrics) {
|
||||
CryptoSession::MakeCryptoSession(&crypto_metrics));
|
||||
session->Open(wvcdm::kLevelDefault);
|
||||
// Exercise a method that will touch a metric.
|
||||
CdmUsageSupportType usage_type;
|
||||
ASSERT_EQ(NO_ERROR, session->GetUsageSupportType(&usage_type));
|
||||
bool supports_usage_table;
|
||||
ASSERT_TRUE(session->HasUsageInfoSupport(&supports_usage_table));
|
||||
|
||||
drm_metrics::WvCdmMetrics::CryptoMetrics metrics_proto;
|
||||
crypto_metrics.Serialize(&metrics_proto);
|
||||
@@ -309,6 +309,8 @@ TEST_F(CryptoSessionMetricsTest, OpenSessionValidMetrics) {
|
||||
metrics_proto.oemcrypto_initialize_time_us(0).operation_count());
|
||||
EXPECT_TRUE(metrics_proto.oemcrypto_initialize_time_us(0).has_mean());
|
||||
|
||||
const CdmUsageSupportType usage_type =
|
||||
supports_usage_table ? kUsageEntrySupport : kNonSecureUsageSupport;
|
||||
EXPECT_EQ(usage_type,
|
||||
metrics_proto.oemcrypto_usage_table_support().int_value());
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ class MockCryptoSession : public TestCryptoSession {
|
||||
: TestCryptoSession(crypto_metrics) {}
|
||||
MOCK_METHOD0(IsOpen, bool());
|
||||
MOCK_METHOD0(request_id, const std::string&());
|
||||
MOCK_METHOD1(UsageInformationSupport, bool(bool*));
|
||||
MOCK_METHOD1(HasUsageInfoSupport, bool(bool*));
|
||||
MOCK_METHOD2(GetHdcpCapabilities,
|
||||
CdmResponseType(HdcpCapability*, HdcpCapability*));
|
||||
MOCK_METHOD1(GetSupportedCertificateTypes, bool(SupportedCertificateTypes*));
|
||||
@@ -301,7 +301,7 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidation) {
|
||||
EXPECT_CALL(*crypto_session_, IsOpen()).WillOnce(Return(true));
|
||||
EXPECT_CALL(*crypto_session_, request_id())
|
||||
.WillOnce(ReturnRef(kCryptoRequestId));
|
||||
EXPECT_CALL(*crypto_session_, UsageInformationSupport(NotNull()))
|
||||
EXPECT_CALL(*crypto_session_, HasUsageInfoSupport(NotNull()))
|
||||
.WillOnce(
|
||||
DoAll(SetArgPointee<0>(usage_information_support), Return(true)));
|
||||
EXPECT_CALL(*crypto_session_, GetHdcpCapabilities(NotNull(), NotNull()))
|
||||
@@ -424,7 +424,7 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidationV15) {
|
||||
EXPECT_CALL(*crypto_session_, IsOpen()).WillOnce(Return(true));
|
||||
EXPECT_CALL(*crypto_session_, request_id())
|
||||
.WillOnce(ReturnRef(kCryptoRequestId));
|
||||
EXPECT_CALL(*crypto_session_, UsageInformationSupport(NotNull()))
|
||||
EXPECT_CALL(*crypto_session_, HasUsageInfoSupport(NotNull()))
|
||||
.WillOnce(
|
||||
DoAll(SetArgPointee<0>(usage_information_support), Return(true)));
|
||||
EXPECT_CALL(*crypto_session_, GetHdcpCapabilities(NotNull(), NotNull()))
|
||||
|
||||
Reference in New Issue
Block a user