TV Input target-side test
Test: make vts; vts-tradefed; run -m HalTvInputHidlTargetTest
Change-Id: Ifd8a178c9d1dde9b8e87ba0ff06aad75a811b420
diff --git a/tv/Android.bp b/tv/Android.bp
index 5ad82f4..ac54910 100644
--- a/tv/Android.bp
+++ b/tv/Android.bp
@@ -2,4 +2,5 @@
subdirs = [
"cec/1.0",
"input/1.0",
+ "input/1.0/vts/functional",
]
diff --git a/tv/input/1.0/vts/functional/Android.bp b/tv/input/1.0/vts/functional/Android.bp
new file mode 100644
index 0000000..979eb99
--- /dev/null
+++ b/tv/input/1.0/vts/functional/Android.bp
@@ -0,0 +1,43 @@
+//
+// Copyright (C) 2017 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.
+//
+
+cc_test {
+ name: "tv_input_hidl_hal_test",
+ gtest: true,
+ srcs: ["tv_input_hidl_hal_test.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libnativehelper",
+ "libutils",
+ "android.hardware.tv.input@1.0",
+ ],
+ static_libs: ["libgtest"],
+ cflags: [
+// TODO: add --coverage when the segfault issue is fixed.
+// "--coverage",
+ "-O0",
+ "-g",
+ ],
+// ldflags: [
+// "--coverage"
+// ]
+}
+
diff --git a/tv/input/1.0/vts/functional/tv_input_hidl_hal_test.cpp b/tv/input/1.0/vts/functional/tv_input_hidl_hal_test.cpp
new file mode 100644
index 0000000..1279ecd
--- /dev/null
+++ b/tv/input/1.0/vts/functional/tv_input_hidl_hal_test.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#define LOG_TAG "tv_input_hidl_hal_test"
+#include <android-base/logging.h>
+
+#include <android/hardware/tv/input/1.0/types.h>
+#include <android/hardware/tv/input/1.0/ITvInput.h>
+#include <android/hardware/tv/input/1.0/ITvInputCallback.h>
+
+#include <gtest/gtest.h>
+
+using ::android::hardware::tv::input::V1_0::ITvInput;
+using ::android::hardware::tv::input::V1_0::ITvInputCallback;
+using ::android::hardware::tv::input::V1_0::Result;
+using ::android::hardware::tv::input::V1_0::TvInputType;
+using ::android::hardware::tv::input::V1_0::TvInputDeviceInfo;
+using ::android::hardware::tv::input::V1_0::TvInputEventType;
+using ::android::hardware::tv::input::V1_0::TvInputEvent;
+using ::android::hardware::tv::input::V1_0::TvStreamConfig;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+
+// Simple ITvInputCallback used as part of testing.
+class TvInputCallback : public ITvInputCallback {
+ public:
+ TvInputCallback() {};
+
+ virtual ~TvInputCallback() = default;
+
+ // notify callback function - currently no-op.
+ // TODO: modify it later.
+ Return<void> notify(const TvInputEvent& event) override {
+ return Void();
+ };
+};
+
+
+// The main test class for TV Input HIDL HAL.
+class TvInputHidlTest : public ::testing::Test {
+ public:
+ virtual void SetUp() override {
+ // currently test passthrough mode only
+ tv_input = ITvInput::getService();
+ ASSERT_NE(tv_input, nullptr);
+
+ tv_input_callback = new TvInputCallback();
+ ASSERT_NE(tv_input_callback, nullptr);
+ }
+
+ virtual void TearDown() override {}
+
+ sp<ITvInput> tv_input;
+ sp<ITvInputCallback> tv_input_callback;
+};
+
+
+// A class for test environment setup.
+class TvInputHidlEnvironment : public ::testing::Environment {
+ public:
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+
+ private:
+};
+
+// TODO: remove this test and add meaningful tests.
+TEST_F(TvInputHidlTest, DummyTest) {
+ EXPECT_NE(tv_input, nullptr);
+}
+
+int main(int argc, char **argv) {
+ ::testing::AddGlobalTestEnvironment(new TvInputHidlEnvironment);
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ return status;
+}
+
diff --git a/tv/input/1.0/vts/functional/vts/testcases/hal/tv_input/hidl/target/Android.mk b/tv/input/1.0/vts/functional/vts/testcases/hal/tv_input/hidl/target/Android.mk
new file mode 100644
index 0000000..153da0b
--- /dev/null
+++ b/tv/input/1.0/vts/functional/vts/testcases/hal/tv_input/hidl/target/Android.mk
@@ -0,0 +1,26 @@
+#
+# Copyright (C) 2017 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(call all-subdir-makefiles)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := HalTvInputHidlTargetTest
+VTS_CONFIG_SRC_DIR := testcases/hal/tv_input/hidl/target
+include test/vts/tools/build/Android.host_config.mk
+
diff --git a/tv/input/1.0/vts/functional/vts/testcases/hal/tv_input/hidl/target/AndroidTest.xml b/tv/input/1.0/vts/functional/vts/testcases/hal/tv_input/hidl/target/AndroidTest.xml
new file mode 100644
index 0000000..4f98940
--- /dev/null
+++ b/tv/input/1.0/vts/functional/vts/testcases/hal/tv_input/hidl/target/AndroidTest.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+<configuration description="Config for VTS TV Input HIDL HAL's target-side test cases">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group" value="HidlHalTest.push" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="HalTvInputHidlTargetTest"/>
+ <option name="binary-test-sources" value="
+ _32bit::DATA/nativetest/tv_input_hidl_hal_test/tv_input_hidl_hal_test,
+ "/>
+ <option name="binary-test-type" value="gtest" />
+ <option name="test-timeout" value="1m" />
+ </test>
+</configuration>
+