Add ILnb VTS tests am: e5a9da2e17
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/11696698 Change-Id: I2d74508971d476a757399fb311a1cfeeedde4882
This commit is contained in:
commit
7a7838f88c
10 changed files with 289 additions and 11 deletions
|
@ -124,12 +124,12 @@ Return<void> Demux::getAvSyncHwId(const sp<IFilter>& filter, getAvSyncHwId_cb _h
|
|||
}
|
||||
|
||||
if (!mPcrFilterIds.empty()) {
|
||||
ALOGE("[Demux] No PCR filter opened.");
|
||||
// Return the lowest pcr filter id in the default implementation as the av sync id
|
||||
_hidl_cb(Result::SUCCESS, *mPcrFilterIds.begin());
|
||||
return Void();
|
||||
}
|
||||
|
||||
ALOGE("[Demux] No PCR filter opened.");
|
||||
_hidl_cb(Result::INVALID_STATE, avSyncHwId);
|
||||
return Void();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ cc_test {
|
|||
"FilterTests.cpp",
|
||||
"DvrTests.cpp",
|
||||
"DescramblerTests.cpp",
|
||||
"LnbTests.cpp",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.cas@1.0",
|
||||
|
|
|
@ -53,23 +53,23 @@ AssertionResult DemuxTests::closeDemux() {
|
|||
return AssertionResult(status.isOk());
|
||||
}
|
||||
|
||||
void DemuxTests::getAvSyncId(sp<IFilter> filter, uint32_t& avSyncHwId) {
|
||||
ASSERT_TRUE(mDemux) << "Demux is not opened yet.";
|
||||
AssertionResult DemuxTests::getAvSyncId(sp<IFilter> filter, uint32_t& avSyncHwId) {
|
||||
EXPECT_TRUE(mDemux) << "Demux is not opened yet.";
|
||||
Result status;
|
||||
mDemux->getAvSyncHwId(filter, [&](Result result, uint32_t id) {
|
||||
status = result;
|
||||
avSyncHwId = id;
|
||||
});
|
||||
ASSERT_TRUE(status == Result::SUCCESS) << "Fail to get avSyncHwId.";
|
||||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
||||
|
||||
void DemuxTests::getAvSyncTime(uint32_t avSyncId) {
|
||||
ASSERT_TRUE(mDemux) << "Demux is not opened yet.";
|
||||
AssertionResult DemuxTests::getAvSyncTime(uint32_t avSyncId) {
|
||||
EXPECT_TRUE(mDemux) << "Demux is not opened yet.";
|
||||
Result status;
|
||||
uint64_t syncTime;
|
||||
mDemux->getAvSyncTime(avSyncId, [&](Result result, uint64_t time) {
|
||||
status = result;
|
||||
syncTime = time;
|
||||
});
|
||||
ASSERT_TRUE(status == Result::SUCCESS) << "Fail to get avSyncTime.";
|
||||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
|
@ -44,8 +44,8 @@ class DemuxTests {
|
|||
|
||||
AssertionResult openDemux(sp<IDemux>& demux, uint32_t& demuxId);
|
||||
AssertionResult setDemuxFrontendDataSource(uint32_t frontendId);
|
||||
void getAvSyncId(sp<IFilter> filter, uint32_t& avSyncHwId);
|
||||
void getAvSyncTime(uint32_t avSyncId);
|
||||
AssertionResult getAvSyncId(sp<IFilter> filter, uint32_t& avSyncHwId);
|
||||
AssertionResult getAvSyncTime(uint32_t avSyncId);
|
||||
AssertionResult getDemuxCaps(DemuxCapabilities& demuxCaps);
|
||||
AssertionResult closeDemux();
|
||||
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/cas/1.0/types.h>
|
||||
#include <android/hardware/cas/1.2/ICas.h>
|
||||
|
@ -28,6 +26,8 @@
|
|||
#include <android/hardware/tv/tuner/1.0/ITuner.h>
|
||||
#include <android/hardware/tv/tuner/1.0/types.h>
|
||||
#include <fmq/MessageQueue.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <utils/Condition.h>
|
||||
#include <utils/Mutex.h>
|
||||
|
@ -69,6 +69,8 @@ using android::hardware::tv::tuner::V1_0::TunerKeyToken;
|
|||
|
||||
using ::testing::AssertionResult;
|
||||
|
||||
using namespace std;
|
||||
|
||||
class MediaCasListener : public ICasListener {
|
||||
public:
|
||||
virtual Return<void> onEvent(int32_t /*event*/, int32_t /*arg*/,
|
||||
|
|
116
tv/tuner/1.0/vts/functional/LnbTests.cpp
Normal file
116
tv/tuner/1.0/vts/functional/LnbTests.cpp
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* Copyright 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "LnbTests.h"
|
||||
|
||||
Return<void> LnbCallback::onEvent(LnbEventType lnbEventType) {
|
||||
android::Mutex::Autolock autoLock(mMsgLock);
|
||||
ALOGD("[vts] lnb event received. Type: %d", lnbEventType);
|
||||
mEventReceived = true;
|
||||
mMsgCondition.signal();
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> LnbCallback::onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage) {
|
||||
string msg(diseqcMessage.begin(), diseqcMessage.end());
|
||||
ALOGD("[vts] onDiseqcMessage %s", msg.c_str());
|
||||
return Void();
|
||||
}
|
||||
|
||||
AssertionResult LnbTests::getLnbIds(vector<uint32_t>& ids) {
|
||||
Result status;
|
||||
mService->getLnbIds([&](Result result, const hidl_vec<uint32_t>& lnbIds) {
|
||||
status = result;
|
||||
ids = lnbIds;
|
||||
});
|
||||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult LnbTests::openLnbById(uint32_t lnbId) {
|
||||
Result status;
|
||||
mService->openLnbById(lnbId, [&](Result result, const sp<ILnb>& lnb) {
|
||||
mLnb = lnb;
|
||||
status = result;
|
||||
});
|
||||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult LnbTests::openLnbByName(string lnbName) {
|
||||
Result status;
|
||||
mService->openLnbByName(lnbName, [&](Result result, uint32_t /*lnbId*/, const sp<ILnb>& lnb) {
|
||||
mLnb = lnb;
|
||||
status = result;
|
||||
});
|
||||
|
||||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult LnbTests::setLnbCallback() {
|
||||
if (!mLnb) {
|
||||
ALOGW("[vts] Open Lnb first");
|
||||
return failure();
|
||||
}
|
||||
mLnbCallback = new LnbCallback();
|
||||
auto callbackStatus = mLnb->setCallback(mLnbCallback);
|
||||
return AssertionResult(callbackStatus.isOk());
|
||||
}
|
||||
|
||||
AssertionResult LnbTests::setVoltage(LnbVoltage voltage) {
|
||||
if (!mLnb) {
|
||||
ALOGW("[vts] Open Lnb first");
|
||||
return failure();
|
||||
}
|
||||
Result status = mLnb->setVoltage(voltage);
|
||||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult LnbTests::setTone(LnbTone tone) {
|
||||
if (!mLnb) {
|
||||
ALOGW("[vts] Open Lnb first");
|
||||
return failure();
|
||||
}
|
||||
Result status = mLnb->setTone(tone);
|
||||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult LnbTests::setSatellitePosition(LnbPosition position) {
|
||||
if (!mLnb) {
|
||||
ALOGW("[vts] Open Lnb first");
|
||||
return failure();
|
||||
}
|
||||
Result status = mLnb->setSatellitePosition(position);
|
||||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult LnbTests::sendDiseqcMessage(vector<uint8_t> diseqcMsg) {
|
||||
if (!mLnb) {
|
||||
ALOGW("[vts] Open Lnb first");
|
||||
return failure();
|
||||
}
|
||||
Result status = mLnb->sendDiseqcMessage(diseqcMsg);
|
||||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
||||
|
||||
AssertionResult LnbTests::closeLnb() {
|
||||
if (!mLnb) {
|
||||
ALOGW("[vts] Open Lnb first");
|
||||
return failure();
|
||||
}
|
||||
Result status = mLnb->close();
|
||||
mLnb = nullptr;
|
||||
mLnbCallback = nullptr;
|
||||
return AssertionResult(status == Result::SUCCESS);
|
||||
}
|
84
tv/tuner/1.0/vts/functional/LnbTests.h
Normal file
84
tv/tuner/1.0/vts/functional/LnbTests.h
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/tv/tuner/1.0/ILnb.h>
|
||||
#include <android/hardware/tv/tuner/1.0/ITuner.h>
|
||||
#include <android/hardware/tv/tuner/1.0/types.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <hidlmemory/FrameworkUtils.h>
|
||||
#include <utils/Condition.h>
|
||||
#include <utils/Mutex.h>
|
||||
#include <map>
|
||||
|
||||
using android::Condition;
|
||||
using android::Mutex;
|
||||
using android::sp;
|
||||
using android::hardware::hidl_vec;
|
||||
using android::hardware::Return;
|
||||
using android::hardware::Void;
|
||||
using android::hardware::tv::tuner::V1_0::ILnb;
|
||||
using android::hardware::tv::tuner::V1_0::ILnbCallback;
|
||||
using android::hardware::tv::tuner::V1_0::ITuner;
|
||||
using android::hardware::tv::tuner::V1_0::LnbEventType;
|
||||
using android::hardware::tv::tuner::V1_0::LnbPosition;
|
||||
using android::hardware::tv::tuner::V1_0::LnbTone;
|
||||
using android::hardware::tv::tuner::V1_0::LnbVoltage;
|
||||
using android::hardware::tv::tuner::V1_0::Result;
|
||||
|
||||
using ::testing::AssertionResult;
|
||||
|
||||
using namespace std;
|
||||
|
||||
class LnbCallback : public ILnbCallback {
|
||||
public:
|
||||
virtual Return<void> onEvent(LnbEventType lnbEventType) override;
|
||||
virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage) override;
|
||||
|
||||
private:
|
||||
bool mEventReceived = false;
|
||||
android::Mutex mMsgLock;
|
||||
android::Condition mMsgCondition;
|
||||
};
|
||||
|
||||
class LnbTests {
|
||||
public:
|
||||
void setService(sp<ITuner> tuner) { mService = tuner; }
|
||||
|
||||
AssertionResult getLnbIds(vector<uint32_t>& ids);
|
||||
AssertionResult openLnbById(uint32_t lnbId);
|
||||
AssertionResult openLnbByName(string lnbName);
|
||||
AssertionResult setLnbCallback();
|
||||
AssertionResult setVoltage(LnbVoltage voltage);
|
||||
AssertionResult setTone(LnbTone tone);
|
||||
AssertionResult setSatellitePosition(LnbPosition position);
|
||||
AssertionResult sendDiseqcMessage(vector<uint8_t> diseqcMsg);
|
||||
AssertionResult closeLnb();
|
||||
|
||||
protected:
|
||||
static AssertionResult failure() { return ::testing::AssertionFailure(); }
|
||||
|
||||
static AssertionResult success() { return ::testing::AssertionSuccess(); }
|
||||
|
||||
sp<ITuner> mService;
|
||||
sp<ILnb> mLnb;
|
||||
sp<LnbCallback> mLnbCallback;
|
||||
hidl_vec<uint32_t> mLnbIds;
|
||||
};
|
|
@ -275,6 +275,22 @@ TEST_P(TunerFrontendHidlTest, BlindScanFrontend) {
|
|||
mFrontendTests.scanTest(frontendScanArray[SCAN_DVBT], FrontendScanType::SCAN_BLIND);
|
||||
}
|
||||
|
||||
TEST_P(TunerLnbHidlTest, SendDiseqcMessageToLnb) {
|
||||
description("Open and configure an Lnb with specific settings then send a diseqc msg to it.");
|
||||
vector<uint32_t> ids;
|
||||
ASSERT_TRUE(mLnbTests.getLnbIds(ids));
|
||||
if (ids.size() == 0) {
|
||||
return;
|
||||
}
|
||||
ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
|
||||
ASSERT_TRUE(mLnbTests.setLnbCallback());
|
||||
ASSERT_TRUE(mLnbTests.setVoltage(lnbArray[LNB0].voltage));
|
||||
ASSERT_TRUE(mLnbTests.setTone(lnbArray[LNB0].tone));
|
||||
ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbArray[LNB0].position));
|
||||
ASSERT_TRUE(mLnbTests.sendDiseqcMessage(diseqcMsgArray[DISEQC_POWER_ON]));
|
||||
ASSERT_TRUE(mLnbTests.closeLnb());
|
||||
}
|
||||
|
||||
TEST_P(TunerDemuxHidlTest, openDemux) {
|
||||
description("Open and close a Demux.");
|
||||
uint32_t feId;
|
||||
|
@ -428,6 +444,11 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(ITuner::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PerInstance, TunerLnbHidlTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(ITuner::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PerInstance, TunerDemuxHidlTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(ITuner::descriptor)),
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "DescramblerTests.h"
|
||||
#include "DvrTests.h"
|
||||
#include "FrontendTests.h"
|
||||
#include "LnbTests.h"
|
||||
|
||||
using android::hardware::tv::tuner::V1_0::DataFormat;
|
||||
using android::hardware::tv::tuner::V1_0::IDescrambler;
|
||||
|
@ -31,6 +32,7 @@ namespace {
|
|||
void initConfiguration() {
|
||||
initFrontendConfig();
|
||||
initFrontendScanConfig();
|
||||
initLnbConfig();
|
||||
initFilterConfig();
|
||||
initDvrConfig();
|
||||
initDescramblerConfig();
|
||||
|
@ -65,6 +67,25 @@ class TunerFrontendHidlTest : public testing::TestWithParam<std::string> {
|
|||
FrontendTests mFrontendTests;
|
||||
};
|
||||
|
||||
class TunerLnbHidlTest : public testing::TestWithParam<std::string> {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
mService = ITuner::getService(GetParam());
|
||||
ASSERT_NE(mService, nullptr);
|
||||
initConfiguration();
|
||||
|
||||
mLnbTests.setService(mService);
|
||||
}
|
||||
|
||||
protected:
|
||||
static void description(const std::string& description) {
|
||||
RecordProperty("description", description);
|
||||
}
|
||||
|
||||
sp<ITuner> mService;
|
||||
LnbTests mLnbTests;
|
||||
};
|
||||
|
||||
class TunerDemuxHidlTest : public testing::TestWithParam<std::string> {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
|
|
|
@ -47,6 +47,9 @@ using android::hardware::tv::tuner::V1_0::FrontendSettings;
|
|||
using android::hardware::tv::tuner::V1_0::FrontendStatus;
|
||||
using android::hardware::tv::tuner::V1_0::FrontendStatusType;
|
||||
using android::hardware::tv::tuner::V1_0::FrontendType;
|
||||
using android::hardware::tv::tuner::V1_0::LnbPosition;
|
||||
using android::hardware::tv::tuner::V1_0::LnbTone;
|
||||
using android::hardware::tv::tuner::V1_0::LnbVoltage;
|
||||
using android::hardware::tv::tuner::V1_0::PlaybackSettings;
|
||||
using android::hardware::tv::tuner::V1_0::RecordSettings;
|
||||
|
||||
|
@ -94,6 +97,16 @@ typedef enum {
|
|||
FRONTEND_MAX,
|
||||
} Frontend;
|
||||
|
||||
typedef enum {
|
||||
LNB0,
|
||||
LNB_MAX,
|
||||
} Lnb;
|
||||
|
||||
typedef enum {
|
||||
DISEQC_POWER_ON,
|
||||
DISEQC_MAX,
|
||||
} Diseqc;
|
||||
|
||||
typedef enum {
|
||||
SCAN_DVBT,
|
||||
SCAN_MAX,
|
||||
|
@ -125,6 +138,12 @@ struct FrontendConfig {
|
|||
vector<FrontendStatus> expectTuneStatuses;
|
||||
};
|
||||
|
||||
struct LnbConfig {
|
||||
LnbVoltage voltage;
|
||||
LnbTone tone;
|
||||
LnbPosition position;
|
||||
};
|
||||
|
||||
struct ChannelConfig {
|
||||
int32_t frontendId;
|
||||
int32_t channelId;
|
||||
|
@ -148,6 +167,8 @@ struct DescramblerConfig {
|
|||
|
||||
static FrontendConfig frontendArray[FILTER_MAX];
|
||||
static FrontendConfig frontendScanArray[SCAN_MAX];
|
||||
static LnbConfig lnbArray[LNB_MAX];
|
||||
static vector<uint8_t> diseqcMsgArray[DISEQC_MAX];
|
||||
static ChannelConfig channelArray[FRONTEND_MAX];
|
||||
static FilterConfig filterArray[FILTER_MAX];
|
||||
static DemuxFilterType filterLinkageTypes[LINKAGE_DIR][FILTER_MAIN_TYPE_BIT_COUNT];
|
||||
|
@ -198,6 +219,18 @@ inline void initFrontendScanConfig() {
|
|||
});
|
||||
};
|
||||
|
||||
/** Configuration array for the Lnb test */
|
||||
inline void initLnbConfig() {
|
||||
lnbArray[LNB0].voltage = LnbVoltage::VOLTAGE_12V;
|
||||
lnbArray[LNB0].tone = LnbTone::NONE;
|
||||
lnbArray[LNB0].position = LnbPosition::UNDEFINED;
|
||||
};
|
||||
|
||||
/** Diseqc messages array for the Lnb test */
|
||||
inline void initDiseqcMsg() {
|
||||
diseqcMsgArray[DISEQC_POWER_ON] = {0xE, 0x0, 0x0, 0x0, 0x0, 0x3};
|
||||
};
|
||||
|
||||
/** Configuration array for the filter test */
|
||||
inline void initFilterConfig() {
|
||||
// TS VIDEO filter setting for default implementation testing
|
||||
|
|
Loading…
Reference in a new issue