Add hal_metrics_adapter_unittest for AIDL service. am: cf3771e54a am: 67522b7b65

Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18308868

Change-Id: I7967755fcea35ab9518d9f640a4fdf3dfb110e01
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Edwin Wong
2022-05-12 03:29:55 +00:00
committed by Automerger Merge Worker
3 changed files with 503 additions and 5 deletions

View File

@@ -120,10 +120,13 @@ endif
include $(BUILD_EXECUTABLE)
# -----------------------------------------------------------------------------
# Builds hidl_metrics_adapter_unittest
# Builds hidl hal_metrics_adapter_unittest
#
include $(CLEAR_VARS)
WV_UNITTESTS_BUILD_TARGET?=
ifeq ($(WV_UNITTESTS_BUILD_TARGET), hidl)
LOCAL_SRC_FILES := \
hidl/hidl_metrics_adapter_unittest.cpp \
@@ -143,10 +146,9 @@ LOCAL_STATIC_LIBRARIES := \
libcdm_utils \
libgtest \
libgtest_main \
libwvdrmdrmplugin_hidl \
libjsmn \
libwvlevel3 \
libwvdrmdrmplugin_hidl \
libwvlevel3 \
libwv_odk \
LOCAL_SHARED_LIBRARIES := \
@@ -163,7 +165,46 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_C_INCLUDES += \
external/protobuf/src \
LOCAL_MODULE := hidl_metrics_adapter_unittest
# build unit tests for Aidl
else
LOCAL_SRC_FILES := \
hal_metrics_adapter_unittest.cpp \
LOCAL_C_INCLUDES := \
vendor/widevine/libwvdrmengine/cdm/core/include \
vendor/widevine/libwvdrmengine/cdm/include \
vendor/widevine/libwvdrmengine/cdm/metrics/include \
vendor/widevine/libwvdrmengine/cdm/util/include \
vendor/widevine/libwvdrmengine/aidl_include \
vendor/widevine/libwvdrmengine/include \
vendor/widevine/libwvdrmengine/mediadrm/aidl_include \
vendor/widevine/libwvdrmengine/oemcrypto/include \
LOCAL_STATIC_LIBRARIES := \
libcdm \
libcdm_protos \
libcdm_utils \
libgtest \
libgtest_main \
libjsmn \
libwvdrmdrmplugin_aidl \
libwvlevel3 \
libwv_odk \
LOCAL_SHARED_LIBRARIES := \
android.hardware.drm-V1-ndk \
libcrypto \
liblog \
libprotobuf-cpp-lite \
libutils \
LOCAL_C_INCLUDES += \
external/protobuf/src \
# endif $(WV_UNITTESTS_BUILD_TARGET)
endif
LOCAL_MODULE := hal_metrics_adapter_unittest
LOCAL_LICENSE_KINDS := legacy_by_exception_only
LOCAL_LICENSE_CONDITIONS := by_exception_only

View File

