From 185b5a749226f5185f768b0fdcf4a312112493e3 Mon Sep 17 00:00:00 2001 From: Ruchi Kandoi Date: Wed, 18 Jan 2017 11:12:58 -0800 Subject: [PATCH] NFC: Update VTS test - Order of data and CORE_CONN_CREDITS_NTF is not defined, check for the order in which they were received before checking for contents - Configuration status is added to WriteCoreReset test - Add WriteCoreResetConfigReset test Test: VTS test passes Change-Id: Ifb730bbb51c366807028fe7e6757c0f8eae943c3 Signed-off-by: Ruchi Kandoi --- nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp | 36 +++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp b/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp index a50d88f55c..a0c5f1aee9 100644 --- a/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp +++ b/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp @@ -40,6 +40,8 @@ using ::android::sp; /* NCI Commands */ #define CORE_RESET_CMD \ { 0x20, 0x00, 0x01, 0x00 } +#define CORE_RESET_CMD_CONFIG_RESET \ + { 0x20, 0x00, 0x01, 0x01 } #define CORE_CONN_CREATE_CMD \ { 0x20, 0x04, 0x02, 0x01, 0x00 } #define INVALID_COMMAND \ @@ -166,7 +168,7 @@ TEST_F(NfcHidlTest, OpenAndClose) {} * WriteCoreReset: * Sends CORE_RESET_CMD * Waits for CORE_RESET_RSP - * Checks the status and the version number + * Checks the status, version number and configuration status */ TEST_F(NfcHidlTest, WriteCoreReset) { std::vector cmd = CORE_RESET_CMD; @@ -178,6 +180,26 @@ TEST_F(NfcHidlTest, WriteCoreReset) { EXPECT_EQ(6ul, last_data_[0].size()); EXPECT_EQ((int)NfcStatus::OK, last_data_[0][3]); EXPECT_GE(VERSION, last_data_[0][4]); + EXPECT_EQ(0ul, last_data_[0][5]); +} + +/* + * WriteCoreResetConfigReset: + * Sends CORE_RESET_CMD_CONFIG_RESET + * Waits for CORE_RESET_RSP + * Checks the status, version number and configuration status + */ +TEST_F(NfcHidlTest, WriteCoreResetConfigReset) { + std::vector cmd = CORE_RESET_CMD_CONFIG_RESET; + NfcData data = cmd; + EXPECT_EQ(data.size(), nfc_->write(data)); + // Wait for CORE_RESET_RSP + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(1ul, last_data_.size()); + EXPECT_EQ(6ul, last_data_[0].size()); + EXPECT_EQ((int)NfcStatus::OK, last_data_[0][3]); + EXPECT_GE(VERSION, last_data_[0][4]); + EXPECT_EQ(1ul, last_data_[0][5]); } /* @@ -273,14 +295,18 @@ TEST_F(NfcHidlTest, Bandwidth) { EXPECT_EQ(std::cv_status::no_timeout, wait()); // Check if the same data was recieved back EXPECT_EQ(2ul, last_data_.size()); - EXPECT_EQ(data.size(), last_data_[0].size()); + + /* It is possible that CORE_CONN_CREDITS_NTF is received before data, + * Find the order and do further checks depending on that */ + uint8_t data_index = last_data_[0].size() == data.size() ? 0 : 1; + EXPECT_EQ(data.size(), last_data_[data_index].size()); for (size_t i = 0; i < data.size(); i++) { - EXPECT_EQ(data[i], last_data_[0][i]); + EXPECT_EQ(data[i], last_data_[data_index][i]); } - EXPECT_EQ(6ul, last_data_[1].size()); + EXPECT_EQ(6ul, last_data_[!data_index].size()); // Check if the credit is refilled to 1 - EXPECT_EQ(1, last_data_[1][5]); + EXPECT_EQ(1, last_data_[!data_index][5]); } }