From 62de6a18e583b37b56f3f67847357a0c10eb112a Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Tue, 6 Feb 2024 11:27:06 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20(functional):=20RFIDKit=20-=20Add?= =?UTF-8?q?=20card=20detection=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../deep_sleep_rfid_kit/suite_rfid_kit.cpp | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/functional/tests/deep_sleep_rfid_kit/suite_rfid_kit.cpp b/tests/functional/tests/deep_sleep_rfid_kit/suite_rfid_kit.cpp index 70c341ac6..5b17a1283 100644 --- a/tests/functional/tests/deep_sleep_rfid_kit/suite_rfid_kit.cpp +++ b/tests/functional/tests/deep_sleep_rfid_kit/suite_rfid_kit.cpp @@ -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); }; + }; + }; + }; };