am 89682556: Fix CanSetServiceCertificate Test

* commit '89682556adb5dd2689ca346e66d924b42d0ff848':
  Fix CanSetServiceCertificate Test
This commit is contained in:
John "Juce" Bruce
2015-06-19 18:48:24 +00:00
committed by Android Git Automerger
4 changed files with 25 additions and 8 deletions

View File

@@ -92,6 +92,8 @@ class MockCDM : public WvContentDecryptionModule {
MOCK_METHOD1(ReleaseUsageInfo,
CdmResponseType(const CdmUsageInfoReleaseMessage&));
MOCK_METHOD1(IsValidServiceCertificate, bool(const std::string&));
};
class MockCrypto : public WVGenericCryptoInterface {
@@ -1702,6 +1704,8 @@ TEST_F(WVDrmPluginTest, CanSetServiceCertificate) {
Vector<uint8_t> privacyCert;
privacyCert.appendArray(privacyCertRaw, kPrivacyCertSize);
std::string strPrivacyCert(reinterpret_cast<char*>(privacyCertRaw),
kPrivacyCertSize);
Vector<uint8_t> emptyVector;
// Provide expected mock behavior
@@ -1721,6 +1725,13 @@ TEST_F(WVDrmPluginTest, CanSetServiceCertificate) {
.Times(AtLeast(0));
}
// Validate that the certificate is validated. Accept it once and reject it
// once. Note that there is no expected call for when the certificate is
// cleared.
EXPECT_CALL(*cdm, IsValidServiceCertificate(strPrivacyCert))
.WillOnce(Return(true))
.WillOnce(Return(false));
plugin.openSession(sessionId);
ASSERT_THAT(propertySet, NotNull());
@@ -1736,6 +1747,11 @@ TEST_F(WVDrmPluginTest, CanSetServiceCertificate) {
res = plugin.setPropertyByteArray(String8("serviceCertificate"), emptyVector);
ASSERT_EQ(OK, res);
EXPECT_EQ(0u, propertySet->service_certificate().size());
// Test setting a certificate and having it fail
res = plugin.setPropertyByteArray(String8("serviceCertificate"), privacyCert);
ASSERT_NE(OK, res);
EXPECT_EQ(0u, propertySet->service_certificate().size());
}
TEST_F(WVDrmPluginTest, CanSetSessionSharing) {