Merge changes I2618c2be,Ie8b9d8b9,I2f39f99c
* changes: Support GetPropertyByteArray for getting metrics. CDM Metrics Protocol buffer serialization. Refactored metrics to support pull model.
This commit is contained in:
@@ -114,7 +114,17 @@ const std::string kAppId("com.unittest.mock.app.id");
|
||||
const uint8_t* const kUnprovisionResponse =
|
||||
reinterpret_cast<const uint8_t*>("unprovision");
|
||||
const size_t kUnprovisionResponseSize = 11;
|
||||
}
|
||||
const std::string kDeviceId = "0123456789ABCDEF";
|
||||
|
||||
// This is a serialized MetricsGroup message containing a small amount of
|
||||
// sample data. This ensures we're able to extract it via a property.
|
||||
const char kSerializedMetrics[] = {
|
||||
0x0a, 0x0a, 0x0a, 0x04, 0x74, 0x65, 0x73, 0x74, 0x12, 0x02, 0x08, 0x00,
|
||||
0x0a, 0x12, 0x0a, 0x05, 0x74, 0x65, 0x73, 0x74, 0x32, 0x12, 0x09, 0x11,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x15, 0x0a, 0x05,
|
||||
0x74, 0x65, 0x73, 0x74, 0x33, 0x12, 0x0c, 0x1a, 0x0a, 0x74, 0x65, 0x73,
|
||||
0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65};
|
||||
} // anonymous namespace
|
||||
|
||||
class MockCDM : public WvContentDecryptionModule {
|
||||
public:
|
||||
@@ -180,6 +190,8 @@ class MockCDM : public WvContentDecryptionModule {
|
||||
CdmResponseType(const CdmUsageInfoReleaseMessage&, const CdmIdentifier&));
|
||||
|
||||
MOCK_METHOD1(IsValidServiceCertificate, bool(const std::string&));
|
||||
|
||||
MOCK_METHOD1(GetSerializedMetrics, void(std::string*));
|
||||
};
|
||||
|
||||
class MockCrypto : public WVGenericCryptoInterface {
|
||||
@@ -1044,6 +1056,8 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
|
||||
static const std::string openSessions = "42";
|
||||
static const std::string maxSessions = "54";
|
||||
static const std::string oemCryptoApiVersion = "13";
|
||||
std::string serializedMetrics(
|
||||
kSerializedMetrics, kSerializedMetrics + sizeof(kSerializedMetrics));
|
||||
|
||||
EXPECT_CALL(*cdm, QueryStatus(_, QUERY_KEY_SECURITY_LEVEL, _))
|
||||
.WillOnce(DoAll(SetArgPointee<2>(QUERY_VALUE_SECURITY_LEVEL_L1),
|
||||
@@ -1075,6 +1089,9 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
|
||||
.WillOnce(DoAll(SetArgPointee<2>(oemCryptoApiVersion),
|
||||
testing::Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(*cdm, GetSerializedMetrics(_))
|
||||
.WillOnce(SetArgPointee<0>(serializedMetrics));
|
||||
|
||||
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto, false);
|
||||
std::string stringResult;
|
||||
std::vector<uint8_t> vectorResult;
|
||||
@@ -1161,6 +1178,15 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
EXPECT_EQ(oemCryptoApiVersion, stringResult.c_str());
|
||||
});
|
||||
|
||||
plugin.getPropertyByteArray(
|
||||
hidl_string("metrics"),
|
||||
[&](Status status, hidl_vec<uint8_t> vectorResult) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
std::vector<uint8_t> id(vectorResult);
|
||||
EXPECT_THAT(id, ElementsAreArray(serializedMetrics.data(),
|
||||
serializedMetrics.size()));
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(WVDrmPluginTest, DoesNotGetUnknownProperties) {
|
||||
|
||||
Reference in New Issue
Block a user