Refactor Tuner vts test Demux part

Test: cuttlefish + vendor device test
Bug: 135708935
Change-Id: I7e8e14809975854d6c88819a40819227a187a5a1
(cherry picked from commit dd08190510)
This commit is contained in:
Amy 2020-02-06 16:19:04 -08:00
parent c830cfb345
commit 3c95a93b48

View file

@ -760,16 +760,16 @@ class TunerHidlTest : public testing::TestWithParam<std::string> {
AssertionResult stopTuneFrontend(); AssertionResult stopTuneFrontend();
AssertionResult closeFrontend(); AssertionResult closeFrontend();
::testing::AssertionResult createDemux(); AssertionResult openDemux();
::testing::AssertionResult createDemuxWithFrontend(int32_t frontendId, AssertionResult setDemuxFrontendDataSource(uint32_t frontendId);
FrontendSettings settings); AssertionResult closeDemux();
::testing::AssertionResult getPlaybackMQDescriptor(); ::testing::AssertionResult getPlaybackMQDescriptor();
::testing::AssertionResult addPlaybackToDemux(PlaybackSettings setting); ::testing::AssertionResult addPlaybackToDemux(PlaybackSettings setting);
::testing::AssertionResult getRecordMQDescriptor(); ::testing::AssertionResult getRecordMQDescriptor();
::testing::AssertionResult addRecordToDemux(RecordSettings setting); ::testing::AssertionResult addRecordToDemux(RecordSettings setting);
::testing::AssertionResult addFilterToDemux(DemuxFilterType type, DemuxFilterSettings setting); ::testing::AssertionResult addFilterToDemux(DemuxFilterType type, DemuxFilterSettings setting);
::testing::AssertionResult getFilterMQDescriptor(); ::testing::AssertionResult getFilterMQDescriptor();
::testing::AssertionResult closeDemux();
::testing::AssertionResult createDescrambler(); ::testing::AssertionResult createDescrambler();
::testing::AssertionResult closeDescrambler(); ::testing::AssertionResult closeDescrambler();
@ -864,48 +864,33 @@ AssertionResult TunerHidlTest::closeFrontend() {
} }
/*============================End Frontend APIs Tests Implementation============================*/ /*============================End Frontend APIs Tests Implementation============================*/
/*::testing::AssertionResult TunerHidlTest::createDemux() { /*============================Start Demux APIs Tests Implementation============================*/
AssertionResult TunerHidlTest::openDemux() {
Result status; Result status;
mService->openDemux([&](Result result, uint32_t demuxId, const sp<IDemux>& demux) { mService->openDemux([&](Result result, uint32_t demuxId, const sp<IDemux>& demux) {
mDemux = demux; mDemux = demux;
mDemuxId = demuxId; mDemuxId = demuxId;
status = result; status = result;
}); });
return ::testing::AssertionResult(status == Result::SUCCESS); return AssertionResult(status == Result::SUCCESS);
} }
::testing::AssertionResult TunerHidlTest::createDemuxWithFrontend(int32_t frontendId, AssertionResult TunerHidlTest::setDemuxFrontendDataSource(uint32_t frontendId) {
FrontendSettings settings) { EXPECT_TRUE(mDemux) << "Test with openDemux first.";
Result status; EXPECT_TRUE(mFrontend) << "Test with openFrontend first.";
auto status = mDemux->setFrontendDataSource(frontendId);
if (!mDemux && createDemux() == ::testing::AssertionFailure()) { return AssertionResult(status.isOk());
return ::testing::AssertionFailure();
}
if (!mFrontend && createFrontend(frontendId) == ::testing::AssertionFailure()) {
return ::testing::AssertionFailure();
}
mFrontendCallback->testOnEvent(mFrontend, settings);
status = mDemux->setFrontendDataSource(frontendId);
return ::testing::AssertionResult(status == Result::SUCCESS);
} }
::testing::AssertionResult TunerHidlTest::closeDemux() { AssertionResult TunerHidlTest::closeDemux() {
Result status; EXPECT_TRUE(mDemux) << "Test with openDemux first.";
if (!mDemux && createDemux() == ::testing::AssertionFailure()) { auto status = mDemux->close();
return ::testing::AssertionFailure();
}
status = mDemux->close();
mDemux = nullptr; mDemux = nullptr;
return ::testing::AssertionResult(status == Result::SUCCESS); return AssertionResult(status.isOk());
} }
/*============================End Demux APIs Tests Implementation============================*/
::testing::AssertionResult TunerHidlTest::createDescrambler() { /*::testing::AssertionResult TunerHidlTest::createDescrambler() {
Result status; Result status;
mService->openDescrambler([&](Result result, const sp<IDescrambler>& descrambler) { mService->openDescrambler([&](Result result, const sp<IDescrambler>& descrambler) {
@ -1395,44 +1380,29 @@ TEST_P(TunerHidlTest, AutoScanFrontend) {
} }
/*============================End Frontend Tests============================*/ /*============================End Frontend Tests============================*/
/*TEST_P(TunerHidlTest, CreateDemuxWithFrontend) { /*============================Start Demux Tests============================*/
Result status; TEST_P(TunerHidlTest, OpenDemuxWithFrontendDataSource) {
hidl_vec<FrontendId> feIds; description("Open Demux with a Frontend as its data source.");
ASSERT_TRUE(getFrontendIds());
ASSERT_TRUE(mFeIds.size() > 0);
description("Create Demux with Frontend"); for (size_t i = 0; i < mFeIds.size(); i++) {
mService->getFrontendIds([&](Result result, const hidl_vec<FrontendId>& frontendIds) { ASSERT_TRUE(getFrontendInfo(mFeIds[i]));
status = result; if (mFrontendInfo.type != frontendArray[0].type) {
feIds = frontendIds; continue;
}); }
ASSERT_TRUE(openFrontend(mFeIds[i]));
if (feIds.size() == 0) { ASSERT_TRUE(setFrontendCallback());
ALOGW("[ WARN ] Frontend isn't available"); ASSERT_TRUE(openDemux());
return; ASSERT_TRUE(setDemuxFrontendDataSource(mFeIds[i]));
} ASSERT_TRUE(closeDemux());
ASSERT_TRUE(closeFrontend());
FrontendDvbtSettings dvbt{ break;
.frequency = 1000,
};
FrontendSettings settings;
settings.dvbt(dvbt);
for (size_t i = 0; i < feIds.size(); i++) {
ASSERT_TRUE(createDemuxWithFrontend(feIds[i], settings));
mFrontend->stopTune();
} }
} }
/*============================End Demux Tests============================*/
TEST_P(TunerHidlTest, CreateDemux) { /*TEST_P(TunerHidlTest, CreateDescrambler) {
description("Create Demux");
ASSERT_TRUE(createDemux());
}
TEST_P(TunerHidlTest, CloseDemux) {
description("Close Demux");
ASSERT_TRUE(closeDemux());
}
TEST_P(TunerHidlTest, CreateDescrambler) {
description("Create Descrambler"); description("Create Descrambler");
ASSERT_TRUE(createDescrambler()); ASSERT_TRUE(createDescrambler());
} }