// Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary // source code may only be used and distributed under the Widevine License // Agreement. #include #include #include #include #include #include #include #include "cdm.h" #include "log.h" #include "test_base.h" #include "test_host.h" std::string g_sandbox_id = ""; namespace widevine { namespace { constexpr char kSandboxIdParam[] = "--sandbox_id="; // Following the pattern established by help text in test_base.cpp constexpr char kExtraHelpText[] = " --sandbox_id=\n" " Specifies the Sandbox ID that should be sent to OEMCrypto via\n" " OEMCrypto_SetSandbox(). On most platforms, since Sandbox IDs are not\n" " in use, this parameter should be omitted.\n"; } // namespace int Main(Cdm::IStorage* storage, Cdm::IClock* clock, Cdm::ITimer* timer, int argc, char** argv) { // Find and filter out the Sandbox ID, if any. std::vector args(argv, argv + argc); auto sandbox_id_iter = std::find_if(std::begin(args) + 1, std::end(args), [](const std::string& elem) -> bool { return elem.find(kSandboxIdParam) == 0; }); if (sandbox_id_iter != std::end(args)) { g_sandbox_id = sandbox_id_iter->substr(strlen(kSandboxIdParam)); args.erase(sandbox_id_iter); } Cdm::Status status = Cdm::initialize( Cdm::kOpaqueHandle, storage, clock, timer, static_cast(wvutil::g_cutoff), g_sandbox_id); (void)status; // status is now used when assertions are turned off. assert(status == Cdm::kSuccess); std::vector new_argv(args.size()); std::transform( std::begin(args), std::end(args), std::begin(new_argv), [](const std::string& arg) -> const char* { return arg.c_str(); }); // This must take place after the call to Cdm::initialize() because it makes // calls that are only valid after the library is initialized. if (!wvcdm::WvCdmTestBase::Initialize(static_cast(new_argv.size()), new_argv.data(), kExtraHelpText)) { return 1; } // Init gtest after oemcrypto and cdm host have been initialized. ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } } // namespace widevine