// 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 #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_