diff options
author | Sasha Levitskiy <sanek@google.com> | 2014-03-24 16:14:42 -0700 |
---|---|---|
committer | Alexander Levitskiy <sanek@google.com> | 2014-04-07 18:14:34 +0000 |
commit | a747c069c6b3f5a6420662020822992cc70384bc (patch) | |
tree | 252a78401e0653374d34574b712fe9ad54871338 /tests | |
parent | d5aa52756fe21c23096e333afc74e3589a11d216 (diff) | |
download | hardware_libhardware-a747c069c6b3f5a6420662020822992cc70384bc.zip hardware_libhardware-a747c069c6b3f5a6420662020822992cc70384bc.tar.gz hardware_libhardware-a747c069c6b3f5a6420662020822992cc70384bc.tar.bz2 |
Hardware: Fingerprint: Introducing Fingerprint HAL
Change-Id: I4e55c42841c3b6a1327a16bdf6d1d4bb3847c7f3
Signed-off-by: Sasha Levitskiy <sanek@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fingerprint/Android.mk | 19 | ||||
-rw-r--r-- | tests/fingerprint/fingerprint_test_fixtures.h | 75 | ||||
-rw-r--r-- | tests/fingerprint/fingerprint_tests.cpp | 37 |
3 files changed, 131 insertions, 0 deletions
diff --git a/tests/fingerprint/Android.mk b/tests/fingerprint/Android.mk new file mode 100644 index 0000000..4f03c39 --- /dev/null +++ b/tests/fingerprint/Android.mk @@ -0,0 +1,19 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= \ + fingerprint_tests.cpp \ + +LOCAL_SHARED_LIBRARIES := \ + liblog \ + libhardware \ + +#LOCAL_C_INCLUDES += \ +# system/media/camera/include \ + +LOCAL_CFLAGS += -Wall -Wextra + +LOCAL_MODULE:= fingerprint_tests +LOCAL_MODULE_TAGS := tests + +include $(BUILD_NATIVE_TEST) diff --git a/tests/fingerprint/fingerprint_test_fixtures.h b/tests/fingerprint/fingerprint_test_fixtures.h new file mode 100644 index 0000000..a526203 --- /dev/null +++ b/tests/fingerprint/fingerprint_test_fixtures.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2014 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. + */ + +#ifndef __ANDROID_HAL_FINGERPRINT_TEST_COMMON__ +#define __ANDROID_HAL_FINGERPRINT_TEST_COMMON__ + +#include <gtest/gtest.h> +#include <hardware/hardware.h> +#include <hardware/fingerprint.h> + +namespace tests { + +static const uint16_t kVersion = HARDWARE_MODULE_API_VERSION(1, 0); + +class FingerprintModule : public testing::Test { + public: + FingerprintModule() : + fp_module_(NULL) {} + ~FingerprintModule() {} + protected: + virtual void SetUp() { + const hw_module_t *hw_module = NULL; + ASSERT_EQ(0, hw_get_module(FINGERPRINT_HARDWARE_MODULE_ID, &hw_module)) + << "Can't get fingerprint module"; + ASSERT_TRUE(NULL != hw_module) + << "hw_get_module didn't return a valid fingerprint module"; + + fp_module_ = reinterpret_cast<const fingerprint_module_t*>(hw_module); + } + const fingerprint_module_t* fp_module() { return fp_module_; } + private: + const fingerprint_module_t *fp_module_; +}; + +class FingerprintDevice : public FingerprintModule { + public: + FingerprintDevice() : + fp_device_(NULL) {} + ~FingerprintDevice() {} + protected: + virtual void SetUp() { + FingerprintModule::SetUp(); + hw_device_t *device = NULL; + ASSERT_TRUE(NULL != fp_module()->common.methods->open) + << "Fingerprint open() is unimplemented"; + ASSERT_EQ(0, fp_module()->common.methods->open( + (const hw_module_t*)fp_module(), NULL, &device)) + << "Can't open fingerprint device"; + ASSERT_TRUE(NULL != device) + << "Fingerprint open() returned a NULL device"; + ASSERT_EQ(kVersion, device->version) + << "Unsupported version"; + fp_device_ = reinterpret_cast<fingerprint_device_t*>(device); + } + fingerprint_device_t* fp_device() { return fp_device_; } + private: + fingerprint_device_t *fp_device_; +}; + +} // namespace tests + +#endif // __ANDROID_HAL_FINGERPRINT_TEST_COMMON__ diff --git a/tests/fingerprint/fingerprint_tests.cpp b/tests/fingerprint/fingerprint_tests.cpp new file mode 100644 index 0000000..ad6e1dd --- /dev/null +++ b/tests/fingerprint/fingerprint_tests.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2014 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 <gtest/gtest.h> +#include "fingerprint_test_fixtures.h" + +namespace tests { + +TEST_F(FingerprintDevice, isThereEnroll) { + ASSERT_TRUE(NULL != fp_device()->enroll) + << "Enroll function is not implemented"; +} + +TEST_F(FingerprintDevice, isThereRemove) { + ASSERT_TRUE(NULL != fp_device()->remove) + << "Remove function is not implemented"; +} + +TEST_F(FingerprintDevice, isThereMatch) { + ASSERT_TRUE(NULL != fp_device()->match) + << "Match function is not implemented"; +} + +} // namespace tests |