diff --git a/vibrator/1.0/vts/functional/Android.bp b/vibrator/1.0/vts/functional/Android.bp new file mode 100644 index 0000000000..22b7536ecf --- /dev/null +++ b/vibrator/1.0/vts/functional/Android.bp @@ -0,0 +1,32 @@ +// +// 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: "vibrator_hidl_hal_test", + gtest: true, + srcs: ["vibrator_hidl_hal_test.cpp"], + shared_libs: [ + "liblog", + "libutils", + "android.hardware.vibrator@1.0", + ], + static_libs: ["libgtest"], + cflags: [ + "-O0", + "-g", + ], +} + diff --git a/vibrator/1.0/vts/functional/vibrator_hidl_hal_test.cpp b/vibrator/1.0/vts/functional/vibrator_hidl_hal_test.cpp new file mode 100644 index 0000000000..659508db7e --- /dev/null +++ b/vibrator/1.0/vts/functional/vibrator_hidl_hal_test.cpp @@ -0,0 +1,67 @@ +/* + * 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 "vibrator_hidl_hal_test" + +#include +#include +#include +#include +#include + +using ::android::hardware::vibrator::V1_0::IVibrator; +using ::android::hardware::vibrator::V1_0::Status; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +#define VIBRATOR_SERVICE_NAME "vibrator" + +// The main test class for VIBRATOR HIDL HAL. +class VibratorHidlTest : public ::testing::Test { + public: + virtual void SetUp() override { + vibrator = IVibrator::getService(VIBRATOR_SERVICE_NAME, false); + ASSERT_NE(vibrator, nullptr); + } + + virtual void TearDown() override {} + + sp vibrator; +}; + +// A class for test environment setup (kept since this file is a template). +class VibratorHidlEnvironment : public ::testing::Environment { + public: + virtual void SetUp() {} + virtual void TearDown() {} + + private: +}; + +TEST_F(VibratorHidlTest, OnThenOffBeforeTimeout) { + EXPECT_EQ(Status::OK, vibrator->on(2000)); + sleep(1); + EXPECT_EQ(Status::OK, vibrator->off()); +} + +int main(int argc, char **argv) { + ::testing::AddGlobalTestEnvironment(new VibratorHidlEnvironment); + ::testing::InitGoogleTest(&argc, argv); + int status = RUN_ALL_TESTS(); + ALOGI("Test result = %d", status); + return status; +} diff --git a/vibrator/Android.bp b/vibrator/Android.bp index ba90f2c9d1..ed19a37034 100644 --- a/vibrator/Android.bp +++ b/vibrator/Android.bp @@ -2,4 +2,5 @@ subdirs = [ "1.0", "1.0/default", + "1.0/vts/functional", ]