Create two new metric types to simplify metrics.
This is part one of a mult-part change to revise some metrics. Several metrics are currently EventMetric type when they should be a simpler type. Test: Added unit tests for the new types. Also, re-ran existing tests. Verified playback works with Google Play, and re-ran Widevine GTS tests. Bug: 36220619 Change-Id: I2ec8fc355f66ad4834dd722aacd22541fb9c94ad
This commit is contained in:
47
libwvdrmengine/cdm/metrics/test/distribution_unittest.cpp
Normal file
47
libwvdrmengine/cdm/metrics/test/distribution_unittest.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Unit tests for Distribution.
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include "distribution.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
TEST(DistributionTest, NoValuesRecorded) {
|
||||
Distribution distribution;
|
||||
EXPECT_EQ(DBL_MAX, distribution.Min());
|
||||
EXPECT_EQ(-DBL_MAX, distribution.Max());
|
||||
EXPECT_EQ(0, distribution.Mean());
|
||||
EXPECT_EQ(0, distribution.Count());
|
||||
EXPECT_EQ(0, distribution.Variance());
|
||||
}
|
||||
|
||||
TEST(DistributionTest, OneValueRecorded) {
|
||||
Distribution distribution;
|
||||
distribution.Record(5.0);
|
||||
EXPECT_EQ(5, distribution.Min());
|
||||
EXPECT_EQ(5, distribution.Max());
|
||||
EXPECT_EQ(5, distribution.Mean());
|
||||
EXPECT_EQ(1, distribution.Count());
|
||||
EXPECT_EQ(0, distribution.Variance());
|
||||
}
|
||||
|
||||
TEST(DistributionTest, MultipleValuesRecorded) {
|
||||
Distribution distribution;
|
||||
distribution.Record(5.0);
|
||||
distribution.Record(10.0);
|
||||
distribution.Record(15.0);
|
||||
EXPECT_EQ(5, distribution.Min());
|
||||
EXPECT_EQ(15, distribution.Max());
|
||||
EXPECT_EQ(10, distribution.Mean());
|
||||
EXPECT_EQ(3, distribution.Count());
|
||||
EXPECT_NEAR(16.6667, distribution.Variance(), 0.0001);
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
Reference in New Issue
Block a user