diff --git a/ir/1.0/Android.bp b/ir/1.0/Android.bp index 3a8fceb4cd..fb9f070b10 100644 --- a/ir/1.0/Android.bp +++ b/ir/1.0/Android.bp @@ -54,3 +54,106 @@ cc_library_shared { "android.hidl.base@1.0", ], } + +genrule { + name: "android.hardware.ir.vts.driver@1.0_genc++", + tools: ["hidl-gen", "vtsc"], + cmd: "$(location hidl-gen) -o $(genDir) -Lvts -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.ir@1.0 && $(location vtsc) -mDRIVER -tSOURCE -b$(genDir) android/hardware/ir/1.0/ $(genDir)/android/hardware/ir/1.0/", + srcs: [ + "types.hal", + "IConsumerIr.hal", + ], + out: [ + "android/hardware/ir/1.0/types.vts.cpp", + "android/hardware/ir/1.0/ConsumerIr.vts.cpp", + ], +} + +genrule { + name: "android.hardware.ir.vts.driver@1.0_genc++_headers", + tools: ["hidl-gen", "vtsc"], + cmd: "$(location hidl-gen) -o $(genDir) -Lvts -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.ir@1.0 && $(location vtsc) -mDRIVER -tHEADER -b$(genDir) android/hardware/ir/1.0/ $(genDir)/android/hardware/ir/1.0/", + srcs: [ + "types.hal", + "IConsumerIr.hal", + ], + out: [ + "android/hardware/ir/1.0/types.vts.h", + "android/hardware/ir/1.0/ConsumerIr.vts.h", + ], +} + +cc_library_shared { + name: "android.hardware.ir.vts.driver@1.0", + generated_sources: ["android.hardware.ir.vts.driver@1.0_genc++"], + generated_headers: ["android.hardware.ir.vts.driver@1.0_genc++_headers"], + export_generated_headers: ["android.hardware.ir.vts.driver@1.0_genc++_headers"], + shared_libs: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "liblog", + "libutils", + "libcutils", + "libvts_common", + "libvts_datatype", + "libvts_measurement", + "libvts_multidevice_proto", + "libcamera_metadata", + "libprotobuf-cpp-full", + "android.hidl.base@1.0", + "android.hardware.ir@1.0", + ], + export_shared_lib_headers: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "libutils", + "android.hidl.base@1.0", + ], +} + +genrule { + name: "android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++", + tools: ["hidl-gen", "vtsc"], + cmd: "$(location hidl-gen) -o $(genDir) -Lvts -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.ir@1.0 && $(location vtsc) -mPROFILER -tSOURCE -b$(genDir) android/hardware/ir/1.0/ $(genDir)/android/hardware/ir/1.0/", + srcs: [ + "IConsumerIr.hal", + "types.hal", + ], + out: [ + "android/hardware/ir/1.0/ConsumerIr.vts.cpp", + "android/hardware/ir/1.0/types.vts.cpp", + ], +} + +genrule { + name: "android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++_headers", + tools: ["hidl-gen", "vtsc"], + cmd: "$(location hidl-gen) -o $(genDir) -Lvts -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.ir@1.0 && $(location vtsc) -mPROFILER -tHEADER -b$(genDir) android/hardware/ir/1.0/ $(genDir)/android/hardware/ir/1.0/", + srcs: [ + "IConsumerIr.hal", + "types.hal", + ], + out: [ + "android/hardware/ir/1.0/ConsumerIr.vts.h", + "android/hardware/ir/1.0/types.vts.h", + ], +} + +cc_library_shared { + name: "android.hardware.ir@1.0-IConsumerIr-vts.profiler", + generated_sources: ["android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++"], + generated_headers: ["android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++_headers"], + export_generated_headers: ["android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++_headers"], + shared_libs: [ + "libbase", + "libhidlbase", + "libhidltransport", + "libvts_profiling", + "libvts_multidevice_proto", + "libprotobuf-cpp-full", + "android.hidl.base@1.0", + "android.hardware.ir@1.0", + ], +} diff --git a/ir/1.0/vts/Android.mk b/ir/1.0/vts/Android.mk new file mode 100644 index 0000000000..90c50c899d --- /dev/null +++ b/ir/1.0/vts/Android.mk @@ -0,0 +1,19 @@ +# +# Copyright (C) 2016 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 $(LOCAL_PATH)/functional/vts/testcases/hal/ir/hidl/target/Android.mk diff --git a/ir/1.0/vts/ConsumerIr.vts b/ir/1.0/vts/ConsumerIr.vts new file mode 100644 index 0000000000..bebc6cffc2 --- /dev/null +++ b/ir/1.0/vts/ConsumerIr.vts @@ -0,0 +1,44 @@ +component_class: HAL_HIDL +component_type_version: 1.0 +component_name: "IConsumerIr" + +package: "android.hardware.ir" + +import: "android.hardware.ir@1.0::types" + +interface: { + api: { + name: "transmit" + return_type_hidl: { + type: TYPE_SCALAR + scalar_type: "bool_t" + } + arg: { + type: TYPE_SCALAR + scalar_type: "int32_t" + } + arg: { + type: TYPE_VECTOR + vector_value: { + type: TYPE_SCALAR + scalar_type: "int32_t" + } + } + } + + api: { + name: "getCarrierFreqs" + return_type_hidl: { + type: TYPE_SCALAR + scalar_type: "bool_t" + } + return_type_hidl: { + type: TYPE_VECTOR + vector_value: { + type: TYPE_STRUCT + predefined_type: "::android::hardware::ir::V1_0::ConsumerIrFreqRange" + } + } + } + +} diff --git a/ir/1.0/vts/functional/Android.bp b/ir/1.0/vts/functional/Android.bp new file mode 100644 index 0000000000..c5265de4ee --- /dev/null +++ b/ir/1.0/vts/functional/Android.bp @@ -0,0 +1,40 @@ +// +// Copyright (C) 2016 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: "ir_hidl_hal_test", + gtest: true, + srcs: ["ir_hidl_hal_test.cpp"], + shared_libs: [ + "libbase", + "liblog", + "libcutils", + "libhidlbase", + "libhidltransport", + "libhwbinder", + "libutils", + "android.hardware.ir@1.0", + ], + static_libs: ["libgtest"], + cflags: [ + "--coverage", + "-O0", + "-g", + ], + ldflags: [ + "--coverage" + ] +} diff --git a/ir/1.0/vts/functional/ir_hidl_hal_test.cpp b/ir/1.0/vts/functional/ir_hidl_hal_test.cpp new file mode 100644 index 0000000000..57d0b73fcf --- /dev/null +++ b/ir/1.0/vts/functional/ir_hidl_hal_test.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2016 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 "ir_hidl_hal_test" + +#include + +#include +#include + +#include +#include + +using ::android::hardware::ir::V1_0::IConsumerIr; +using ::android::hardware::ir::V1_0::ConsumerIrFreqRange; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::sp; + +// The main test class for IR HIDL HAL. +class ConsumerIrHidlTest : public ::testing::Test { + public: + virtual void SetUp() override { + ir = IConsumerIr::getService(false); + ASSERT_NE(ir, nullptr); + } + + virtual void TearDown() override {} + + sp ir; +}; + +// Test transmit() for the min and max frequency of every available range +TEST_F(ConsumerIrHidlTest, TransmitTest) { + int32_t freqs; + bool success; + hidl_vec ranges; + auto cb = [&](bool s, hidl_vec v) { + ranges = v; + success = s; + }; + Return ret = ir->getCarrierFreqs(cb); + ASSERT_TRUE(ret.isOk()); + ASSERT_TRUE(success); + + if (ranges.size() > 0) { + uint32_t len = 16; + hidl_vec vec; + vec.resize(len); + std::fill(vec.begin(), vec.end(), 1); + for (auto range = ranges.begin(); range != ranges.end(); range++) { + EXPECT_TRUE(ir->transmit(range->min, vec)); + EXPECT_TRUE(ir->transmit(range->max, vec)); + } + } +} + +// Test transmit() when called with invalid frequencies +TEST_F(ConsumerIrHidlTest, BadFreqTest) { + uint32_t len = 16; + hidl_vec vec; + vec.resize(len); + std::fill(vec.begin(), vec.end(), 1); + EXPECT_FALSE(ir->transmit(-1, vec)); + EXPECT_FALSE(ir->transmit(0, vec)); +} + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + int status = RUN_ALL_TESTS(); + LOG(INFO) << "Test result = " << status; + return status; +} diff --git a/ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/Android.mk b/ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/Android.mk new file mode 100644 index 0000000000..a69fd0827c --- /dev/null +++ b/ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/Android.mk @@ -0,0 +1,23 @@ +# +# Copyright (C) 2016 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 $(CLEAR_VARS) + +LOCAL_MODULE := HalIrHidlTargetTest +VTS_CONFIG_SRC_DIR := testcases/hal/ir/hidl/target +include test/vts/tools/build/Android.host_config.mk diff --git a/ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/AndroidTest.xml b/ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/AndroidTest.xml new file mode 100644 index 0000000000..3ad7e45268 --- /dev/null +++ b/ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/AndroidTest.xml @@ -0,0 +1,31 @@ + + + + + + + + + diff --git a/ir/1.0/vts/types.vts b/ir/1.0/vts/types.vts new file mode 100644 index 0000000000..d308b1f2b5 --- /dev/null +++ b/ir/1.0/vts/types.vts @@ -0,0 +1,21 @@ +component_class: HAL_HIDL +component_type_version: 1.0 +component_name: "types" + +package: "android.hardware.ir" + + +attribute: { + name: "::android::hardware::ir::V1_0::ConsumerIrFreqRange" + type: TYPE_STRUCT + struct_value: { + name: "min" + type: TYPE_SCALAR + scalar_type: "uint32_t" + } + struct_value: { + name: "max" + type: TYPE_SCALAR + scalar_type: "uint32_t" + } +} \ No newline at end of file diff --git a/ir/Android.bp b/ir/Android.bp index ba90f2c9d1..ed19a37034 100644 --- a/ir/Android.bp +++ b/ir/Android.bp @@ -2,4 +2,5 @@ subdirs = [ "1.0", "1.0/default", + "1.0/vts/functional", ] diff --git a/ir/Android.mk b/ir/Android.mk new file mode 100644 index 0000000000..f9e32763ff --- /dev/null +++ b/ir/Android.mk @@ -0,0 +1,19 @@ +# +# Copyright (C) 2016 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)