Updated copyright notice and cleaned up includes.
[ Merge of http://go/wvgerrit/137810 ] Bug: 204946540 Test: Metric unit tests Change-Id: I78f839fafd27604a2bb78c04d587c40919c5372d
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
// Copyright 2018 Google Inc. All Rights Reserved.
|
||||
// Copyright 2018 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 the declarations for the EventMetric class and related
|
||||
// types.
|
||||
#ifndef WVCDM_METRICS_ATTRIBUTE_HANDLER_H_
|
||||
#define WVCDM_METRICS_ATTRIBUTE_HANDLER_H_
|
||||
#include <string>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "field_tuples.h"
|
||||
#include "log.h"
|
||||
#include "pow2bucket.h"
|
||||
#include "value_metric.h"
|
||||
#include "wv_cdm_types.h"
|
||||
#include "wv_metrics.pb.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
// This method is used to set the value of a single proto field.
|
||||
// Specializations handle setting each value.
|
||||
template <int I, typename F>
|
||||
@@ -47,7 +44,6 @@ class AttributeHandler {
|
||||
return serialized_attributes;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
#endif // WVCDM_METRICS_ATTRIBUTE_HANDLER_H_
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 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 the declarations for the Metric class and related
|
||||
// types.
|
||||
#ifndef WVCDM_METRICS_COUNTER_METRIC_H_
|
||||
#define WVCDM_METRICS_COUNTER_METRIC_H_
|
||||
|
||||
#include <cstdarg>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "attribute_handler.h"
|
||||
#include "field_tuples.h"
|
||||
#include "wv_metrics.pb.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
class CounterMetricTest;
|
||||
|
||||
// This base class provides the common defintion used by all templated
|
||||
@@ -144,8 +144,6 @@ inline void CounterMetric<I1, F1, I2, F2, I3, F3, I4, F4>::ToProto(
|
||||
new_counter->set_count(it->second);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_COUNTER_METRIC_H_
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 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 the definition of a Distribution class which computes
|
||||
// the distribution values of a series of samples.
|
||||
@@ -10,7 +12,6 @@
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
// The Distribution class holds statistics about a series of values that the
|
||||
// client provides via the Record method. A caller will call Record once for
|
||||
// each of the values in a series. The Distribution instance will calculate the
|
||||
@@ -46,8 +47,6 @@ class Distribution {
|
||||
float mean_;
|
||||
double sum_squared_deviation_;
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_DISTRIBUTION_H_
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 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 the declarations for the EventMetric class and related
|
||||
// types.
|
||||
#ifndef WVCDM_METRICS_EVENT_METRIC_H_
|
||||
#define WVCDM_METRICS_EVENT_METRIC_H_
|
||||
|
||||
#include <cstdarg>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "attribute_handler.h"
|
||||
#include "distribution.h"
|
||||
#include "field_tuples.h"
|
||||
#include "log.h"
|
||||
#include "pow2bucket.h"
|
||||
#include "wv_metrics.pb.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
class EventMetricTest;
|
||||
|
||||
// This base class provides the common defintion used by all templated
|
||||
@@ -166,8 +164,6 @@ inline void EventMetric<I1, F1, I2, F2, I3, F3, I4, F4>::ToProto(
|
||||
SetDistributionValues(*it->second, new_metric);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_EVENT_METRIC_H_
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 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 the helper classes and methods for using field tuples
|
||||
// used by metrics classes to record variations of a single metric.
|
||||
#ifndef WVCDM_METRICS_FIELD_TUPLES_H_
|
||||
#define WVCDM_METRICS_FIELD_TUPLES_H_
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
namespace util {
|
||||
|
||||
// TODO(blueeyes): Change to use C++ 11 support for variadic template args.
|
||||
// The C++ 03 pattern is no longer needed since we require C++11. b/68766426.
|
||||
|
||||
@@ -23,9 +22,7 @@ struct Unused {
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_FIELD_TUPLES_H_
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
// Copyright 2016 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 definitions for metrics being collected throughout the
|
||||
// CDM.
|
||||
|
||||
#ifndef WVCDM_METRICS_METRICS_GROUP_H_
|
||||
#define WVCDM_METRICS_METRICS_GROUP_H_
|
||||
|
||||
#ifndef WVCDM_METRICS_METRICS_COLLECTIONS_H_
|
||||
#define WVCDM_METRICS_METRICS_COLLECTIONS_H_
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "counter_metric.h"
|
||||
@@ -58,9 +61,7 @@
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
namespace {
|
||||
|
||||
// Short name definitions to ease AttributeHandler definitions.
|
||||
// Internal namespace to help simplify declarations.
|
||||
const int kErrorCodeFieldNumber =
|
||||
@@ -88,8 +89,7 @@ const int kKeyRequestTypeFieldNumber =
|
||||
::drm_metrics::Attributes::kKeyRequestTypeFieldNumber;
|
||||
const int kLicenseTypeFieldNumber =
|
||||
::drm_metrics::Attributes::kLicenseTypeFieldNumber;
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
|
||||
// The maximum number of completed sessions that can be stored. More than this
|
||||
// will cause some metrics to be discarded.
|
||||
@@ -292,7 +292,7 @@ class CryptoMetrics {
|
||||
oemcrypto_load_provisioning_;
|
||||
ValueMetric<uint32_t> oemcrypto_minor_api_version_;
|
||||
ValueMetric<uint32_t> oemcrypto_maximum_usage_table_header_size_;
|
||||
};
|
||||
}; // class CryptoMetrics
|
||||
|
||||
// This class contains session-scoped metrics. All properties and
|
||||
// statistics related to operations within a single session are
|
||||
@@ -350,7 +350,7 @@ class SessionMetrics {
|
||||
CdmSessionId session_id_;
|
||||
bool completed_;
|
||||
CryptoMetrics crypto_metrics_;
|
||||
};
|
||||
}; // class SessionMetrics
|
||||
|
||||
// This class contains metrics for the OEMCrypto Dynamic Adapter. They are
|
||||
// separated from other metrics because they need to be encapsulated in a
|
||||
@@ -389,7 +389,7 @@ class OemCryptoDynamicAdapterMetrics {
|
||||
previous_oemcrypto_initialization_failure_;
|
||||
ValueMetric<uint32_t> oemcrypto_l1_api_version_;
|
||||
ValueMetric<uint32_t> oemcrypto_l1_min_api_version_;
|
||||
};
|
||||
}; // class OemCryptoDynamicAdapterMetrics
|
||||
|
||||
// This will fetch the singleton instance for dynamic adapter metrics.
|
||||
// This method is safe only if we use C++ 11. In C++ 11, static function-local
|
||||
@@ -494,9 +494,7 @@ class EngineMetrics {
|
||||
|
||||
void SerializeEngineMetrics(
|
||||
drm_metrics::WvCdmMetrics::EngineMetrics* engine_metrics) const;
|
||||
};
|
||||
|
||||
}; // class EngineMetrics
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_METRICS_GROUP_H_
|
||||
#endif // WVCDM_METRICS_METRICS_COLLECTIONS_H_
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// Copyright 2018 Google Inc. All Rights Reserved.
|
||||
// Copyright 2018 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 the declaration of the Pow2Bucket class which
|
||||
// is a convenient way to bucketize sampled values into powers of 2.
|
||||
#ifndef WVCDM_METRICS_POW2BUCKET_H_
|
||||
#define WVCDM_METRICS_POW2BUCKET_H_
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
// This class converts the size_t value into the highest power of two
|
||||
// below the value. E.g. for 7, the value is 4. For 11, the value is 8.
|
||||
// This class is intended to simplify the use of EventMetric Fields that may
|
||||
@@ -43,8 +43,6 @@ class Pow2Bucket {
|
||||
|
||||
size_t value_;
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_POW2BUCKET_H_
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
#ifndef WVCDM_METRICS_TIMER_METRIC_H_
|
||||
#define WVCDM_METRICS_TIMER_METRIC_H_
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
class TimerMetric {
|
||||
public:
|
||||
// Constructs a new TimerMetric.
|
||||
@@ -28,7 +29,6 @@ class TimerMetric {
|
||||
std::chrono::time_point<std::chrono::steady_clock> start_;
|
||||
bool is_started_;
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
#endif
|
||||
#endif // WVCDM_METRICS_TIMER_METRIC_H_
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 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 the declarations for the Metric class and related
|
||||
// types.
|
||||
#ifndef WVCDM_METRICS_VALUE_METRIC_H_
|
||||
#define WVCDM_METRICS_VALUE_METRIC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
@@ -13,14 +15,11 @@
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
// Internal namespace for helper methods.
|
||||
namespace impl {
|
||||
|
||||
// Helper function for setting a value in the proto.
|
||||
template <typename T>
|
||||
void SetValue(drm_metrics::ValueMetric* value_proto, const T& value);
|
||||
|
||||
} // namespace impl
|
||||
|
||||
// The ValueMetric class supports storing a single, overwritable value or an
|
||||
@@ -118,9 +117,7 @@ class ValueMetric {
|
||||
* in const methods.
|
||||
*/
|
||||
mutable std::mutex internal_lock_;
|
||||
};
|
||||
|
||||
}; // class ValueMetric
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_VALUE_METRIC_H_
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
// Copyright 2018 Google Inc. All Rights Reserved.
|
||||
// Copyright 2018 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 implementations for the AttributeHandler.
|
||||
|
||||
#include "attribute_handler.h"
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "field_tuples.h"
|
||||
#include "pow2bucket.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
//
|
||||
// Specializations for setting attribute fields.
|
||||
//
|
||||
@@ -106,6 +109,5 @@ void SetAttributeField<drm_metrics::Attributes::kErrorCodeFieldNumber, int>(
|
||||
const int& cdm_error, drm_metrics::Attributes* attributes) {
|
||||
attributes->set_error_code(cdm_error);
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 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 implementations for the BaseCounterMetric, the base class
|
||||
// for CounterMetric.
|
||||
|
||||
#include "counter_metric.h"
|
||||
|
||||
#include "wv_metrics.pb.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
void BaseCounterMetric::Increment(const std::string& counter_key,
|
||||
int64_t value) {
|
||||
std::unique_lock<std::mutex> lock(internal_lock_);
|
||||
@@ -20,6 +19,5 @@ void BaseCounterMetric::Increment(const std::string& counter_key,
|
||||
value_map_[counter_key] = value_map_[counter_key] + value;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 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 the definitions for the Distribution class members.
|
||||
|
||||
@@ -8,7 +10,6 @@
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
Distribution::Distribution()
|
||||
: count_(0ULL),
|
||||
min_(FLT_MAX),
|
||||
@@ -26,6 +27,5 @@ void Distribution::Record(float value) {
|
||||
min_ = min_ < value ? min_ : value;
|
||||
max_ = max_ > value ? max_ : value;
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 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 implementations for the BaseEventMetric.
|
||||
|
||||
#include "event_metric.h"
|
||||
|
||||
using ::google::protobuf::RepeatedPtrField;
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
BaseEventMetric::~BaseEventMetric() {
|
||||
std::unique_lock<std::mutex> lock(internal_lock_);
|
||||
|
||||
for (std::map<std::string, Distribution*>::iterator it = value_map_.begin();
|
||||
it != value_map_.end(); it++) {
|
||||
delete it->second;
|
||||
@@ -20,9 +17,7 @@ BaseEventMetric::~BaseEventMetric() {
|
||||
|
||||
void BaseEventMetric::Record(const std::string& key, double value) {
|
||||
std::unique_lock<std::mutex> lock(internal_lock_);
|
||||
|
||||
Distribution* distribution;
|
||||
|
||||
if (value_map_.find(key) == value_map_.end()) {
|
||||
distribution = new Distribution();
|
||||
value_map_[key] = distribution;
|
||||
@@ -32,6 +27,5 @@ void BaseEventMetric::Record(const std::string& key, double value) {
|
||||
|
||||
distribution->Record(value);
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
|
||||
// Copyright 2016 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
#include "metrics_collections.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -7,13 +8,13 @@
|
||||
#include "log.h"
|
||||
#include "wv_metrics.pb.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
using ::drm_metrics::Attributes;
|
||||
using ::drm_metrics::WvCdmMetrics;
|
||||
using ::google::protobuf::RepeatedPtrField;
|
||||
using ::wvcdm::metrics::EventMetric;
|
||||
|
||||
namespace {
|
||||
|
||||
// Helper struct for comparing session ids.
|
||||
struct CompareSessionIds {
|
||||
const std::string& target_;
|
||||
@@ -25,11 +26,7 @@ struct CompareSessionIds {
|
||||
return metrics->GetSessionId() == target_;
|
||||
}
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
} // namespace
|
||||
|
||||
void CryptoMetrics::Serialize(
|
||||
WvCdmMetrics::CryptoMetrics* crypto_metrics) const {
|
||||
@@ -458,6 +455,5 @@ void EngineMetrics::SerializeEngineMetrics(
|
||||
|
||||
crypto_metrics_.Serialize(engine_metrics->mutable_crypto_metrics());
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
#include "timer_metric.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
void TimerMetric::Start() {
|
||||
start_ = clock_.now();
|
||||
is_started_ = true;
|
||||
@@ -17,6 +19,5 @@ double TimerMetric::AsMs() const {
|
||||
double TimerMetric::AsUs() const {
|
||||
return (clock_.now() - start_) / std::chrono::microseconds(1);
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 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 the specializations for helper methods for the
|
||||
// ValueMetric class.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include "value_metric.h"
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
@@ -14,9 +12,7 @@
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
namespace impl {
|
||||
|
||||
template <>
|
||||
void SetValue<int>(drm_metrics::ValueMetric* value_proto, const int& value) {
|
||||
value_proto->set_int_value(value);
|
||||
@@ -106,7 +102,6 @@ void SetValue<std::string>(drm_metrics::ValueMetric* value_proto,
|
||||
const std::string& value) {
|
||||
value_proto->set_string_value(value);
|
||||
}
|
||||
|
||||
} // namespace impl
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 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 a proto definition for serialization of metrics data.
|
||||
//
|
||||
@@ -15,10 +17,7 @@ option optimize_for = LITE_RUNTIME;
|
||||
// want to count all of the operations with a give error code.
|
||||
message Attributes {
|
||||
// Reserved for compatibility with logging proto.
|
||||
// TODO(blueeyes): The reserved keyword is not supported in the older version
|
||||
// of protoc in the CE CDM third_party directory. Uncomment the reserved
|
||||
// line when we upgrade. b/67016366.
|
||||
// reserved 8, 10 to 13;
|
||||
reserved 8, 10 to 13;
|
||||
|
||||
// The error code. See CdmResponseType in wv_cdm_types.h
|
||||
optional int32 error_code = 1;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// Unit tests for CounterMetric
|
||||
|
||||
#include "counter_metric.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "string_conversions.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using drm_metrics::TestMetrics;
|
||||
using testing::IsNull;
|
||||
using testing::NotNull;
|
||||
#include "pow2bucket.h"
|
||||
#include "string_conversions.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
using drm_metrics::TestMetrics;
|
||||
|
||||
TEST(CounterMetricTest, NoFieldsEmpty) {
|
||||
wvcdm::metrics::CounterMetric<> metric;
|
||||
@@ -126,6 +126,5 @@ TEST(CounterMetricTest, FourFieldsSuccess) {
|
||||
EXPECT_EQ(kLevel3,
|
||||
metric_proto.test_counters(0).attributes().security_level());
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// Unit tests for Distribution.
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include "distribution.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include <float.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
TEST(DistributionTest, NoValuesRecorded) {
|
||||
Distribution distribution;
|
||||
EXPECT_EQ(FLT_MAX, distribution.Min());
|
||||
@@ -41,6 +42,5 @@ TEST(DistributionTest, MultipleValuesRecorded) {
|
||||
EXPECT_EQ(3u, distribution.Count());
|
||||
EXPECT_NEAR(16.6667, distribution.Variance(), 0.0001);
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// Unit tests for EventMetric
|
||||
|
||||
#include "event_metric.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "string_conversions.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using drm_metrics::TestMetrics;
|
||||
using testing::IsNull;
|
||||
using testing::NotNull;
|
||||
#include "string_conversions.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
using drm_metrics::TestMetrics;
|
||||
|
||||
class EventMetricTest : public ::testing::Test {
|
||||
public:
|
||||
@@ -191,6 +190,5 @@ TEST_F(EventMetricTest, Pow2BucketTest) {
|
||||
value << Pow2Bucket(0x7FFFFFFF);
|
||||
EXPECT_EQ("1073741824", value.str());
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// Unit tests for the metrics collections,
|
||||
// EngineMetrics, SessionMetrics and CrytpoMetrics.
|
||||
|
||||
#include "metrics_collections.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "google/protobuf/text_format.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "log.h"
|
||||
#include "wv_cdm_types.h"
|
||||
#include "wv_metrics.pb.h"
|
||||
|
||||
using drm_metrics::MetricsGroup;
|
||||
using google::protobuf::TextFormat;
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
using drm_metrics::MetricsGroup;
|
||||
|
||||
// TODO(blueeyes): Improve this implementation by supporting full message
|
||||
// API In CDM. That allows us to use MessageDifferencer.
|
||||
@@ -432,6 +428,5 @@ TEST_F(CryptoMetricsTest, AllCryptoMetrics) {
|
||||
// No subgroups should exist.
|
||||
EXPECT_EQ(0, actual_metrics.metric_sub_group_size());
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// Unit tests for the metrics collections,
|
||||
// EngineMetrics, SessionMetrics and CryptoMetrics.
|
||||
|
||||
#include "metrics_collections.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "device_files.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "google/protobuf/text_format.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "log.h"
|
||||
#include "string_conversions.h"
|
||||
#include "wv_cdm_types.h"
|
||||
#include "wv_metrics.pb.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
using drm_metrics::WvCdmMetrics;
|
||||
|
||||
namespace {
|
||||
const char kSessionId1[] = "session_id_1";
|
||||
const char kSessionId2[] = "session_id_2";
|
||||
} // anonymous namespace
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
} // namespace
|
||||
|
||||
// TODO(blueeyes): Improve this implementation by supporting full message
|
||||
// API In CDM. That allows us to use MessageDifferencer.
|
||||
@@ -538,6 +535,5 @@ TEST_F(CryptoMetricsTest, AllCryptoMetrics) {
|
||||
EXPECT_EQ(321,
|
||||
actual.oemcrypto_maximum_usage_table_header_size().int_value());
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
// Unit tests for ValueMetric.
|
||||
#include "value_metric.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "value_metric.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "wv_metrics.pb.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
TEST(ValueMetricTest, StringValue) {
|
||||
ValueMetric<std::string> metric;
|
||||
metric.Record("foo");
|
||||
@@ -59,6 +57,5 @@ TEST(ValueMetricTest, SetError) {
|
||||
ASSERT_EQ(7, metric_proto->error_code());
|
||||
ASSERT_FALSE(metric_proto->has_int_value());
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
Reference in New Issue
Block a user