diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index c21d13630..35fe44b83 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -47,6 +47,7 @@ add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/deep_sleep_core_pwm) add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/deep_sleep_imu) add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/deep_sleep_log_kit) add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/deep_sleep_mbed_hal) +add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/deep_sleep_rfid_kit) add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/file_manager) add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/firmware_kit) add_subdirectory(${TESTS_FUNCTIONAL_TESTS_DIR}/imu_kit) diff --git a/tests/functional/tests/deep_sleep_rfid_kit/CMakeLists.txt b/tests/functional/tests/deep_sleep_rfid_kit/CMakeLists.txt new file mode 100644 index 000000000..d76ba1f74 --- /dev/null +++ b/tests/functional/tests/deep_sleep_rfid_kit/CMakeLists.txt @@ -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 +) 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 new file mode 100644 index 000000000..70c341ac6 --- /dev/null +++ b/tests/functional/tests/deep_sleep_rfid_kit/suite_rfid_kit.cpp @@ -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); + }; + }; + }; + }; +};