diff options
author | Siarhei Vishniakou <svv@google.com> | 2020-03-30 17:17:21 -0700 |
---|---|---|
committer | Siarhei Vishniakou <svv@google.com> | 2020-03-30 17:23:11 -0700 |
commit | 25a866eecc75058be54a837fe5c00df496e626ca (patch) | |
tree | 2f4b912a74ee063c09938ad078a065b480aeed7b /input | |
parent | 55a25b2d47a9b72ba2eb02f26c742d9f57a4fcfb (diff) |
Convert InputClassifierTest to parametrized test
The test is currently based on old vts harness and not in vts suite.
Bug: 150383004
Test: atest VtsHalInputClassifierV1_0TargetTest
Change-Id: I5df4eff845fd49b8663d1589c5314d5acf4b5057
Diffstat (limited to 'input')
-rw-r--r-- | input/classifier/1.0/vts/functional/Android.bp | 6 | ||||
-rw-r--r-- | input/classifier/1.0/vts/functional/VtsHalInputClassifierV1_0TargetTest.cpp | 47 |
2 files changed, 18 insertions, 35 deletions
diff --git a/input/classifier/1.0/vts/functional/Android.bp b/input/classifier/1.0/vts/functional/Android.bp index ef49d70dfb..4db1398778 100644 --- a/input/classifier/1.0/vts/functional/Android.bp +++ b/input/classifier/1.0/vts/functional/Android.bp @@ -22,6 +22,8 @@ cc_test { "android.hardware.input.classifier@1.0", "android.hardware.input.common@1.0", ], - test_suites: ["general-tests"], + test_suites: [ + "general-tests", + "vts-core", + ], } - diff --git a/input/classifier/1.0/vts/functional/VtsHalInputClassifierV1_0TargetTest.cpp b/input/classifier/1.0/vts/functional/VtsHalInputClassifierV1_0TargetTest.cpp index f033c2a102..ee529c73b0 100644 --- a/input/classifier/1.0/vts/functional/VtsHalInputClassifierV1_0TargetTest.cpp +++ b/input/classifier/1.0/vts/functional/VtsHalInputClassifierV1_0TargetTest.cpp @@ -16,11 +16,12 @@ #define LOG_TAG "input_classifier_hal_test" -#include <VtsHalHidlTargetTestBase.h> -#include <VtsHalHidlTargetTestEnvBase.h> #include <android-base/logging.h> #include <android/hardware/input/classifier/1.0/IInputClassifier.h> #include <android/hardware/input/common/1.0/types.h> +#include <gtest/gtest.h> +#include <hidl/GtestPrinter.h> +#include <hidl/ServiceManagement.h> #include <input/InputDevice.h> #include <unistd.h> @@ -72,27 +73,11 @@ static MotionEvent getSimpleMotionEvent() { return event; } -// Test environment for Input Classifier HIDL HAL. -class InputClassifierHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { - public: - // get the test environment singleton - static InputClassifierHidlEnvironment* Instance() { - static InputClassifierHidlEnvironment* instance = new InputClassifierHidlEnvironment; - return instance; - } - - virtual void registerTestServices() override { registerTestService<IInputClassifier>(); } - - private: - InputClassifierHidlEnvironment() {} -}; - // The main test class for INPUT CLASSIFIER HIDL HAL 1.0. -class InputClassifierHidlTest_1_0 : public ::testing::VtsHalHidlTargetTestBase { +class InputClassifierHidlTest_1_0 : public ::testing::TestWithParam<std::string> { public: virtual void SetUp() override { - classifier = ::testing::VtsHalHidlTargetTestBase::getService<IInputClassifier>( - InputClassifierHidlEnvironment::Instance()->getServiceName<IInputClassifier>()); + classifier = IInputClassifier::getService(GetParam()); ASSERT_NE(classifier, nullptr); } @@ -105,7 +90,7 @@ class InputClassifierHidlTest_1_0 : public ::testing::VtsHalHidlTargetTestBase { * Call resetDevice(..) for a few common device id values, and make sure that the HAL * can handle the resets gracefully. */ -TEST_F(InputClassifierHidlTest_1_0, ResetDevice) { +TEST_P(InputClassifierHidlTest_1_0, ResetDevice) { EXPECT_TRUE(classifier->resetDevice(ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID).isOk()); EXPECT_TRUE(classifier->resetDevice(ReservedInputDeviceId::BUILT_IN_KEYBOARD_ID).isOk()); EXPECT_TRUE(classifier->resetDevice(1).isOk()); @@ -115,14 +100,14 @@ TEST_F(InputClassifierHidlTest_1_0, ResetDevice) { /** * Call reset() on the HAL to ensure no fatal failure there. */ -TEST_F(InputClassifierHidlTest_1_0, ResetHal) { +TEST_P(InputClassifierHidlTest_1_0, ResetHal) { EXPECT_TRUE(classifier->reset().isOk()); } /** * Classify an event without any video frames. */ -TEST_F(InputClassifierHidlTest_1_0, Classify_NoVideoFrame) { +TEST_P(InputClassifierHidlTest_1_0, Classify_NoVideoFrame) { // Create a MotionEvent that does not have any video data MotionEvent event = getSimpleMotionEvent(); @@ -137,7 +122,7 @@ TEST_F(InputClassifierHidlTest_1_0, Classify_NoVideoFrame) { /** * Classify an event with one video frame. Should be the most common scenario. */ -TEST_F(InputClassifierHidlTest_1_0, Classify_OneVideoFrame) { +TEST_P(InputClassifierHidlTest_1_0, Classify_OneVideoFrame) { MotionEvent event = getSimpleMotionEvent(); VideoFrame frame; frame.data = {1, 2, 3, 4}; @@ -163,7 +148,7 @@ TEST_F(InputClassifierHidlTest_1_0, Classify_OneVideoFrame) { * monotonically increasing timestamps. Still, we provide consistent timestamps here since that * is the most realistic mode of operation. */ -TEST_F(InputClassifierHidlTest_1_0, Classify_TwoVideoFrames) { +TEST_P(InputClassifierHidlTest_1_0, Classify_TwoVideoFrames) { MotionEvent event = getSimpleMotionEvent(); VideoFrame frame1; frame1.data = {1, 2, 3, 4}; @@ -183,11 +168,7 @@ TEST_F(InputClassifierHidlTest_1_0, Classify_TwoVideoFrames) { classifier->reset(); } -int main(int argc, char** argv) { - ::testing::AddGlobalTestEnvironment(InputClassifierHidlEnvironment::Instance()); - ::testing::InitGoogleTest(&argc, argv); - InputClassifierHidlEnvironment::Instance()->init(&argc, argv); - int status = RUN_ALL_TESTS(); - LOG(INFO) << "Test result = " << status; - return status; -} +INSTANTIATE_TEST_SUITE_P( + PerInstance, InputClassifierHidlTest_1_0, + testing::ValuesIn(android::hardware::getAllHalInstanceNames(IInputClassifier::descriptor)), + android::hardware::PrintInstanceNameToString); |