@@ -0,0 +1,457 @@
//
// Copyright 2022 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
// This file contains unit tests for the HalMetricsAdapter.
#include "wv_metrics_adapter.h"
#include <sstream>
#include <utils/Log.h>
#include "wv_metrics.pb.h"
#include "gtest/gtest.h"
namespace wvcdm {
using ::aidl::android::hardware::drm::DrmMetric;
using ::aidl::android::hardware::drm::DrmMetricGroup;
using ::aidl::android::hardware::drm::DrmMetricNamedValue;
using ::aidl::android::hardware::drm::DrmMetricValue;
using drm_metrics::CounterMetric;
using drm_metrics::DistributionMetric;
std::string ToString(const DrmMetricValue value) {
std::ostringstream os;
switch (value.getTag()) {
case DrmMetricValue::Tag::doubleValue:
os << "double: " << value.get<DrmMetricValue::Tag::doubleValue>();
break;
case DrmMetricValue::Tag::int64Value:
os << "int64: " << value.get<DrmMetricValue::Tag::int64Value>();
break;
case DrmMetricValue::Tag::stringValue:
os << "string: " << value.get<DrmMetricValue::Tag::stringValue>();
break;
default:
os << "(\"<< Unknown type, valid types are: doubleValue, int64Value and "
"stringValue\")";
break;
}
return os.str();
}
std::string ToString(const DrmMetric &metric) {
std::ostringstream os;
os << "metric: " << metric.name << std::endl;
os << " attributes:" << std::endl;
for (unsigned a = 0; a < metric.attributes.size(); a++) {
os << " " << metric.attributes[a].name << ". "
<< ToString(metric.attributes[a].value) << std::endl;
}
os << " values:" << std::endl;
for (unsigned v = 0; v < metric.values.size(); v++) {
os << " " << metric.values[v].name << ". "
<< ToString(metric.values[v].value) << std::endl;
}
return os.str();
}
std::string ToString(const std::vector<DrmMetricGroup> &group) {
std::ostringstream os;
os << "Drm metrics..." << std::endl;
os << "group count: " << group.size() << std::endl;
for (size_t g = 0; g < group.size(); g++) {
os << "group " << g << ". metric count: " << group[g].metrics.size()
<< std::endl;
for (const auto &metric : group[g].metrics) {
os << ToString(metric);
}
}
return os.str();
}
bool HasMetric(const DrmMetric &expected,
const DrmMetricGroup &actual_metrics) {
auto it = std::find(actual_metrics.metrics.begin(),
actual_metrics.metrics.end(), expected);
if (it == actual_metrics.metrics.end()) {
ALOGE("COULDN'T FIND THE METRIC! %s", ToString(expected).c_str());
for (auto it = actual_metrics.metrics.begin();
it < actual_metrics.metrics.end(); it++) {
if (expected.name == it->name) {
ALOGE("Names match.");
}
if (expected.attributes == it->attributes) {
ALOGE("attributes match.");
}
if (expected.values == it->values) {
ALOGE("values match.");
} else {
ALOGE("values length match? %zu, %zu", expected.values.size(),
it->values.size());
if (expected.values.size() == it->values.size()) {
for (unsigned int i = 0; i < expected.values.size(); i++) {
ALOGE("value %u match? %d", i, expected.values[i] == it->values[i]);
if (expected.values[i] != it->values[i]) {
ALOGE("value component mismatch. %u. %s, %s", i,
ToString(expected).c_str(), ToString(*it).c_str());
}
}
}
}
}
} else {
ALOGE("Found metric: %s", ToString(*it).c_str());
}
return it != actual_metrics.metrics.end();
}
TEST(HalMetricsAdapterTest, EmptyMetrics) {
drm_metrics::WvCdmMetrics metrics_proto;
std::vector<DrmMetricGroup> metrics;
::wvcdm::WvMetricsAdapter::ToWvMetrics(metrics_proto, &metrics);
ASSERT_EQ(0U, metrics.size()) << ToString(metrics);
}
// Adds a metric from each type - Value, counter and distribution.
TEST(HalMetricsAdapterTest, AllMetricTypes) {
drm_metrics::WvCdmMetrics metrics_proto;
// Value metric - error.
metrics_proto.mutable_engine_metrics()
->mutable_crypto_metrics()
->mutable_crypto_session_security_level()
->set_error_code(7);
DrmMetric expected_value_metric_1 = {
"crypto_session_security_level",
{},
{{"error_code", {DrmMetricValue::make<DrmMetricValue::int64Value>(7)}}},
};
// Value metric - integer.
metrics_proto.mutable_engine_metrics()
->mutable_oemcrypto_initialization_mode()
->set_int_value(11);
DrmMetric expected_value_metric_2 = {
"oemcrypto_initialization_mode",
{},
{{"value", {DrmMetricValue::make<DrmMetricValue::int64Value>(11)}}},
};
// Value metric - double.
metrics_proto.mutable_engine_metrics()
->mutable_cdm_engine_life_span_ms()
->set_double_value(3.14159);
DrmMetric expected_value_metric_3 = {
"cdm_engine_life_span_ms",
{},
{{"value", {DrmMetricValue::make<DrmMetricValue::doubleValue>(3.14159)}}},
};
// Value metric - string.
metrics_proto.mutable_engine_metrics()
->mutable_cdm_engine_cdm_version()
->set_string_value("test");
DrmMetric expected_value_metric_4 = {
"cdm_engine_cdm_version",
{},
{{"value", {DrmMetricValue::make<DrmMetricValue::stringValue>("test")}}},
};
// Counter metric
CounterMetric *counter = metrics_proto.mutable_engine_metrics()
->mutable_crypto_metrics()
->add_crypto_session_get_token();
counter->set_count(13);
counter->mutable_attributes()->set_error_code(17);
DrmMetric expected_counter_metric_1 = {
"crypto_session_get_token",
{{"error_code", {DrmMetricValue::make<DrmMetricValue::int64Value>(17)}}},
{{"count", {DrmMetricValue::make<DrmMetricValue::int64Value>(13)}}},
};
// Add a second counter.
counter = metrics_proto.mutable_engine_metrics()
->mutable_crypto_metrics()
->add_crypto_session_get_token();
counter->set_count(19);
counter->mutable_attributes()->set_error_code(23);
DrmMetric expected_counter_metric_2 = {
"crypto_session_get_token",
{{"error_code", {DrmMetricValue::make<DrmMetricValue::int64Value>(23)}}},
{{"count", {DrmMetricValue::make<DrmMetricValue::int64Value>(19)}}},
};
// Distribution metric
DistributionMetric *distribution = metrics_proto.mutable_engine_metrics()
->mutable_crypto_metrics()
->add_crypto_session_open_time_us();
distribution->set_min(1.0);
distribution->set_max(1.2);
distribution->set_mean(1.1);
distribution->set_variance(.01);
distribution->set_operation_count(2);
distribution->mutable_attributes()->set_error_code(0);
DrmMetric expected_distribution_metric_1 = {
"crypto_session_open_time_us",
{{"error_code", {DrmMetricValue::make<DrmMetricValue::int64Value>(0)}}},
{{"mean", {DrmMetricValue::make<DrmMetricValue::doubleValue>(1.1f)}},
{"count", {DrmMetricValue::make<DrmMetricValue::int64Value>(2)}},
{"min", {DrmMetricValue::make<DrmMetricValue::doubleValue>(1.0)}},
{"max", {DrmMetricValue::make<DrmMetricValue::doubleValue>(1.2f)}},
{"variance",
{DrmMetricValue::make<DrmMetricValue::doubleValue>(0.01)}}}};
// Add a second distribution
distribution = metrics_proto.mutable_engine_metrics()
->mutable_crypto_metrics()
->add_crypto_session_open_time_us();
distribution->set_mean(0.7);
distribution->set_operation_count(1);
distribution->mutable_attributes()->set_error_code(27);
DrmMetric expected_distribution_metric_2 = {
"crypto_session_open_time_us",
{{"error_code", {DrmMetricValue::make<DrmMetricValue::int64Value>(27)}}},
{{"mean", {DrmMetricValue::make<DrmMetricValue::doubleValue>(0.7f)}},
{"count", {DrmMetricValue::make<DrmMetricValue::int64Value>(1)}}}};
std::vector<DrmMetricGroup> metrics;
WvMetricsAdapter::ToWvMetrics(metrics_proto, &metrics);
ASSERT_EQ(1U, metrics.size());
ASSERT_EQ(8U, metrics[0].metrics.size()) << ToString(metrics);
EXPECT_TRUE(HasMetric(expected_value_metric_1, metrics[0]))
<< "Missing value_metric_1. " << ToString(expected_value_metric_1)
<< std::endl
<< "In metrics: " << ToString(metrics);
EXPECT_TRUE(HasMetric(expected_value_metric_2, metrics[0]))
<< "Missing value_metric_2. " << ToString(expected_value_metric_2)
<< std::endl
<< "In metrics: " << ToString(metrics);
EXPECT_TRUE(HasMetric(expected_value_metric_3, metrics[0]))
<< "Missing value_metric_3." << ToString(expected_value_metric_3)
<< std::endl
<< "In metrics: " << ToString(metrics);
EXPECT_TRUE(HasMetric(expected_value_metric_4, metrics[0]))
<< "Missing value_metric_4. " << ToString(expected_value_metric_4)
<< std::endl
<< "In metrics: " << ToString(metrics);
EXPECT_TRUE(HasMetric(expected_counter_metric_1, metrics[0]))
<< "Missing counter_metric_1. " << ToString(expected_counter_metric_1)
<< std::endl
<< "In metrics: " << ToString(metrics);
EXPECT_TRUE(HasMetric(expected_counter_metric_2, metrics[0]))
<< "Missing counter_metric_2. " << ToString(expected_counter_metric_2)
<< std::endl
<< "In metrics: " << ToString(metrics);
EXPECT_TRUE(HasMetric(expected_distribution_metric_1, metrics[0]))
<< "Missing distribution_metric_1. "
<< ToString(expected_distribution_metric_1) << std::endl
<< "In metrics: " << ToString(metrics);
EXPECT_TRUE(HasMetric(expected_distribution_metric_2, metrics[0]))
<< "Missing distribution_metric_2. "
<< ToString(expected_distribution_metric_2) << std::endl
<< "In metrics: " << ToString(metrics);
}
// Add a single metric with all attributes to confirm that all attributes
// can be converted.
TEST(HalMetricsAdapterTest, AddAllAttrbitues) {
// Create a test attribute proto with all attributes set.
drm_metrics::WvCdmMetrics metrics_proto;
CounterMetric *counter = metrics_proto.mutable_engine_metrics()
->mutable_crypto_metrics()
->add_crypto_session_get_token();
counter->set_count(13);
drm_metrics::Attributes *attributes = counter->mutable_attributes();
attributes->set_error_code(17);
attributes->set_error_code_bool(true);
attributes->set_cdm_security_level(19);
attributes->set_security_level(23);
attributes->set_length(29);
attributes->set_encryption_algorithm(31);
attributes->set_signing_algorithm(37);
attributes->set_oem_crypto_result(41);
attributes->set_key_status_type(43);
attributes->set_event_type(47);
attributes->set_key_request_type(53);
attributes->set_license_type(59);
DrmMetric expected_counter_metric = {
"crypto_session_get_token",
{{"error_code", {DrmMetricValue::make<DrmMetricValue::int64Value>(17)}},
{"error_code_bool",
{DrmMetricValue::make<DrmMetricValue::int64Value>(true)}},
{"cdm_security_level",
{DrmMetricValue::make<DrmMetricValue::int64Value>(19)}},
{"security_level",
{DrmMetricValue::make<DrmMetricValue::int64Value>(23)}},
{"length", {DrmMetricValue::make<DrmMetricValue::int64Value>(29)}},
{"encryption_algorithm",
{DrmMetricValue::make<DrmMetricValue::int64Value>(31)}},
{"signing_algorithm",
{DrmMetricValue::make<DrmMetricValue::int64Value>(37)}},
{"oem_crypto_result",
{DrmMetricValue::make<DrmMetricValue::int64Value>(41)}},
{"key_status_type",
{DrmMetricValue::make<DrmMetricValue::int64Value>(43)}},
{"event_type", {DrmMetricValue::make<DrmMetricValue::int64Value>(47)}},
{"key_request_type",
{DrmMetricValue::make<DrmMetricValue::int64Value>(53)}},
{"license_type",
{DrmMetricValue::make<DrmMetricValue::int64Value>(59)}}},
{{"count", {DrmMetricValue::make<DrmMetricValue::int64Value>(13)}}}};
// Confirm that all of the attributes exist in the hidl data.
std::vector<DrmMetricGroup> metrics;
WvMetricsAdapter::ToWvMetrics(metrics_proto, &metrics);
EXPECT_TRUE(HasMetric(expected_counter_metric, metrics[0]))
<< "Missing expected_counter_metrc. " << ToString(expected_counter_metric)
<< std::endl
<< "In metrics: " << ToString(metrics);
}
// Add all session and engine metrics to cofirm that all are converted.
// Only check the counts since other tests confirm that metrics are converted
// properly.
TEST(HalMetricsAdapterTest, EngineAndSessionAllMetrics) {
// Set all CryptoSession metrics.
drm_metrics::WvCdmMetrics::CryptoMetrics crypto_metrics;
crypto_metrics.mutable_crypto_session_security_level()->set_int_value(1);
crypto_metrics.add_crypto_session_delete_all_usage_reports()->set_count(13);
crypto_metrics.add_crypto_session_delete_multiple_usage_information()
->set_count(13);
crypto_metrics.add_crypto_session_generic_decrypt_time_us()->set_min(1.0f);
crypto_metrics.add_crypto_session_generic_encrypt_time_us()->set_min(1.0f);
crypto_metrics.add_crypto_session_generic_sign_time_us()->set_min(1.0f);
crypto_metrics.add_crypto_session_generic_verify_time_us()->set_min(1.0f);
crypto_metrics.add_crypto_session_get_device_unique_id()->set_count(13);
crypto_metrics.add_crypto_session_get_token()->set_count(13);
crypto_metrics.mutable_crypto_session_life_span()->set_int_value(1);
crypto_metrics.add_crypto_session_load_certificate_private_key_time_us()
->set_min(1.0f);
crypto_metrics.add_crypto_session_open_time_us()->set_min(1.0f);
crypto_metrics.mutable_crypto_session_system_id()->set_int_value(1);
crypto_metrics.add_crypto_session_update_usage_information_time_us()->set_min(
1.0f);
crypto_metrics.mutable_crypto_session_usage_information_support()
->set_int_value(1);
// Usage Table Metrics
crypto_metrics.mutable_usage_table_header_initial_size()->set_int_value(1);
crypto_metrics.add_usage_table_header_add_entry()->set_count(13);
crypto_metrics.add_usage_table_header_delete_entry()->set_count(13);
crypto_metrics.add_usage_table_header_update_entry_time_us()->set_min(1.0f);
crypto_metrics.add_usage_table_header_load_entry()->set_count(13);
// OemCrypto metrics.
crypto_metrics.mutable_oemcrypto_api_version()->set_int_value(1);
crypto_metrics.add_oemcrypto_close_session()->set_count(13);
crypto_metrics.add_oemcrypto_copy_buffer_time_us()->set_min(1.0f);
crypto_metrics.mutable_oemcrypto_current_hdcp_capability()->set_int_value(1);
crypto_metrics.add_oemcrypto_deactivate_usage_entry()->set_count(13);
crypto_metrics.add_oemcrypto_decrypt_cenc_time_us()->set_min(1.0f);
crypto_metrics.add_oemcrypto_delete_usage_entry()->set_count(13);
crypto_metrics.add_oemcrypto_delete_usage_table()->set_count(13);
crypto_metrics.add_oemcrypto_derive_keys_from_session_key_time_us()->set_min(
1.0f);
crypto_metrics.add_oemcrypto_force_delete_usage_entry()->set_count(13);
crypto_metrics.add_oemcrypto_generate_derived_keys_time_us()->set_min(1.0f);
crypto_metrics.add_oemcrypto_generate_nonce()->set_count(13);
crypto_metrics.add_oemcrypto_generate_rsa_signature_time_us()->set_min(1.0f);
crypto_metrics.add_oemcrypto_generate_signature_time_us()->set_min(1.0f);
crypto_metrics.add_oemcrypto_generic_decrypt_time_us()->set_min(1.0f);
crypto_metrics.add_oemcrypto_generic_encrypt_time_us()->set_min(1.0f);
crypto_metrics.add_oemcrypto_generic_sign_time_us()->set_min(1.0f);
crypto_metrics.add_oemcrypto_generic_verify_time_us()->set_min(1.0f);
crypto_metrics.add_oemcrypto_get_device_id()->set_count(13);
crypto_metrics.add_oemcrypto_get_key_data_time_us()->set_min(1.0f);
crypto_metrics.add_oemcrypto_get_oem_public_certificate()->set_count(13);
crypto_metrics.add_oemcrypto_get_random()->set_count(13);
crypto_metrics.add_oemcrypto_initialize_time_us()->set_min(1.0f);
crypto_metrics.mutable_oemcrypto_is_anti_rollback_hw_present()->set_int_value(
1);
crypto_metrics.mutable_oemcrypto_is_keybox_valid()->set_int_value(1);
crypto_metrics.add_oemcrypto_load_device_drm_key_time_us()->set_min(1.0f);
crypto_metrics.add_oemcrypto_load_entitled_keys_time_us()->set_min(1.0f);
crypto_metrics.add_oemcrypto_load_keys_time_us()->set_min(1.0f);
crypto_metrics.mutable_oemcrypto_max_hdcp_capability()->set_int_value(1);
crypto_metrics.mutable_oemcrypto_max_number_of_sessions()->set_int_value(1);
crypto_metrics.mutable_oemcrypto_number_of_open_sessions()->set_int_value(1);
crypto_metrics.mutable_oemcrypto_provisioning_method()->set_int_value(1);
crypto_metrics.add_oemcrypto_refresh_keys_time_us()->set_min(1.0f);
crypto_metrics.add_oemcrypto_report_usage()->set_count(13);
crypto_metrics.add_oemcrypto_rewrap_device_rsa_key_time_us()->set_min(1.0f);
crypto_metrics.add_oemcrypto_rewrap_device_rsa_key_30_time_us()->set_min(
1.0f);
crypto_metrics.mutable_oemcrypto_security_patch_level()->set_int_value(1);
crypto_metrics.add_oemcrypto_select_key_time_us()->set_min(1.0f);
crypto_metrics.mutable_oemcrypto_usage_table_support()->set_int_value(1);
crypto_metrics.add_oemcrypto_update_usage_table()->set_count(13);
crypto_metrics.add_oemcrypto_update_usage_entry()->set_count(13);
drm_metrics::WvCdmMetrics::SessionMetrics session_metrics;
session_metrics.mutable_session_id()->set_string_value("test");
*(session_metrics.mutable_crypto_metrics()) = crypto_metrics;
session_metrics.mutable_cdm_session_life_span_ms()->set_double_value(1.0f);
session_metrics.add_cdm_session_renew_key_time_us()->set_min(1.0f);
session_metrics.add_cdm_session_restore_offline_session()->set_count(13);
session_metrics.add_cdm_session_restore_usage_session()->set_count(13);
session_metrics.add_cdm_session_license_request_latency_ms()->set_min(1.0);
session_metrics.mutable_oemcrypto_build_info()->set_string_value("test");
session_metrics.mutable_license_sdk_version()->set_string_value("test sdk");
session_metrics.mutable_license_service_version()->set_string_value(
"test service");
drm_metrics::WvCdmMetrics::EngineMetrics engine_metrics;
*(engine_metrics.mutable_crypto_metrics()) = crypto_metrics;
// OEMCrypto Initialize Metrics.
engine_metrics.mutable_level3_oemcrypto_initialization_error()->set_int_value(
1);
engine_metrics.mutable_oemcrypto_initialization_mode()->set_int_value(1);
engine_metrics.mutable_previous_oemcrypto_initialization_failure()
->set_int_value(1);
engine_metrics.mutable_oemcrypto_l1_api_version()->set_int_value(1);
engine_metrics.mutable_oemcrypto_l1_min_api_version()->set_int_value(1);
// CdmEngine Metrics.
engine_metrics.mutable_app_package_name()->set_int_value(1);
engine_metrics.add_cdm_engine_add_key_time_us()->set_min(1.0f);
engine_metrics.mutable_cdm_engine_cdm_version()->set_int_value(1);
engine_metrics.add_cdm_engine_close_session()->set_count(13);
engine_metrics.mutable_cdm_engine_creation_time_millis()->set_int_value(1);
engine_metrics.add_cdm_engine_decrypt_time_us()->set_min(1.0f);
engine_metrics.add_cdm_engine_find_session_for_key()->set_count(13);
engine_metrics.add_cdm_engine_generate_key_request_time_us()->set_min(1.0f);
engine_metrics.add_cdm_engine_get_provisioning_request_time_us()->set_min(
1.0f);
engine_metrics.add_cdm_engine_get_secure_stop_ids()->set_count(13);
engine_metrics.add_cdm_engine_get_usage_info_time_us()->set_min(1.0f);
engine_metrics.add_cdm_engine_handle_provisioning_response_time_us()->set_min(
1.0f);
engine_metrics.mutable_cdm_engine_life_span_ms()->set_int_value(1);
engine_metrics.add_cdm_engine_open_key_set_session()->set_count(13);
engine_metrics.add_cdm_engine_open_session()->set_count(13);
engine_metrics.add_cdm_engine_query_key_status_time_us()->set_min(1.0f);
engine_metrics.add_cdm_engine_release_all_usage_info()->set_count(13);
engine_metrics.add_cdm_engine_release_usage_info()->set_count(13);
engine_metrics.add_cdm_engine_remove_all_usage_info()->set_count(13);
engine_metrics.add_cdm_engine_remove_keys()->set_count(13);
engine_metrics.add_cdm_engine_remove_usage_info()->set_count(13);
engine_metrics.add_cdm_engine_restore_key_time_us()->set_min(1.0f);
engine_metrics.add_cdm_engine_unprovision()->set_count(13);
drm_metrics::WvCdmMetrics metrics_proto;
*(metrics_proto.add_session_metrics()) = session_metrics;
*(metrics_proto.mutable_engine_metrics()) = engine_metrics;
std::vector<DrmMetricGroup> metrics;
WvMetricsAdapter::ToWvMetrics(metrics_proto, &metrics);
ASSERT_EQ(2U, metrics.size());
EXPECT_EQ(89U, metrics[0].metrics.size()) << ToString(metrics);
EXPECT_EQ(70U, metrics[1].metrics.size()) << ToString(metrics);
}
} // namespace wvcdm

View File

@@ -28,7 +28,7 @@ WIDEVINE_TEST_MAKE_TARGETS += \
file_store_unittest \
file_utils_unittest \
generic_crypto_unittest \
hidl_metrics_adapter_unittest \
hal_metrics_adapter_unittest \
http_socket_test \
initialization_data_unittest \
keybox_ota_test \