Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ (functional): RFIDKit - Add card detection test #1448

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 card TO BE detected") = [&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 card TO NOT BE detected") = [&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 card TO BE detected") = [&cardDetected] { expect(cardDetected); };
};
};
};
};