-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀️ Merge branch 'yann/test/rfid/deep-sleep-rfidkit-functional-tests' …
…into develop
- Loading branch information
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Leka - LekaOS | ||
# Copyright 2024 APF France handicap | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
register_functional_test( | ||
TARGET | ||
functional_ut_deep_sleep_rfid_kit | ||
|
||
INCLUDE_DIRECTORIES | ||
|
||
SOURCES | ||
suite_rfid_kit.cpp | ||
|
||
LINK_LIBRARIES | ||
CoreBufferedSerial | ||
CoreRFIDReader | ||
RFIDKit | ||
) |
90 changes: 90 additions & 0 deletions
90
tests/functional/tests/deep_sleep_rfid_kit/suite_rfid_kit.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Leka - LekaOS | ||
// Copyright 2024 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "CoreBufferedSerial.h" | ||
#include "CoreRFIDReaderCR95HF.h" | ||
#include "RFIDKit.h" | ||
#include "tests/config.h" | ||
#include "tests/utils.h" | ||
#include "tests/utils_sleep.h" | ||
|
||
using namespace leka; | ||
using namespace boost::ut; | ||
using namespace std::chrono; | ||
using namespace boost::ut::bdd; | ||
|
||
auto rfidserial = CoreBufferedSerial(RFID_UART_TX, RFID_UART_RX, 57600); | ||
auto rfidreader = CoreRFIDReaderCR95HF(rfidserial); | ||
auto rfidkit = RFIDKit(rfidreader); | ||
|
||
suite suite_rfid_kit = [] { | ||
scenario("rfid initialization") = [] { | ||
given("rfid is in default configuration") = [] { | ||
rfidkit.init(); | ||
rtos::ThisThread::sleep_for(5ms); | ||
|
||
expect(neq(&rfidkit, nullptr)); | ||
|
||
when("I do nothing") = [&] { | ||
then("I expect deep sleep TO NOT BE possible") = [] { | ||
auto status = utils::sleep::system_deep_sleep_check(); | ||
|
||
expect(not status.test_check_ok); | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
scenario("enabled/disable deepsleep") = [] { | ||
given("rfid is in default configuration") = [] { | ||
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 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 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 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); | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; |