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
This commit is contained in:
Adam Stone
2019-05-07 13:47:17 -07:00
parent a1e94e2eb1
commit 3a27d2d649

View File

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