diff --git a/cas/1.0/vts/functional/Android.bp b/cas/1.0/vts/functional/Android.bp index 622baa5988..ab39c0e93b 100644 --- a/cas/1.0/vts/functional/Android.bp +++ b/cas/1.0/vts/functional/Android.bp @@ -29,6 +29,6 @@ cc_test { shared_libs: [ "libbinder", ], - test_suites: ["general-tests"], + test_suites: ["general-tests", "vts-core"], } diff --git a/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp b/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp index f0bba57137..0f16de5e90 100644 --- a/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp +++ b/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp @@ -16,8 +16,6 @@ #define LOG_TAG "mediacas_hidl_hal_test" -#include -#include #include #include #include @@ -27,8 +25,11 @@ #include #include #include +#include +#include #include #include +#include #include #include #include @@ -208,29 +209,16 @@ void MediaCasListener::testEventEcho(sp& mediaCas, int32_t& event, int32_t EXPECT_TRUE(mEventData == eventData); } -// Test environment for Cas HIDL HAL. -class CasHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { - public: - // get the test environment singleton - static CasHidlEnvironment* Instance() { - static CasHidlEnvironment* instance = new CasHidlEnvironment; - return instance; - } - - virtual void registerTestServices() override { registerTestService(); } -}; - -class MediaCasHidlTest : public ::testing::VtsHalHidlTargetTestBase { - public: +class MediaCasHidlTest : public testing::TestWithParam { + public: virtual void SetUp() override { - mService = ::testing::VtsHalHidlTargetTestBase::getService( - CasHidlEnvironment::Instance()->getServiceName()); + mService = IMediaCasService::getService(GetParam()); ASSERT_NE(mService, nullptr); } - sp mService; + sp mService = nullptr; - protected: + protected: static void description(const std::string& description) { RecordProperty("description", description); } @@ -419,7 +407,7 @@ class MediaCasHidlTest : public ::testing::VtsHalHidlTargetTestBase { return ::testing::AssertionResult(returnVoid.isOk()); } -TEST_F(MediaCasHidlTest, EnumeratePlugins) { +TEST_P(MediaCasHidlTest, EnumeratePlugins) { description("Test enumerate plugins"); hidl_vec descriptors; EXPECT_TRUE(mService @@ -440,7 +428,7 @@ TEST_F(MediaCasHidlTest, EnumeratePlugins) { } } -TEST_F(MediaCasHidlTest, TestInvalidSystemIdFails) { +TEST_P(MediaCasHidlTest, TestInvalidSystemIdFails) { description("Test failure for invalid system ID"); sp casListener = new MediaCasListener(); @@ -458,7 +446,7 @@ TEST_F(MediaCasHidlTest, TestInvalidSystemIdFails) { EXPECT_EQ(descramblerBase, nullptr); } -TEST_F(MediaCasHidlTest, TestClearKeyPluginInstalled) { +TEST_P(MediaCasHidlTest, TestClearKeyPluginInstalled) { description("Test if ClearKey plugin is installed"); hidl_vec descriptors; EXPECT_TRUE(mService @@ -480,7 +468,7 @@ TEST_F(MediaCasHidlTest, TestClearKeyPluginInstalled) { ASSERT_TRUE(false) << "ClearKey plugin not installed"; } -TEST_F(MediaCasHidlTest, TestClearKeyApis) { +TEST_P(MediaCasHidlTest, TestClearKeyApis) { description("Test that valid call sequences succeed"); ASSERT_TRUE(createCasPlugin(CLEAR_KEY_SYSTEM_ID)); @@ -584,7 +572,7 @@ TEST_F(MediaCasHidlTest, TestClearKeyApis) { EXPECT_EQ(Status::OK, returnStatus); } -TEST_F(MediaCasHidlTest, TestClearKeySessionClosedAfterRelease) { +TEST_P(MediaCasHidlTest, TestClearKeySessionClosedAfterRelease) { description("Test that all sessions are closed after a MediaCas object is released"); ASSERT_TRUE(createCasPlugin(CLEAR_KEY_SYSTEM_ID)); @@ -611,7 +599,7 @@ TEST_F(MediaCasHidlTest, TestClearKeySessionClosedAfterRelease) { EXPECT_EQ(Status::ERROR_CAS_SESSION_NOT_OPENED, returnStatus); } -TEST_F(MediaCasHidlTest, TestClearKeyErrors) { +TEST_P(MediaCasHidlTest, TestClearKeyErrors) { description("Test that invalid call sequences fail with expected error codes"); ASSERT_TRUE(createCasPlugin(CLEAR_KEY_SYSTEM_ID)); @@ -700,7 +688,7 @@ TEST_F(MediaCasHidlTest, TestClearKeyErrors) { EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent("bad")); } -TEST_F(MediaCasHidlTest, TestClearKeyOobFails) { +TEST_P(MediaCasHidlTest, TestClearKeyOobFails) { description("Test that oob descramble request fails with expected error"); ASSERT_TRUE(createCasPlugin(CLEAR_KEY_SYSTEM_ID)); @@ -849,11 +837,7 @@ TEST_F(MediaCasHidlTest, TestClearKeyOobFails) { } // anonymous namespace -int main(int argc, char** argv) { - ::testing::AddGlobalTestEnvironment(CasHidlEnvironment::Instance()); - ::testing::InitGoogleTest(&argc, argv); - CasHidlEnvironment::Instance()->init(&argc, argv); - int status = RUN_ALL_TESTS(); - LOG(INFO) << "Test result = " << status; - return status; -} +INSTANTIATE_TEST_SUITE_P( + PerInstance, MediaCasHidlTest, + testing::ValuesIn(android::hardware::getAllHalInstanceNames(IMediaCasService::descriptor)), + android::hardware::PrintInstanceNameToString); \ No newline at end of file diff --git a/cas/1.1/vts/functional/Android.bp b/cas/1.1/vts/functional/Android.bp index 8afd19abda..9e8eb52efe 100644 --- a/cas/1.1/vts/functional/Android.bp +++ b/cas/1.1/vts/functional/Android.bp @@ -30,6 +30,6 @@ cc_test { shared_libs: [ "libbinder", ], - test_suites: ["general-tests"], + test_suites: ["general-tests", "vts-core"], } diff --git a/cas/1.1/vts/functional/VtsHalCasV1_1TargetTest.cpp b/cas/1.1/vts/functional/VtsHalCasV1_1TargetTest.cpp index 0264bddedd..7e5a61a6ff 100644 --- a/cas/1.1/vts/functional/VtsHalCasV1_1TargetTest.cpp +++ b/cas/1.1/vts/functional/VtsHalCasV1_1TargetTest.cpp @@ -27,8 +27,11 @@ #include #include #include +#include +#include #include #include +#include #include #include #include @@ -251,27 +254,14 @@ void MediaCasListener::testSessionEventEcho(sp& mediaCas, const hidl_vec(); } -}; - -class MediaCasHidlTest : public ::testing::VtsHalHidlTargetTestBase { +class MediaCasHidlTest : public testing::TestWithParam { public: virtual void SetUp() override { - mService = ::testing::VtsHalHidlTargetTestBase::getService( - CasHidlEnvironment::Instance()->getServiceName()); + mService = IMediaCasService::getService(GetParam()); ASSERT_NE(mService, nullptr); } - sp mService; + sp mService = nullptr; protected: static void description(const std::string& description) { @@ -453,7 +443,7 @@ class MediaCasHidlTest : public ::testing::VtsHalHidlTargetTestBase { return ::testing::AssertionResult(returnVoid.isOk()); } -TEST_F(MediaCasHidlTest, TestClearKeyApisWithSession) { +TEST_P(MediaCasHidlTest, TestClearKeyApisWithSession) { description("Test that valid call sequences with SessionEvent send and receive"); ASSERT_TRUE(createCasPlugin(CLEAR_KEY_SYSTEM_ID)); @@ -561,11 +551,7 @@ TEST_F(MediaCasHidlTest, TestClearKeyApisWithSession) { } // anonymous namespace -int main(int argc, char** argv) { - ::testing::AddGlobalTestEnvironment(CasHidlEnvironment::Instance()); - ::testing::InitGoogleTest(&argc, argv); - CasHidlEnvironment::Instance()->init(&argc, argv); - int status = RUN_ALL_TESTS(); - LOG(INFO) << "Test result = " << status; - return status; -} +INSTANTIATE_TEST_SUITE_P( + PerInstance, MediaCasHidlTest, + testing::ValuesIn(android::hardware::getAllHalInstanceNames(IMediaCasService::descriptor)), + android::hardware::PrintInstanceNameToString);