Merge "handle multiple cas plugins. some of them support descrambler, some of them don't" into android11-tests-dev

This commit is contained in:
Treehugger Robot 2021-02-18 19:09:34 +00:00 committed by Gerrit Code Review
commit 8f96b6734f
3 changed files with 47 additions and 32 deletions

View file

@ -256,12 +256,19 @@ class MediaCasHidlTest : public testing::TestWithParam<std::string> {
::testing::AssertionResult MediaCasHidlTest::createCasPlugin(int32_t caSystemId) {
auto status = mService->isSystemIdSupported(caSystemId);
bool skipDescrambler = false;
if (!status.isOk() || !status) {
return ::testing::AssertionFailure();
}
status = mService->isDescramblerSupported(caSystemId);
if (!status.isOk() || !status) {
return ::testing::AssertionFailure();
if (mIsTestDescrambler) {
return ::testing::AssertionFailure();
} else {
ALOGI("Skip Descrambler test since it's not required in cas@1.2.");
mDescramblerBase = nullptr;
skipDescrambler = true;
}
}
mCasListener = new MediaCasListener();
@ -274,16 +281,15 @@ class MediaCasHidlTest : public testing::TestWithParam<std::string> {
return ::testing::AssertionFailure();
}
if (skipDescrambler) {
return ::testing::AssertionSuccess();
}
auto descramblerStatus = mService->createDescrambler(caSystemId);
if (!descramblerStatus.isOk()) {
if (mIsTestDescrambler) {
return ::testing::AssertionFailure();
} else {
ALOGI("Skip Descrambler test since it's not required in cas@1.2.");
return ::testing::AssertionSuccess();
}
return ::testing::AssertionFailure();
}
mIsTestDescrambler = true;
mDescramblerBase = descramblerStatus;
return ::testing::AssertionResult(mDescramblerBase != nullptr);
}
@ -506,7 +512,7 @@ TEST_P(MediaCasHidlTest, TestClearKeyApis) {
returnStatus = mMediaCas->setSessionPrivateData(streamSessionId, hidlPvtData);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
if (mIsTestDescrambler) {
if (mDescramblerBase != nullptr) {
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
@ -556,7 +562,7 @@ TEST_P(MediaCasHidlTest, TestClearKeyApis) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
if (mIsTestDescrambler) {
if (mDescramblerBase != nullptr) {
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent("video/avc"));
sp<IDescrambler> descrambler;
@ -606,7 +612,7 @@ TEST_P(MediaCasHidlTest, TestClearKeySessionClosedAfterRelease) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
if (mIsTestDescrambler) {
if (mDescramblerBase != nullptr) {
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::ERROR_CAS_SESSION_NOT_OPENED, returnStatus);
@ -672,7 +678,7 @@ TEST_P(MediaCasHidlTest, TestClearKeyErrors) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::ERROR_CAS_UNKNOWN, returnStatus);
if (mIsTestDescrambler) {
if (mDescramblerBase != nullptr) {
/*
* Test MediaDescrambler error codes
*/
@ -720,7 +726,7 @@ TEST_P(MediaCasHidlTest, TestClearKeyOobFails) {
std::vector<uint8_t> sessionId;
ASSERT_TRUE(openCasSession(&sessionId));
if (mIsTestDescrambler) {
if (mDescramblerBase != nullptr) {
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
@ -732,7 +738,7 @@ TEST_P(MediaCasHidlTest, TestClearKeyOobFails) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
if (mIsTestDescrambler) {
if (mDescramblerBase != nullptr) {
sp<IDescrambler> descrambler = IDescrambler::castFrom(mDescramblerBase);
ASSERT_NE(nullptr, descrambler.get());

View file

@ -297,12 +297,19 @@ class MediaCasHidlTest : public testing::TestWithParam<std::string> {
::testing::AssertionResult MediaCasHidlTest::createCasPlugin(int32_t caSystemId) {
auto status = mService->isSystemIdSupported(caSystemId);
bool skipDescrambler = false;
if (!status.isOk() || !status) {
return ::testing::AssertionFailure();
}
status = mService->isDescramblerSupported(caSystemId);
if (!status.isOk() || !status) {
return ::testing::AssertionFailure();
if (mIsTestDescrambler) {
return ::testing::AssertionFailure();
} else {
ALOGI("Skip Descrambler test since it's not required in cas@1.2.");
mDescramblerBase = nullptr;
skipDescrambler = true;
}
}
mCasListener = new MediaCasListener();
@ -315,16 +322,14 @@ class MediaCasHidlTest : public testing::TestWithParam<std::string> {
return ::testing::AssertionFailure();
}
if (skipDescrambler) {
return ::testing::AssertionSuccess();
}
auto descramblerStatus = mService->createDescrambler(caSystemId);
if (!descramblerStatus.isOk()) {
if (mIsTestDescrambler) {
return ::testing::AssertionFailure();
} else {
ALOGI("Skip Descrambler test since it's not required in cas@1.2.");
return ::testing::AssertionSuccess();
}
return ::testing::AssertionFailure();
}
mIsTestDescrambler = true;
mDescramblerBase = descramblerStatus;
return ::testing::AssertionResult(mDescramblerBase != nullptr);
@ -481,7 +486,7 @@ TEST_P(MediaCasHidlTest, TestClearKeyApisWithSession) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
if (mIsTestDescrambler) {
if (mDescramblerBase != nullptr) {
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
@ -533,7 +538,7 @@ TEST_P(MediaCasHidlTest, TestClearKeyApisWithSession) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
if (mIsTestDescrambler) {
if (mDescramblerBase != nullptr) {
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent("video/avc"));
sp<IDescrambler> descrambler;

View file

@ -311,7 +311,6 @@ class MediaCasHidlTest : public testing::TestWithParam<std::string> {
sp<ICas> mMediaCas;
sp<IDescramblerBase> mDescramblerBase;
sp<MediaCasListener> mCasListener;
bool mIsTestDescrambler = false;
typedef struct _OobInputTestParams {
const SubSample* subSamples;
uint32_t numSubSamples;
@ -336,12 +335,15 @@ class MediaCasHidlTest : public testing::TestWithParam<std::string> {
::testing::AssertionResult MediaCasHidlTest::createCasPlugin(int32_t caSystemId) {
auto status = mService->isSystemIdSupported(caSystemId);
bool skipDescrambler = false;
if (!status.isOk() || !status) {
return ::testing::AssertionFailure();
}
status = mService->isDescramblerSupported(caSystemId);
if (!status.isOk() || !status) {
return ::testing::AssertionFailure();
ALOGI("Skip Descrambler test since it's not required in cas@1.2.");
mDescramblerBase = nullptr;
skipDescrambler = true;
}
mCasListener = new MediaCasListener();
@ -354,12 +356,14 @@ class MediaCasHidlTest : public testing::TestWithParam<std::string> {
return ::testing::AssertionFailure();
}
auto descramblerStatus = mService->createDescrambler(caSystemId);
if (!descramblerStatus.isOk()) {
ALOGI("Skip Descrambler test since it's not required in cas@1.2.");
if (skipDescrambler) {
return ::testing::AssertionSuccess();
}
mIsTestDescrambler = true;
auto descramblerStatus = mService->createDescrambler(caSystemId);
if (!descramblerStatus.isOk()) {
return ::testing::AssertionFailure();
}
mDescramblerBase = descramblerStatus;
return ::testing::AssertionResult(mDescramblerBase != nullptr);
@ -516,7 +520,7 @@ TEST_P(MediaCasHidlTest, TestClearKeyApisWithSession) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
if (mIsTestDescrambler) {
if (mDescramblerBase != nullptr) {
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
@ -571,7 +575,7 @@ TEST_P(MediaCasHidlTest, TestClearKeyApisWithSession) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
if (mIsTestDescrambler) {
if (mDescramblerBase != nullptr) {
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent("video/avc"));
sp<IDescrambler> descrambler;