Merge from Widevine repo of http://go/wvgerrit/56521 This CL adds a common main routine for integration tests. It sets a default test configuration for the provisioning and license server urls and certificates, and allows the user to set them on the command line. Test: current unit tests still pass. Bug: 72354901 Fix Generic Crypto tests. Change-Id: I604a3d9e15d50da5041794624c4571c0dcb091f5
52 lines
1.7 KiB
C++
52 lines
1.7 KiB
C++
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
|
// source code may only be used and distributed under the Widevine Master
|
|
// License Agreement.
|
|
|
|
#ifndef WVCDM_CORE_TEST_BASE_H_
|
|
#define WVCDM_CORE_TEST_BASE_H_
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "config_test_env.h"
|
|
#include "crypto_session.h"
|
|
#include "metrics_collections.h"
|
|
#include "string_conversions.h"
|
|
|
|
namespace wvcdm {
|
|
// This is the base class for Widevine CDM integration tests. It's main use is
|
|
// to configure OEMCrypto to use a test keybox.
|
|
class WvCdmTestBase : public ::testing::Test {
|
|
public:
|
|
WvCdmTestBase() : config_(default_config_) {}
|
|
virtual ~WvCdmTestBase() {}
|
|
virtual void SetUp();
|
|
virtual std::string binary_key_id() const { return a2bs_hex(config_.key_id()); }
|
|
|
|
// Returns true if the test program should continue, if false, the caller
|
|
// should exit. This should be called by main() to allow the user to pass in
|
|
// command line switches.
|
|
static bool Initialize(int argc, char **argv);
|
|
// Install a test keybox, if appropriate.
|
|
static void InstallTestRootOfTrust();
|
|
|
|
// The default test configuration. This is influenced by command line
|
|
// arguments before any tests are created.
|
|
static ConfigTestEnv default_config_;
|
|
|
|
// Configuration for an individual test. This is initialized to be the
|
|
// default configuration, but can be modified by the test itself.
|
|
ConfigTestEnv config_;
|
|
};
|
|
|
|
class TestCryptoSession : public CryptoSession {
|
|
public:
|
|
explicit TestCryptoSession(metrics::CryptoMetrics* crypto_metrics);
|
|
// This intercepts nonce flood errors, which is useful for tests that request
|
|
// many nonces and are not time critical.
|
|
bool GenerateNonce(uint32_t* nonce);
|
|
};
|
|
|
|
} // namespace wvcdm
|
|
|
|
#endif // WVCDM_CORE_TEST_BASE_H_
|