From 9ec2405e1ae2652763a76ca5f56f4ff2f5eec66f Mon Sep 17 00:00:00 2001 From: Steve Pomeroy Date: Thu, 18 Jul 2024 18:50:43 +0000 Subject: [PATCH] Use parameterized test to disable test for devices without NFC Test: atest VtsNfcBehaviorChangesTest Bug: 345575225 (cherry picked from https://android-review.googlesource.com/q/commit:a667849ed08197a0811857939d63cdf923f6818d) Merged-In: I22393acc260d200d2e472d276c64af005a75ab6b Change-Id: I22393acc260d200d2e472d276c64af005a75ab6b --- .../vts/functional/VtsNfcBehaviorChangesTest.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/nfc/aidl/vts/functional/VtsNfcBehaviorChangesTest.cpp b/nfc/aidl/vts/functional/VtsNfcBehaviorChangesTest.cpp index 0b73cc991a..ff2522cb35 100644 --- a/nfc/aidl/vts/functional/VtsNfcBehaviorChangesTest.cpp +++ b/nfc/aidl/vts/functional/VtsNfcBehaviorChangesTest.cpp @@ -16,6 +16,10 @@ #define LOG_TAG "nfc_behavior_changes_test" +#include +#include +#include +#include #include #include #include @@ -30,6 +34,9 @@ #include "nfa_api.h" #include "nfa_ee_api.h" +using aidl::android::hardware::nfc::INfc; +using android::getAidlHalInstanceNames; +using android::PrintInstanceNameToString; using android::base::StringPrintf; static SyncEvent sNfaEnableEvent; // event for NFA_Enable() @@ -162,7 +169,7 @@ tNFA_STATUS static nfaObserveModeEnable(bool enable) { return status; } -class NfcBehaviorChanges : public testing::Test { +class NfcBehaviorChanges : public testing::TestWithParam { protected: void SetUp() override { tNFA_STATUS status = NFA_STATUS_OK; @@ -202,7 +209,7 @@ class NfcBehaviorChanges : public testing::Test { * * @VsrTest = GMS-VSR-3.2.8-001 */ -TEST_F(NfcBehaviorChanges, ObserveModeEnableDisable) { +TEST_P(NfcBehaviorChanges, ObserveModeEnableDisable) { tNFA_STATUS status = nfaObserveModeEnable(true); ASSERT_EQ(status, NFA_STATUS_OK); @@ -210,6 +217,11 @@ TEST_F(NfcBehaviorChanges, ObserveModeEnableDisable) { ASSERT_EQ(status, NFA_STATUS_OK); } +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(NfcBehaviorChanges); +INSTANTIATE_TEST_SUITE_P(Nfc, NfcBehaviorChanges, + testing::ValuesIn(::android::getAidlHalInstanceNames(INfc::descriptor)), + ::android::PrintInstanceNameToString); + int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); ABinderProcess_startThreadPool();