Add VTS for Watermark APIs
Bug: 283016116
Test: atest VtsHalTvInputTargetTest
Change-Id: I0861ee1fb60bfc702446f9c8af4ddee3737d9ed9
diff --git a/tv/input/aidl/default/TvInput.cpp b/tv/input/aidl/default/TvInput.cpp
index 5f1f7a2..2ee8bcf 100644
--- a/tv/input/aidl/default/TvInput.cpp
+++ b/tv/input/aidl/default/TvInput.cpp
@@ -82,7 +82,10 @@
MQDescriptor<int8_t, SynchronizedReadWrite>* out_queue, int32_t in_deviceId,
int32_t in_streamId) {
ALOGV("%s", __FUNCTION__);
- // TODO: Implement this
+ if (mStreamConfigs.count(in_deviceId) == 0) {
+ ALOGW("Device with id %d isn't available", in_deviceId);
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(STATUS_INVALID_ARGUMENTS);
+ }
return ::ndk::ScopedAStatus::ok();
}
diff --git a/tv/input/aidl/default/TvInput.h b/tv/input/aidl/default/TvInput.h
index 23118c8..5776961 100644
--- a/tv/input/aidl/default/TvInput.h
+++ b/tv/input/aidl/default/TvInput.h
@@ -57,7 +57,6 @@
::ndk::ScopedAStatus openStream(int32_t in_deviceId, int32_t in_streamId,
NativeHandle* _aidl_return) override;
::ndk::ScopedAStatus closeStream(int32_t in_deviceId, int32_t in_streamId) override;
-
void init();
private:
diff --git a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp
index a2415b4..6433305 100644
--- a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp
+++ b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp
@@ -259,8 +259,11 @@
return;
}
int32_t device_id = stream_config_.keyAt(indices[0]);
- int32_t stream_id = stream_config_.valueAt(indices[0])[0].streamId;
-
+ vector<TvStreamConfig> streamConfigs = stream_config_.valueAt(indices[0]);
+ if (streamConfigs.empty()) {
+ return;
+ }
+ int32_t stream_id = streamConfigs[0].streamId;
NativeHandle handle;
ALOGD("OpenAnOpenedStreamsTest: open stream, device_id=%d, stream_id=%d", device_id, stream_id);
@@ -291,7 +294,11 @@
return;
}
int32_t device_id = stream_config_.keyAt(indices[0]);
- int32_t stream_id = stream_config_.valueAt(indices[0])[0].streamId;
+ vector<TvStreamConfig> streamConfigs = stream_config_.valueAt(indices[0]);
+ if (streamConfigs.empty()) {
+ return;
+ }
+ int32_t stream_id = streamConfigs[0].streamId;
ALOGD("CloseStreamBeforeOpenTest: close stream, device_id=%d, stream_id=%d", device_id,
stream_id);
@@ -299,6 +306,43 @@
ITvInput::STATUS_INVALID_STATE);
}
+TEST_P(TvInputAidlTest, SetTvMessageEnabledTest) {
+ unique_lock<mutex> lock(mutex_);
+
+ updateAllStreamConfigurations();
+ vector<size_t> indices = getConfigIndices();
+ if (indices.empty()) {
+ return;
+ }
+ int32_t device_id = stream_config_.keyAt(indices[0]);
+ vector<TvStreamConfig> streamConfigs = stream_config_.valueAt(indices[0]);
+ if (streamConfigs.empty()) {
+ return;
+ }
+ int32_t stream_id = streamConfigs[0].streamId;
+ ALOGD("SetTvMessageEnabledTest: device_id=%d, stream_id=%d", device_id, stream_id);
+ tv_input_->setTvMessageEnabled(device_id, stream_id, TvMessageEventType::WATERMARK, true);
+}
+
+TEST_P(TvInputAidlTest, GetTvMessageQueueTest) {
+ unique_lock<mutex> lock(mutex_);
+
+ updateAllStreamConfigurations();
+ vector<size_t> indices = getConfigIndices();
+ if (indices.empty()) {
+ return;
+ }
+ int32_t device_id = stream_config_.keyAt(indices[0]);
+ vector<TvStreamConfig> streamConfigs = stream_config_.valueAt(indices[0]);
+ if (streamConfigs.empty()) {
+ return;
+ }
+ int32_t stream_id = streamConfigs[0].streamId;
+ ALOGD("GetTvMessageQueueTest: device_id=%d, stream_id=%d", device_id, stream_id);
+ MQDescriptor<int8_t, SynchronizedReadWrite> queue;
+ tv_input_->getTvMessageQueueDesc(&queue, device_id, stream_id);
+}
+
INSTANTIATE_TEST_SUITE_P(PerInstance, TvInputAidlTest,
testing::ValuesIn(android::getAidlHalInstanceNames(ITvInput::descriptor)),
android::PrintInstanceNameToString);
diff --git a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h
index 20d9227..832b27c 100644
--- a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h
+++ b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h
@@ -37,6 +37,7 @@
using namespace std;
using ::aidl::android::hardware::common::NativeHandle;
using ::aidl::android::hardware::common::fmq::MQDescriptor;
+using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
using ::android::AidlMessageQueue;
#define WAIT_FOR_EVENT_TIMEOUT 5