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:
Alex Dale
2021-11-03 17:28:00 -07:00
parent 21a021e800
commit 1b95db51f1
23 changed files with 112 additions and 163 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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