From 3a27d2d649ec559b9f8f7fb53fcf72837e357e92 Mon Sep 17 00:00:00 2001 From: Adam Stone Date: Tue, 7 May 2019 13:47:17 -0700 Subject: [PATCH] Correctly sets provisioning state for test. [ Merge from http://go/wvgerrit/78383 ] Bug: http://b/121049662 Test: Re-ran the unit test. Change-Id: I62c00f425c93b588e123ddd8b1093177f2e9b241 --- libwvdrmengine/cdm/test/wv_cdm_metrics_test.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libwvdrmengine/cdm/test/wv_cdm_metrics_test.cpp b/libwvdrmengine/cdm/test/wv_cdm_metrics_test.cpp index ba3f635b..9abfb11c 100644 --- a/libwvdrmengine/cdm/test/wv_cdm_metrics_test.cpp +++ b/libwvdrmengine/cdm/test/wv_cdm_metrics_test.cpp @@ -5,6 +5,7 @@ // This file contains unit tests for the WvContentDecryptionModule class // that pertain to collecting and reporting metrics. +#include "cdm_identifier.h" #include "gmock/gmock.h" #include "log.h" #include "metrics.pb.h" @@ -32,9 +33,12 @@ namespace wvcdm { // This class is used to test the metrics-related feaures of the // WvContentDecryptionModule class. -class WvContentDecryptionModuleMetricsTest : public ::testing::Test { +class WvContentDecryptionModuleMetricsTest : public WvCdmTestBase { protected: - + void Unprovision(CdmIdentifier identifier) { + EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(kSecurityLevelL1, identifier)); + EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(kSecurityLevelL3, identifier)); + } wvcdm::WvContentDecryptionModule decryptor_; }; @@ -92,6 +96,7 @@ TEST_F(WvContentDecryptionModuleMetricsTest, EngineOnlyMetrics) { TEST_F(WvContentDecryptionModuleMetricsTest, EngineAndSessionMetrics) { CdmSessionId session_id; wvcdm::CdmKeySystem key_system("com.widevine"); + Unprovision(kDefaultCdmIdentifier); // Openning the session will fail with NEEDS_PROVISIONING error. But it will // still create some session-level stats. @@ -138,6 +143,12 @@ TEST_F(WvContentDecryptionModuleMetricsTest, // as the one above except for the unique_id. { "foo", "bar", "baz", 8 }}; const int cdm_engine_count = 3; + + // Force Unprovision. + for (int i = 0; i < cdm_engine_count; i++) { + Unprovision(identifiers[i]); + } + for (int i = 0; i < cdm_engine_count; i++) { // To make sure we can detect different engine metrics, // make the open session call a different number of times for