Ran clang-format on the metrics directory.

[ Merge of http://go/wvgerrit/137809 ]

Bug: 204946540
Test: Metric unit tests
Change-Id: Ibd68db73ea9ee64664d33c2cb8e8bb7c56674c27
This commit is contained in:
Alex Dale
2021-11-03 17:24:34 -07:00
parent 2046fc05fa
commit 21a021e800
16 changed files with 431 additions and 441 deletions

View File

@@ -99,14 +99,13 @@ class CounterMetric : public BaseCounterMetric {
void Increment(int64_t value, F1 field1 = util::Unused(),
F2 field2 = util::Unused(), F3 field3 = util::Unused(),
F4 field4 = util::Unused()) {
std::string key =
attribute_handler_.GetSerializedAttributes(field1, field2,
field3, field4);
std::string key = attribute_handler_.GetSerializedAttributes(
field1, field2, field3, field4);
BaseCounterMetric::Increment(key, value);
}
void ToProto(::google::protobuf::RepeatedPtrField<drm_metrics::CounterMetric>
*counters) const;
void ToProto(::google::protobuf::RepeatedPtrField<drm_metrics::CounterMetric>*
counters) const;
private:
friend class CounterMetricTest;
@@ -120,9 +119,8 @@ class CounterMetric : public BaseCounterMetric {
template <>
inline void CounterMetric<0, util::Unused, 0, util::Unused, 0, util::Unused, 0,
util::Unused>::
ToProto(::google::protobuf::RepeatedPtrField<drm_metrics::CounterMetric>
*counters) const {
ToProto(::google::protobuf::RepeatedPtrField<drm_metrics::CounterMetric>*
counters) const {
const std::map<std::string, int64_t>* values = GetValues();
for (std::map<std::string, int64_t>::const_iterator it = values->begin();
it != values->end(); it++) {
@@ -134,8 +132,8 @@ inline void CounterMetric<0, util::Unused, 0, util::Unused, 0, util::Unused, 0,
template <int I1, typename F1, int I2, typename F2, int I3, typename F3, int I4,
typename F4>
inline void CounterMetric<I1, F1, I2, F2, I3, F3, I4, F4>::ToProto(
::google::protobuf::RepeatedPtrField<drm_metrics::CounterMetric>
*counters) const {
::google::protobuf::RepeatedPtrField<drm_metrics::CounterMetric>* counters)
const {
const std::map<std::string, int64_t>* values = GetValues();
for (std::map<std::string, int64_t>::const_iterator it = values->begin();
it != values->end(); it++) {

View File

@@ -97,9 +97,8 @@ class EventMetric : public BaseEventMetric {
void Record(double value, F1 field1 = util::Unused(),
F2 field2 = util::Unused(), F3 field3 = util::Unused(),
F4 field4 = util::Unused()) {
std::string key =
attribute_handler_.GetSerializedAttributes(field1, field2,
field3, field4);
std::string key = attribute_handler_.GetSerializedAttributes(
field1, field2, field3, field4);
BaseEventMetric::Record(key, value);
}
@@ -108,8 +107,8 @@ class EventMetric : public BaseEventMetric {
};
void ToProto(
::google::protobuf::RepeatedPtrField<drm_metrics::DistributionMetric>
*distributions_proto) const;
::google::protobuf::RepeatedPtrField<drm_metrics::DistributionMetric>*
distributions_proto) const;
private:
friend class EventMetricTest;
@@ -138,12 +137,13 @@ template <>
inline void EventMetric<0, util::Unused, 0, util::Unused, 0, util::Unused, 0,
util::Unused>::
ToProto(
::google::protobuf::RepeatedPtrField<drm_metrics::DistributionMetric>
*distributions_proto) const {
const std::map<std::string, Distribution *>* distributions
= GetDistributions();
::google::protobuf::RepeatedPtrField<drm_metrics::DistributionMetric>*
distributions_proto) const {
const std::map<std::string, Distribution*>* distributions =
GetDistributions();
for (std::map<std::string, Distribution*>::const_iterator it =
distributions->begin(); it != distributions->end(); it++) {
distributions->begin();
it != distributions->end(); it++) {
drm_metrics::DistributionMetric* new_metric = distributions_proto->Add();
SetDistributionValues(*it->second, new_metric);
}
@@ -152,12 +152,13 @@ inline void EventMetric<0, util::Unused, 0, util::Unused, 0, util::Unused, 0,
template <int I1, typename F1, int I2, typename F2, int I3, typename F3, int I4,
typename F4>
inline void EventMetric<I1, F1, I2, F2, I3, F3, I4, F4>::ToProto(
::google::protobuf::RepeatedPtrField<drm_metrics::DistributionMetric>
*distributions_proto) const {
const std::map<std::string, Distribution *>* distributions
= GetDistributions();
::google::protobuf::RepeatedPtrField<drm_metrics::DistributionMetric>*
distributions_proto) const {
const std::map<std::string, Distribution*>* distributions =
GetDistributions();
for (std::map<std::string, Distribution*>::const_iterator it =
distributions->begin(); it != distributions->end(); it++) {
distributions->begin();
it != distributions->end(); it++) {
drm_metrics::DistributionMetric* new_metric = distributions_proto->Add();
if (!new_metric->mutable_attributes()->ParseFromString(it->first)) {
LOGE("Failed to parse the attributes from a string.");

View File

@@ -73,8 +73,7 @@ const int kCdmSecurityLevelFieldNumber =
::drm_metrics::Attributes::kCdmSecurityLevelFieldNumber;
const int kSecurityLevelFieldNumber =
::drm_metrics::Attributes::kSecurityLevelFieldNumber;
const int kLengthFieldNumber =
::drm_metrics::Attributes::kLengthFieldNumber;
const int kLengthFieldNumber = ::drm_metrics::Attributes::kLengthFieldNumber;
const int kEncryptAlgorithmFieldNumber =
::drm_metrics::Attributes::kEncryptionAlgorithmFieldNumber;
const int kSigningAlgorithmFieldNumber =
@@ -125,8 +124,8 @@ typedef enum OEMCryptoInitializationMode {
// This class contains metrics for Crypto Session and OEM Crypto.
class CryptoMetrics {
public:
void Serialize(drm_metrics::WvCdmMetrics::CryptoMetrics *crypto_metrics)
const;
void Serialize(
drm_metrics::WvCdmMetrics::CryptoMetrics* crypto_metrics) const;
/* CRYPTO SESSION */
// TODO(blueeyes): Convert this to crypto_session_default_security_level_.
@@ -325,11 +324,11 @@ class SessionMetrics {
// Metrics collected at the session level.
ValueMetric<double> cdm_session_life_span_; // Milliseconds.
EventMetric<kErrorCodeFieldNumber, CdmResponseType> cdm_session_renew_key_;
CounterMetric<kErrorCodeFieldNumber, CdmResponseType,
kErrorDetailFieldNumber, int32_t>
CounterMetric<kErrorCodeFieldNumber, CdmResponseType, kErrorDetailFieldNumber,
int32_t>
cdm_session_restore_offline_session_;
CounterMetric<kErrorCodeFieldNumber, CdmResponseType,
kErrorDetailFieldNumber, int32_t>
CounterMetric<kErrorCodeFieldNumber, CdmResponseType, kErrorDetailFieldNumber,
int32_t>
cdm_session_restore_usage_session_;
EventMetric<kKeyRequestTypeFieldNumber, CdmKeyRequestType>
@@ -342,8 +341,8 @@ class SessionMetrics {
// Serialize the session metrics to the provided |metric_group|.
// |metric_group| is owned by the caller and must not be null.
void Serialize(drm_metrics::WvCdmMetrics::SessionMetrics *session_metrics)
const;
void Serialize(
drm_metrics::WvCdmMetrics::SessionMetrics* session_metrics) const;
private:
void SerializeSessionMetrics(
@@ -375,8 +374,8 @@ class OemCryptoDynamicAdapterMetrics {
// Serialize the session metrics to the provided |metric_group|.
// |metric_group| is owned by the caller and must not be null.
void Serialize(drm_metrics::WvCdmMetrics::EngineMetrics *engine_metrics)
const;
void Serialize(
drm_metrics::WvCdmMetrics::EngineMetrics* engine_metrics) const;
// Clears the existing metric values.
void Clear();
@@ -438,8 +437,9 @@ class EngineMetrics {
void SetAppPackageName(const std::string& app_package_name);
// Metrics recorded at the engine level.
EventMetric<kErrorCodeFieldNumber, CdmResponseType,
kLicenseTypeFieldNumber, CdmLicenseType> cdm_engine_add_key_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType, kLicenseTypeFieldNumber,
CdmLicenseType>
cdm_engine_add_key_;
ValueMetric<std::string> cdm_engine_cdm_version_;
CounterMetric<kErrorCodeFieldNumber, CdmResponseType>
cdm_engine_close_session_;
@@ -449,15 +449,15 @@ class EngineMetrics {
cdm_engine_decrypt_;
CounterMetric<kErrorCodeBoolFieldNumber, bool>
cdm_engine_find_session_for_key_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType,
kLicenseTypeFieldNumber, CdmLicenseType>
EventMetric<kErrorCodeFieldNumber, CdmResponseType, kLicenseTypeFieldNumber,
CdmLicenseType>
cdm_engine_generate_key_request_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType>
cdm_engine_get_provisioning_request_;
CounterMetric<kErrorCodeFieldNumber, CdmResponseType>
cdm_engine_get_secure_stop_ids_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType,
kErrorDetailFieldNumber, int32_t>
EventMetric<kErrorCodeFieldNumber, CdmResponseType, kErrorDetailFieldNumber,
int32_t>
cdm_engine_get_usage_info_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType>
cdm_engine_handle_provisioning_response_;

View File

@@ -82,16 +82,14 @@ void SetAttributeField<drm_metrics::Attributes::kKeyRequestTypeFieldNumber,
template <>
void SetAttributeField<drm_metrics::Attributes::kLicenseTypeFieldNumber,
CdmLicenseType>(
const CdmLicenseType &license_type,
CdmLicenseType>(const CdmLicenseType& license_type,
drm_metrics::Attributes* attributes) {
attributes->set_license_type(license_type);
}
template <>
void SetAttributeField<drm_metrics::Attributes::kErrorDetailFieldNumber,
int32_t>(
const int32_t &error_detail,
int32_t>(const int32_t& error_detail,
drm_metrics::Attributes* attributes) {
attributes->set_error_detail(error_detail);
}

View File

@@ -20,8 +20,8 @@ struct CompareSessionIds {
CompareSessionIds(const wvcdm::CdmSessionId& target) : target_(target){};
bool operator()(const std::shared_ptr<wvcdm::metrics::SessionMetrics> metrics)
const {
bool operator()(
const std::shared_ptr<wvcdm::metrics::SessionMetrics> metrics) const {
return metrics->GetSessionId() == target_;
}
};
@@ -31,8 +31,8 @@ struct CompareSessionIds {
namespace wvcdm {
namespace metrics {
void CryptoMetrics::Serialize(WvCdmMetrics::CryptoMetrics *crypto_metrics)
const {
void CryptoMetrics::Serialize(
WvCdmMetrics::CryptoMetrics* crypto_metrics) const {
/* CRYPTO SESSION */
crypto_metrics->set_allocated_crypto_session_security_level(
crypto_session_security_level_.ToProto());
@@ -182,8 +182,7 @@ void CryptoMetrics::Serialize(WvCdmMetrics::CryptoMetrics *crypto_metrics)
crypto_metrics->mutable_oemcrypto_create_new_usage_entry());
oemcrypto_load_usage_entry_.ToProto(
crypto_metrics->mutable_oemcrypto_load_usage_entry());
oemcrypto_move_entry_.ToProto(
crypto_metrics->mutable_oemcrypto_move_entry());
oemcrypto_move_entry_.ToProto(crypto_metrics->mutable_oemcrypto_move_entry());
oemcrypto_create_old_usage_entry_.ToProto(
crypto_metrics->mutable_oemcrypto_create_old_usage_entry());
oemcrypto_copy_old_usage_entry_.ToProto(
@@ -217,8 +216,8 @@ void CryptoMetrics::Serialize(WvCdmMetrics::CryptoMetrics *crypto_metrics)
SessionMetrics::SessionMetrics() : session_id_(""), completed_(false) {}
void SessionMetrics::Serialize(WvCdmMetrics::SessionMetrics *session_metrics)
const {
void SessionMetrics::Serialize(
WvCdmMetrics::SessionMetrics* session_metrics) const {
SerializeSessionMetrics(session_metrics);
crypto_metrics_.Serialize(session_metrics->mutable_crypto_metrics());
}
@@ -291,11 +290,11 @@ void OemCryptoDynamicAdapterMetrics::Serialize(
std::unique_lock<std::mutex> lock(adapter_lock_);
engine_metrics->set_allocated_level3_oemcrypto_initialization_error(
level3_oemcrypto_initialization_error_.ToProto());
oemcrypto_initialization_mode_.ToProto());
engine_metrics->set_allocated_oemcrypto_initialization_mode(
oemcrypto_initialization_mode_.ToProto());
engine_metrics->set_allocated_previous_oemcrypto_initialization_failure(
previous_oemcrypto_initialization_failure_.ToProto());
oemcrypto_initialization_mode_.ToProto());
engine_metrics->set_allocated_oemcrypto_l1_api_version(
oemcrypto_l1_api_version_.ToProto());
engine_metrics->set_allocated_oemcrypto_l1_min_api_version(
@@ -322,14 +321,12 @@ OemCryptoDynamicAdapterMetrics &GetDynamicAdapterMetricsInstance() {
return *adapter_metrics;
}
EngineMetrics::EngineMetrics() {
life_span_internal_.Start();
}
EngineMetrics::EngineMetrics() { life_span_internal_.Start(); }
EngineMetrics::~EngineMetrics() {
std::unique_lock<std::mutex> lock(session_metrics_lock_);
if (!active_session_metrics_list_.empty()
|| !completed_session_metrics_list_.empty()) {
if (!active_session_metrics_list_.empty() ||
!completed_session_metrics_list_.empty()) {
LOGV("Session counts: active = %zu, completed = %zu.",
active_session_metrics_list_.size(),
completed_session_metrics_list_.size());
@@ -363,14 +360,12 @@ void EngineMetrics::ConsolidateSessions() {
};
std::unique_lock<std::mutex> lock(session_metrics_lock_);
std::copy_if(active_session_metrics_list_.begin(),
active_session_metrics_list_.end(),
std::back_inserter(completed_session_metrics_list_),
completed_filter);
std::copy_if(
active_session_metrics_list_.begin(), active_session_metrics_list_.end(),
std::back_inserter(completed_session_metrics_list_), completed_filter);
active_session_metrics_list_.erase(
std::remove_if(active_session_metrics_list_.begin(),
active_session_metrics_list_.end(),
completed_filter),
active_session_metrics_list_.end(), completed_filter),
active_session_metrics_list_.end());
// TODO(b/118664842): Add support to merge older metrics into one

View File

@@ -8,9 +8,7 @@ void TimerMetric::Start() {
is_started_ = true;
}
void TimerMetric::Clear() {
is_started_ = false;
}
void TimerMetric::Clear() { is_started_ = false; }
double TimerMetric::AsMs() const {
return (clock_.now() - start_) / std::chrono::milliseconds(1);

View File

@@ -18,14 +18,12 @@ namespace metrics {
namespace impl {
template <>
void SetValue<int>(drm_metrics::ValueMetric *value_proto,
const int &value) {
void SetValue<int>(drm_metrics::ValueMetric* value_proto, const int& value) {
value_proto->set_int_value(value);
}
template <>
void SetValue<long>(drm_metrics::ValueMetric *value_proto,
const long &value) {
void SetValue<long>(drm_metrics::ValueMetric* value_proto, const long& value) {
value_proto->set_int_value(value);
}
@@ -60,8 +58,7 @@ void SetValue<unsigned long long>(drm_metrics::ValueMetric *value_proto,
}
template <>
void SetValue<bool>(drm_metrics::ValueMetric *value_proto,
const bool &value) {
void SetValue<bool>(drm_metrics::ValueMetric* value_proto, const bool& value) {
value_proto->set_int_value(value);
}

View File

@@ -43,7 +43,8 @@ TEST(CounterMetricTest, NoFieldsSuccess) {
TEST(CounterMetricTest, OneFieldSuccess) {
wvcdm::metrics::CounterMetric<drm_metrics::Attributes::kErrorCodeFieldNumber,
int> metric;
int>
metric;
metric.Increment(7);
metric.Increment(10, 7);
metric.Increment(13);
@@ -61,7 +62,8 @@ TEST(CounterMetricTest, OneFieldSuccess) {
TEST(CounterMetricTest, TwoFieldsSuccess) {
CounterMetric<drm_metrics::Attributes::kErrorCodeFieldNumber, int,
drm_metrics::Attributes::kLengthFieldNumber, Pow2Bucket> metric;
drm_metrics::Attributes::kLengthFieldNumber, Pow2Bucket>
metric;
metric.Increment(7, Pow2Bucket(23)); // Increment by one.
metric.Increment(2, 7, Pow2Bucket(33));
@@ -110,7 +112,8 @@ TEST(CounterMetricTest, FourFieldsSuccess) {
drm_metrics::Attributes::kLengthFieldNumber, Pow2Bucket,
drm_metrics::Attributes::kErrorCodeBoolFieldNumber, bool,
drm_metrics::Attributes::kSecurityLevelFieldNumber,
SecurityLevel> metric;
SecurityLevel>
metric;
metric.Increment(10LL, 7, Pow2Bucket(13), true, kLevel3);
TestMetrics metric_proto;

View File

@@ -44,4 +44,3 @@ TEST(DistributionTest, MultipleValuesRecorded) {
} // namespace metrics
} // namespace wvcdm

View File

@@ -71,7 +71,8 @@ TEST_F(EventMetricTest, OneFieldSuccess) {
TEST_F(EventMetricTest, TwoFieldsSuccess) {
EventMetric<drm_metrics::Attributes::kErrorCodeFieldNumber, int,
drm_metrics::Attributes::kLengthFieldNumber, Pow2Bucket> metric;
drm_metrics::Attributes::kLengthFieldNumber, Pow2Bucket>
metric;
metric.Record(1, 7, Pow2Bucket(23));
metric.Record(2, 7, Pow2Bucket(33));
@@ -114,7 +115,8 @@ TEST_F(EventMetricTest, TwoFieldsSuccess) {
TEST_F(EventMetricTest, ThreeFieldsSuccess) {
EventMetric<drm_metrics::Attributes::kErrorCodeFieldNumber, int,
drm_metrics::Attributes::kLengthFieldNumber, Pow2Bucket,
drm_metrics::Attributes::kErrorCodeBoolFieldNumber, bool> metric;
drm_metrics::Attributes::kErrorCodeBoolFieldNumber, bool>
metric;
metric.Record(10LL, 7, Pow2Bucket(13), false);
metric.Record(11LL, 8, Pow2Bucket(17), true);
@@ -127,14 +129,16 @@ TEST_F(EventMetricTest, ThreeFieldsSuccess) {
EXPECT_FALSE(metric_proto.test_distributions(0).has_variance());
EXPECT_EQ(7, metric_proto.test_distributions(0).attributes().error_code());
EXPECT_EQ(8u, metric_proto.test_distributions(0).attributes().length());
EXPECT_FALSE(metric_proto.test_distributions(0).attributes().error_code_bool());
EXPECT_FALSE(
metric_proto.test_distributions(0).attributes().error_code_bool());
EXPECT_EQ(1u, metric_proto.test_distributions(1).operation_count());
EXPECT_EQ(11LL, metric_proto.test_distributions(1).mean());
EXPECT_FALSE(metric_proto.test_distributions(1).has_variance());
EXPECT_EQ(8, metric_proto.test_distributions(1).attributes().error_code());
EXPECT_EQ(16u, metric_proto.test_distributions(1).attributes().length());
EXPECT_TRUE(metric_proto.test_distributions(1).attributes().error_code_bool());
EXPECT_TRUE(
metric_proto.test_distributions(1).attributes().error_code_bool());
}
TEST_F(EventMetricTest, FourFieldsSuccess) {
@@ -142,7 +146,8 @@ TEST_F(EventMetricTest, FourFieldsSuccess) {
drm_metrics::Attributes::kLengthFieldNumber, Pow2Bucket,
drm_metrics::Attributes::kErrorCodeBoolFieldNumber, bool,
drm_metrics::Attributes::kCdmSecurityLevelFieldNumber,
CdmSecurityLevel> metric;
CdmSecurityLevel>
metric;
metric.Record(10LL, 7, Pow2Bucket(13), true, kSecurityLevelL3);
@@ -155,7 +160,8 @@ TEST_F(EventMetricTest, FourFieldsSuccess) {
EXPECT_FALSE(metric_proto.test_distributions(0).has_variance());
EXPECT_EQ(7, metric_proto.test_distributions(0).attributes().error_code());
EXPECT_EQ(8u, metric_proto.test_distributions(0).attributes().length());
EXPECT_TRUE(metric_proto.test_distributions(0).attributes().error_code_bool());
EXPECT_TRUE(
metric_proto.test_distributions(0).attributes().error_code_bool());
EXPECT_EQ(
3u, metric_proto.test_distributions(0).attributes().cdm_security_level());
}

View File

@@ -22,8 +22,7 @@ namespace metrics {
// TODO(blueeyes): Improve this implementation by supporting full message
// API In CDM. That allows us to use MessageDifferencer.
class EngineMetricsTest : public ::testing::Test {
};
class EngineMetricsTest : public ::testing::Test {};
TEST_F(EngineMetricsTest, AllEngineMetrics) {
EngineMetrics engine_metrics;
@@ -45,7 +44,8 @@ TEST_F(EngineMetricsTest, AllEngineMetrics) {
engine_metrics.cdm_engine_release_usage_info_.Record(1.0, NO_ERROR);
engine_metrics.cdm_engine_remove_keys_.Record(1.0, NO_ERROR);
engine_metrics.cdm_engine_restore_key_.Record(1.0, NO_ERROR);
engine_metrics.cdm_engine_unprovision_.Record(1.0, NO_ERROR, kSecurityLevelL1);
engine_metrics.cdm_engine_unprovision_.Record(1.0, NO_ERROR,
kSecurityLevelL1);
drm_metrics::MetricsGroup actual_metrics;
engine_metrics.Serialize(&actual_metrics, true, false);
@@ -73,10 +73,9 @@ TEST_F(EngineMetricsTest, EngineAndCryptoMetrics) {
engine_metrics.cdm_engine_close_session_.Record(1.0, NO_ERROR);
CryptoMetrics* crypto_metrics = engine_metrics.GetCryptoMetrics();
crypto_metrics->crypto_session_generic_decrypt_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
crypto_metrics->crypto_session_get_device_unique_id_
.Record(4.0, false);
crypto_metrics->crypto_session_generic_decrypt_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
crypto_metrics->crypto_session_get_device_unique_id_.Record(4.0, false);
drm_metrics::MetricsGroup actual_metrics;
engine_metrics.Serialize(&actual_metrics, true, false);
@@ -124,8 +123,8 @@ TEST_F(EngineMetricsTest, EngineMetricsWithCompletedSessions) {
SessionMetrics* session_metrics_2 = engine_metrics.AddSession();
session_metrics_2->SetSessionId("session_id_2");
// Record a CryptoMetrics metric in the session.
session_metrics_2->GetCryptoMetrics()->crypto_session_generic_decrypt_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
session_metrics_2->GetCryptoMetrics()->crypto_session_generic_decrypt_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
session_metrics_2->SetSessionId("session_id_2");
// Mark only session 2 as completed.
session_metrics_2->SetCompleted();
@@ -144,7 +143,8 @@ TEST_F(EngineMetricsTest, EngineMetricsWithCompletedSessions) {
// Spot check some metrics.
EXPECT_EQ("/drm/widevine/cdm_engine/add_key/time/count{error:2}",
actual_metrics.metric(0).name());
EXPECT_EQ("/drm/widevine/crypto_session/load_certificate_private_key"
EXPECT_EQ(
"/drm/widevine/crypto_session/load_certificate_private_key"
"/time/count{success:1}",
actual_metrics.metric(2).name());
EXPECT_EQ("/drm/widevine/cdm_session/session_id",
@@ -241,8 +241,7 @@ TEST_F(EngineMetricsTest, EngineMetricsRemoveSessions) {
ASSERT_EQ(0, actual_metrics.metric_sub_group_size());
}
class SessionMetricsTest : public ::testing::Test {
};
class SessionMetricsTest : public ::testing::Test {};
TEST_F(SessionMetricsTest, AllSessionMetrics) {
SessionMetrics session_metrics;
@@ -254,8 +253,8 @@ TEST_F(SessionMetricsTest, AllSessionMetrics) {
session_metrics.cdm_session_restore_usage_session_.Record(1.0, NO_ERROR);
// Record a CryptoMetrics metric in the session.
session_metrics.GetCryptoMetrics()->crypto_session_generic_decrypt_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
session_metrics.GetCryptoMetrics()->crypto_session_generic_decrypt_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
MetricsGroup actual_metrics;
session_metrics.Serialize(&actual_metrics);
@@ -271,7 +270,8 @@ TEST_F(SessionMetricsTest, AllSessionMetrics) {
EXPECT_EQ("/drm/widevine/cdm_session/renew_key/time/mean{error:0}",
actual_metrics.metric(4).name());
EXPECT_EQ(1.0, actual_metrics.metric(4).value().double_value());
EXPECT_EQ("/drm/widevine/crypto_session/generic_decrypt/time/count"
EXPECT_EQ(
"/drm/widevine/crypto_session/generic_decrypt/time/count"
"{error:0&length:1024&encryption_algorithm:1}",
actual_metrics.metric(9).name());
}
@@ -290,134 +290,126 @@ TEST_F(SessionMetricsTest, EmptySessionMetrics) {
EXPECT_EQ(0, actual_metrics.metric_sub_group_size());
}
class CryptoMetricsTest : public ::testing::Test {
};
class CryptoMetricsTest : public ::testing::Test {};
TEST_F(CryptoMetricsTest, AllCryptoMetrics) {
CryptoMetrics crypto_metrics;
// Crypto session metrics.
crypto_metrics.crypto_session_delete_all_usage_reports_
.Record(1.0, NO_ERROR);
crypto_metrics.crypto_session_delete_multiple_usage_information_
.Record(1.0, NO_ERROR);
crypto_metrics.crypto_session_generic_decrypt_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
crypto_metrics.crypto_session_generic_encrypt_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
crypto_metrics.crypto_session_generic_sign_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256);
crypto_metrics.crypto_session_generic_verify_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256);
crypto_metrics.crypto_session_delete_all_usage_reports_.Record(1.0, NO_ERROR);
crypto_metrics.crypto_session_delete_multiple_usage_information_.Record(
1.0, NO_ERROR);
crypto_metrics.crypto_session_generic_decrypt_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
crypto_metrics.crypto_session_generic_encrypt_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
crypto_metrics.crypto_session_generic_sign_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256);
crypto_metrics.crypto_session_generic_verify_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256);
crypto_metrics.crypto_session_get_device_unique_id_.Record(1.0, true);
crypto_metrics.crypto_session_get_security_level_
.Record(1.0, kSecurityLevelL1);
crypto_metrics.crypto_session_get_security_level_.Record(1.0,
kSecurityLevelL1);
crypto_metrics.crypto_session_get_system_id_.Record(1.0, true, 1234);
crypto_metrics.crypto_session_get_token_.Record(1.0, true);
crypto_metrics.crypto_session_life_span_.Record(1.0);
crypto_metrics.crypto_session_load_certificate_private_key_
.Record(1.0, true);
crypto_metrics.crypto_session_load_certificate_private_key_.Record(1.0, true);
crypto_metrics.crypto_session_open_.Record(1.0, NO_ERROR, kLevelDefault);
crypto_metrics.crypto_session_update_usage_information_
.Record(1.0, NO_ERROR);
crypto_metrics.crypto_session_update_usage_information_.Record(1.0, NO_ERROR);
crypto_metrics.crypto_session_usage_information_support_.Record(1.0, true);
// Oem crypto metrics.
crypto_metrics.oemcrypto_api_version_.Record(1.0, 123, kLevelDefault);
crypto_metrics.oemcrypto_close_session_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_copy_buffer_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED,
crypto_metrics.oemcrypto_close_session_.Record(1.0,
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_copy_buffer_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED,
kLevelDefault, Pow2Bucket(1025));
crypto_metrics.oemcrypto_deactivate_usage_entry_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_decrypt_cenc_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_delete_usage_entry_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_delete_usage_table_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_derive_keys_from_session_key_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_force_delete_usage_entry_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_generate_derived_keys_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_generate_nonce_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_generate_rsa_signature_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generate_signature_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_decrypt_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_encrypt_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_sign_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_verify_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_get_device_id_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_get_hdcp_capability_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_get_key_data_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED,
Pow2Bucket(1025), kLevelDefault);
crypto_metrics.oemcrypto_get_max_number_of_sessions_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_get_number_of_open_sessions_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_get_oem_public_certificate_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_deactivate_usage_entry_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_decrypt_cenc_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_delete_usage_entry_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_delete_usage_table_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_derive_keys_from_session_key_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_force_delete_usage_entry_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_generate_derived_keys_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_generate_nonce_.Record(1.0,
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_generate_rsa_signature_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generate_signature_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_decrypt_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_encrypt_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_sign_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_verify_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_get_device_id_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_get_hdcp_capability_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_get_key_data_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025), kLevelDefault);
crypto_metrics.oemcrypto_get_max_number_of_sessions_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_get_number_of_open_sessions_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_get_oem_public_certificate_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_get_provisioning_method_
.Record(1.0, OEMCrypto_Keybox, kLevelDefault);
crypto_metrics.oemcrypto_get_provisioning_method_.Record(
1.0, OEMCrypto_Keybox, kLevelDefault);
crypto_metrics.oemcrypto_get_random_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_initialize_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_install_keybox_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_is_anti_rollback_hw_present_
.Record(1.0, true, kLevelDefault);
crypto_metrics.oemcrypto_get_random_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED,
Pow2Bucket(1025));
crypto_metrics.oemcrypto_initialize_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_install_keybox_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_is_anti_rollback_hw_present_.Record(1.0, true,
kLevelDefault);
crypto_metrics.oemcrypto_is_keybox_valid_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_load_device_rsa_key_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_is_keybox_valid_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_load_device_rsa_key_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_load_keys_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_load_test_keybox_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_load_test_rsa_key_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_open_session_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_refresh_keys_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_report_usage_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_rewrap_device_rsa_key_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_rewrap_device_rsa_key_30_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_security_level_
.Record(1.0, kSecurityLevelL2, kLevelDefault);
crypto_metrics.oemcrypto_security_patch_level_
.Record(1.0, 123, kLevelDefault);
crypto_metrics.oemcrypto_select_key_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_supports_usage_table_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_update_usage_table_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_wrap_keybox_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_load_test_keybox_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_load_test_rsa_key_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_open_session_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_refresh_keys_.Record(1.0,
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_report_usage_.Record(1.0,
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_rewrap_device_rsa_key_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_rewrap_device_rsa_key_30_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_security_level_.Record(1.0, kSecurityLevelL2,
kLevelDefault);
crypto_metrics.oemcrypto_security_patch_level_.Record(1.0, 123,
kLevelDefault);
crypto_metrics.oemcrypto_select_key_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_supports_usage_table_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault);
crypto_metrics.oemcrypto_update_usage_table_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_wrap_keybox_.Record(1.0,
OEMCrypto_ERROR_INIT_FAILED);
// Internal OEMCrypto Metrics
crypto_metrics.oemcrypto_initialization_mode_
.Record(1.0, OEMCrypto_INITIALIZED_FORCING_L3);
crypto_metrics.oemcrypto_initialization_mode_.Record(
1.0, OEMCrypto_INITIALIZED_FORCING_L3);
crypto_metrics.oemcrypto_l1_api_version_.Record(1.0, 12, 123);
MetricsGroup actual_metrics;

View File

@@ -28,8 +28,7 @@ namespace metrics {
// TODO(blueeyes): Improve this implementation by supporting full message
// API In CDM. That allows us to use MessageDifferencer.
class EngineMetricsTest : public ::testing::Test {
};
class EngineMetricsTest : public ::testing::Test {};
TEST_F(EngineMetricsTest, AllEngineMetrics) {
EngineMetrics engine_metrics;
@@ -78,16 +77,16 @@ TEST_F(EngineMetricsTest, AllEngineMetrics) {
EXPECT_GT(actual.engine_metrics().cdm_engine_decrypt_time_us_size(), 0);
EXPECT_GT(actual.engine_metrics().cdm_engine_find_session_for_key_size(), 0);
EXPECT_GT(
actual.engine_metrics()
.cdm_engine_generate_key_request_time_us_size(), 0);
EXPECT_GT(
actual.engine_metrics()
.cdm_engine_get_provisioning_request_time_us_size(), 0);
actual.engine_metrics().cdm_engine_generate_key_request_time_us_size(),
0);
EXPECT_GT(actual.engine_metrics()
.cdm_engine_get_provisioning_request_time_us_size(),
0);
EXPECT_GT(actual.engine_metrics().cdm_engine_get_usage_info_time_us_size(),
0);
EXPECT_GT(
actual.engine_metrics()
.cdm_engine_handle_provisioning_response_time_us_size(), 0);
EXPECT_GT(actual.engine_metrics()
.cdm_engine_handle_provisioning_response_time_us_size(),
0);
EXPECT_GT(actual.engine_metrics().cdm_engine_open_key_set_session_size(), 0);
EXPECT_GT(actual.engine_metrics().cdm_engine_open_session_size(), 0);
EXPECT_GT(actual.engine_metrics().cdm_engine_query_key_status_time_us_size(),
@@ -105,9 +104,9 @@ TEST_F(EngineMetricsTest, AllEngineMetrics) {
actual.engine_metrics().app_package_name().string_value());
EXPECT_EQ("test cdm version",
actual.engine_metrics().cdm_engine_cdm_version().string_value());
EXPECT_EQ(100,
actual.engine_metrics()
.cdm_engine_creation_time_millis().int_value());
EXPECT_EQ(
100,
actual.engine_metrics().cdm_engine_creation_time_millis().int_value());
}
TEST_F(EngineMetricsTest, EngineAndCryptoMetrics) {
@@ -120,8 +119,8 @@ TEST_F(EngineMetricsTest, EngineAndCryptoMetrics) {
CryptoMetrics* crypto_metrics = engine_metrics.GetCryptoMetrics();
crypto_metrics->crypto_session_get_device_unique_id_.Increment(NO_ERROR);
crypto_metrics->crypto_session_generic_decrypt_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
crypto_metrics->crypto_session_generic_decrypt_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
WvCdmMetrics actual_metrics;
engine_metrics.Serialize(&actual_metrics);
@@ -134,28 +133,37 @@ TEST_F(EngineMetricsTest, EngineAndCryptoMetrics) {
actual_metrics.engine_metrics().cdm_engine_add_key_time_us_size());
EXPECT_EQ(2, actual_metrics.engine_metrics()
.cdm_engine_add_key_time_us(0)
.attributes().error_code());
ASSERT_EQ(1,
actual_metrics.engine_metrics().cdm_engine_close_session_size());
.attributes()
.error_code());
ASSERT_EQ(1, actual_metrics.engine_metrics().cdm_engine_close_session_size());
EXPECT_EQ(UNKNOWN_ERROR, actual_metrics.engine_metrics()
.cdm_engine_close_session(0)
.attributes().error_code());
ASSERT_EQ(1, actual_metrics.engine_metrics().crypto_metrics()
.attributes()
.error_code());
ASSERT_EQ(1, actual_metrics.engine_metrics()
.crypto_metrics()
.crypto_session_get_device_unique_id_size());
EXPECT_EQ(1, actual_metrics.engine_metrics().crypto_metrics()
EXPECT_EQ(1, actual_metrics.engine_metrics()
.crypto_metrics()
.crypto_session_get_device_unique_id(0)
.count());
EXPECT_EQ(NO_ERROR, actual_metrics.engine_metrics().crypto_metrics()
EXPECT_EQ(NO_ERROR, actual_metrics.engine_metrics()
.crypto_metrics()
.crypto_session_get_device_unique_id(0)
.attributes().error_code());
ASSERT_EQ(1, actual_metrics.engine_metrics().crypto_metrics()
.attributes()
.error_code());
ASSERT_EQ(1, actual_metrics.engine_metrics()
.crypto_metrics()
.crypto_session_generic_decrypt_time_us_size());
EXPECT_EQ(2.0, actual_metrics.engine_metrics().crypto_metrics()
EXPECT_EQ(2.0, actual_metrics.engine_metrics()
.crypto_metrics()
.crypto_session_generic_decrypt_time_us(0)
.mean());
EXPECT_EQ(NO_ERROR, actual_metrics.engine_metrics().crypto_metrics()
EXPECT_EQ(NO_ERROR, actual_metrics.engine_metrics()
.crypto_metrics()
.crypto_session_generic_decrypt_time_us(0)
.attributes().error_code());
.attributes()
.error_code());
}
TEST_F(EngineMetricsTest, EmptyEngineMetrics) {
@@ -186,8 +194,8 @@ TEST_F(EngineMetricsTest, EngineMetricsWithSessions) {
engine_metrics.AddSession();
session_metrics_2->SetSessionId(kSessionId2);
// Record a CryptoMetrics metric in the session.
session_metrics_2->GetCryptoMetrics()->crypto_session_generic_decrypt_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
session_metrics_2->GetCryptoMetrics()->crypto_session_generic_decrypt_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
WvCdmMetrics actual_metrics;
engine_metrics.Serialize(&actual_metrics);
@@ -201,7 +209,8 @@ TEST_F(EngineMetricsTest, EngineMetricsWithSessions) {
actual_metrics.session_metrics(0).session_id().string_value());
EXPECT_EQ(kSessionId2,
actual_metrics.session_metrics(1).session_id().string_value());
EXPECT_EQ(1, actual_metrics.session_metrics(1).crypto_metrics()
EXPECT_EQ(1, actual_metrics.session_metrics(1)
.crypto_metrics()
.crypto_session_generic_decrypt_time_us_size());
}
@@ -259,8 +268,7 @@ TEST_F(EngineMetricsTest, EngineMetricsConsolidateSessionsNoSessions) {
ASSERT_EQ(0, actual_metrics.session_metrics_size());
}
class SessionMetricsTest : public ::testing::Test {
};
class SessionMetricsTest : public ::testing::Test {};
TEST_F(SessionMetricsTest, AllSessionMetrics) {
SessionMetrics session_metrics;
@@ -275,12 +283,13 @@ TEST_F(SessionMetricsTest, AllSessionMetrics) {
2.0, kKeyRequestTypeInitial);
session_metrics.oemcrypto_build_info_.Record("test build info");
session_metrics.license_sdk_version_.Record("test license sdk version");
session_metrics.license_service_version_.Record("test license service version");
session_metrics.license_service_version_.Record(
"test license service version");
session_metrics.drm_certificate_key_type_.Record(1);
// Record a CryptoMetrics metric in the session.
session_metrics.GetCryptoMetrics()->crypto_session_generic_decrypt_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
session_metrics.GetCryptoMetrics()->crypto_session_generic_decrypt_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
WvCdmMetrics::SessionMetrics actual;
session_metrics.Serialize(&actual);
@@ -315,32 +324,30 @@ TEST_F(SessionMetricsTest, EmptySessionMetrics) {
EXPECT_EQ(0, actual_metrics.cdm_session_restore_usage_session_size());
}
class CryptoMetricsTest : public ::testing::Test {
};
class CryptoMetricsTest : public ::testing::Test {};
TEST_F(CryptoMetricsTest, AllCryptoMetrics) {
CryptoMetrics crypto_metrics;
// Crypto session metrics.
crypto_metrics.crypto_session_delete_all_usage_reports_.Increment(NO_ERROR);
crypto_metrics.crypto_session_delete_multiple_usage_information_
.Increment(NO_ERROR);
crypto_metrics.crypto_session_generic_decrypt_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
crypto_metrics.crypto_session_generic_encrypt_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
crypto_metrics.crypto_session_generic_sign_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256);
crypto_metrics.crypto_session_generic_verify_
.Record(2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256);
crypto_metrics.crypto_session_delete_multiple_usage_information_.Increment(
NO_ERROR);
crypto_metrics.crypto_session_generic_decrypt_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
crypto_metrics.crypto_session_generic_encrypt_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128);
crypto_metrics.crypto_session_generic_sign_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256);
crypto_metrics.crypto_session_generic_verify_.Record(
2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256);
crypto_metrics.crypto_session_get_device_unique_id_.Increment(NO_ERROR);
crypto_metrics.crypto_session_get_token_.Increment(NO_ERROR);
crypto_metrics.crypto_session_life_span_.Record(1.0);
crypto_metrics.crypto_session_load_certificate_private_key_
.Record(1.0, NO_ERROR);
crypto_metrics.crypto_session_load_certificate_private_key_.Record(1.0,
NO_ERROR);
crypto_metrics.crypto_session_open_.Record(1.0, NO_ERROR, kLevelDefault);
crypto_metrics.crypto_session_update_usage_information_
.Record(1.0, NO_ERROR);
crypto_metrics.crypto_session_update_usage_information_.Record(1.0, NO_ERROR);
crypto_metrics.crypto_session_usage_information_support_.Record(true);
crypto_metrics.crypto_session_security_level_.Record(kSecurityLevelL2);
@@ -359,87 +366,83 @@ TEST_F(CryptoMetricsTest, AllCryptoMetrics) {
// Oem crypto metrics.
crypto_metrics.oemcrypto_api_version_.Record(123);
crypto_metrics.oemcrypto_close_session_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_copy_buffer_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_deactivate_usage_entry_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_decrypt_cenc_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_delete_usage_entry_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_delete_usage_table_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_derive_keys_from_session_key_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_force_delete_usage_entry_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_generate_derived_keys_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_generate_nonce_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_generate_rsa_signature_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generate_signature_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_decrypt_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_encrypt_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_sign_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_verify_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_get_device_id_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_get_key_data_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_close_session_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_copy_buffer_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED,
Pow2Bucket(1025));
crypto_metrics.oemcrypto_deactivate_usage_entry_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_decrypt_cenc_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_delete_usage_entry_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_delete_usage_table_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_derive_keys_from_session_key_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_force_delete_usage_entry_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_generate_derived_keys_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_generate_nonce_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_generate_rsa_signature_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generate_signature_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_decrypt_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_encrypt_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_sign_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_generic_verify_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_get_device_id_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_get_key_data_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025));
crypto_metrics.oemcrypto_max_number_of_sessions_.Record(7);
crypto_metrics.oemcrypto_number_of_open_sessions_.Record(5);
crypto_metrics.oemcrypto_get_oem_public_certificate_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_get_oem_public_certificate_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_provisioning_method_.Record(OEMCrypto_Keybox);
crypto_metrics.oemcrypto_get_random_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_initialize_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_get_random_.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_initialize_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_is_anti_rollback_hw_present_.Record(true);
crypto_metrics.oemcrypto_is_keybox_valid_.Record(true);
crypto_metrics.oemcrypto_load_device_drm_key_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_load_keys_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_refresh_keys_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_refresh_keys_.Record(1.0,
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_report_usage_.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_rewrap_device_rsa_key_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_rewrap_device_rsa_key_30_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_rewrap_device_rsa_key_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_rewrap_device_rsa_key_30_.Record(
1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_security_patch_level_.Record(123);
crypto_metrics.oemcrypto_select_key_
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_update_usage_table_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_create_usage_table_header_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_load_usage_table_header_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_shrink_usage_table_header_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_create_new_usage_entry_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_load_usage_entry_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_move_entry_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_create_old_usage_entry_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_copy_old_usage_entry_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_select_key_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_update_usage_table_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_create_usage_table_header_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_load_usage_table_header_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_shrink_usage_table_header_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_create_new_usage_entry_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_load_usage_entry_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_move_entry_.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_create_old_usage_entry_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_copy_old_usage_entry_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_set_sandbox_.Record("sandbox");
crypto_metrics.oemcrypto_set_decrypt_hash_
.Increment(OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_set_decrypt_hash_.Increment(
OEMCrypto_ERROR_INIT_FAILED);
crypto_metrics.oemcrypto_resource_rating_tier_.Record(123);
crypto_metrics.oemcrypto_minor_api_version_.Record(234);
crypto_metrics.oemcrypto_maximum_usage_table_header_size_.Record(321);