Add Test cases to Nfc VTS

- Call close() after close()
- Call open() after open()
- Call powerCycle() after close()
- Call preDiscover() after close()
- Call controlGranted() after close()
- Call coreInitialized() with different data

Test: VTS test passes
Bug: 32024301
Change-Id: I7cd986887ccbf2774d5eace9c975a9a55ee46364
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
This commit is contained in:
Ruchi Kandoi 2017-01-25 17:08:35 -08:00
parent 89145d5849
commit 3d7c5f974c

View file

@ -324,19 +324,43 @@ TEST_F(NfcHidlTest, PowerCycle) {
EXPECT_EQ(NfcStatus::OK, last_status_);
}
/*
* PowerCycleAfterClose:
* Calls powerCycle() after close()
* Checks status
*/
TEST_F(NfcHidlTest, PowerCycleAfterClose) {
EXPECT_EQ(NfcStatus::OK, nfc_->close());
// Wait for CLOSE_CPLT event
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
EXPECT_EQ(NfcStatus::OK, last_status_);
EXPECT_EQ(NfcStatus::FAILED, nfc_->powerCycle());
EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
// Wait for OPEN_CPLT event
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
EXPECT_EQ(NfcStatus::OK, last_status_);
}
/*
* CoreInitialized:
* Calls coreInitialized()
* Calls coreInitialized() with different data
* Waits for NfcEvent.POST_INIT_CPLT
*/
TEST_F(NfcHidlTest, CoreInitialized) {
NfcData data;
data.resize(1);
data[0] = 0;
EXPECT_EQ(NfcStatus::OK, nfc_->coreInitialized(data));
// Wait for NfcEvent.POST_INIT_CPLT
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(NfcEvent::POST_INIT_CPLT, last_event_);
for (int i = 0; i <= 6; i++)
{
data[0] = i;
EXPECT_EQ(NfcStatus::OK, nfc_->coreInitialized(data));
// Wait for NfcEvent.POST_INIT_CPLT
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(NfcEvent::POST_INIT_CPLT, last_event_);
}
}
/*
@ -348,6 +372,27 @@ TEST_F(NfcHidlTest, ControlGranted) {
EXPECT_EQ(NfcStatus::OK, nfc_->controlGranted());
}
/*
* ControlGrantedAfterClose:
* Call controlGranted() after close
* Checks the return value
*/
TEST_F(NfcHidlTest, ControlGrantedAfterClose) {
EXPECT_EQ(NfcStatus::OK, nfc_->close());
// Wait for CLOSE_CPLT event
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
EXPECT_EQ(NfcStatus::OK, last_status_);
EXPECT_EQ(NfcStatus::OK, nfc_->controlGranted());
EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
// Wait for OPEN_CPLT event
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
EXPECT_EQ(NfcStatus::OK, last_status_);
}
/* PreDiscover:
* Calls prediscover()
* Checks the return value
@ -356,6 +401,59 @@ TEST_F(NfcHidlTest, PreDiscover) {
EXPECT_EQ(NfcStatus::OK, nfc_->prediscover());
}
/*
* PreDiscoverAfterClose:
* Call prediscover() after close
* Checks the return value
*/
TEST_F(NfcHidlTest, PreDiscoverAfterClose) {
EXPECT_EQ(NfcStatus::OK, nfc_->close());
// Wait for CLOSE_CPLT event
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
EXPECT_EQ(NfcStatus::OK, last_status_);
EXPECT_EQ(NfcStatus::OK, nfc_->prediscover());
EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
// Wait for OPEN_CPLT event
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
EXPECT_EQ(NfcStatus::OK, last_status_);
}
/*
* CloseAfterClose:
* Calls close() multiple times
* Checks status
*/
TEST_F(NfcHidlTest, CloseAfterClose) {
EXPECT_EQ(NfcStatus::OK, nfc_->close());
// Wait for CLOSE_CPLT event
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
EXPECT_EQ(NfcStatus::OK, last_status_);
EXPECT_EQ(NfcStatus::FAILED, nfc_->close());
EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
// Wait for OPEN_CPLT event
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
EXPECT_EQ(NfcStatus::OK, last_status_);
}
/*
* OpenAfterOpen:
* Calls open() multiple times
* Checks status
*/
TEST_F(NfcHidlTest, OpenAfterOpen) {
EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
}
int main(int argc, char** argv) {
::testing::AddGlobalTestEnvironment(new NfcHidlEnvironment);
::testing::InitGoogleTest(&argc, argv);