Skip to content

Commit

Permalink
✅ (functional): RFIDKit - Add card detection test
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Jul 10, 2024
1 parent 68d3719 commit 342db27
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/functional/tests/deep_sleep_rfid_kit/suite_rfid_kit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,56 @@ suite suite_rfid_kit = [] {
};
};
};

scenario("enabled/disable deepsleep then magic card detected") = [] {
given("rfid is in default configuration") = [] {
auto cardDetected = false;
rfidkit.onTagActivated([&cardDetected](const MagicCard &card) { cardDetected = true; });

when("I wait") = [&] {
cardDetected = false;
rtos::ThisThread::sleep_for(1s);

then("I expect TO detect card") = [&cardDetected] { expect(cardDetected); };
};

when("I enable rfid deep sleep") = [&] {
rtos::ThisThread::sleep_for(500ms);
rfidkit.enableDeepSleep();
rtos::ThisThread::sleep_for(500ms);

then("I expect deep sleep TO BE possible") = [] {
auto status = utils::sleep::system_deep_sleep_check();

expect(status.test_check_ok);
};
};

when("I wait") = [&] {
cardDetected = false;
rtos::ThisThread::sleep_for(1s);

then("I expect TO NOT detect card") = [&cardDetected] { expect(not cardDetected); };
};

when("I disable rfid deep sleep") = [&] {
rtos::ThisThread::sleep_for(500ms);
rfidkit.disableDeepSleep();
rtos::ThisThread::sleep_for(500ms);

then("I expect deep sleep TO NOT BE possible") = [] {
auto status = utils::sleep::system_deep_sleep_check();

expect(not status.test_check_ok);
};
};

when("I wait") = [&] {
cardDetected = false;
rtos::ThisThread::sleep_for(1s);

then("I expect TO detect card") = [&cardDetected] { expect(cardDetected); };
};
};
};
};

0 comments on commit 342db27

Please sign in to comment.