From 805305a20723dc5960c289d7b84214c817a07825 Mon Sep 17 00:00:00 2001 From: Pascal Brunot Date: Sun, 11 Aug 2024 23:18:07 +0200 Subject: [PATCH] Tests: rework after DELAY_BETWEEN_SWEEPS --- test/test_logic/test_common.cpp | 8 +++++--- test/test_logic/test_logic.cpp | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/test/test_logic/test_common.cpp b/test/test_logic/test_common.cpp index 0ecb4fb2..e1b7a03a 100644 --- a/test/test_logic/test_common.cpp +++ b/test/test_logic/test_common.cpp @@ -22,24 +22,26 @@ namespace fabomatic::tests { constexpr auto DEFAULT_CYCLES = 3; - // Ignore DELAY_BETWEEN_SWEEPS delay between cards events - rfid.setDisabledUntil(std::nullopt); MockMrfc522 &driver = rfid.getDriver(); driver.resetUid(); + rfid.setDisabledUntil(std::nullopt); + for (auto i = 0; i < DEFAULT_CYCLES; i++) { logic.checkRfid(); + rfid.setDisabledUntil(std::nullopt); } + if (uid.has_value()) { driver.setUid(uid.value(), duration_tap); TEST_ASSERT_TRUE_MESSAGE(uid == rfid.getUid(), "Card UID not equal"); auto start = fabomatic::Tasks::arduinoNow(); - do { logic.checkRfid(); + rfid.setDisabledUntil(std::nullopt); delay(50); } while (duration_tap.has_value() && fabomatic::Tasks::arduinoNow() - start < duration_tap); } diff --git a/test/test_logic/test_logic.cpp b/test/test_logic/test_logic.cpp index 94d28b18..2f64bf12 100644 --- a/test/test_logic/test_logic.cpp +++ b/test/test_logic/test_logic.cpp @@ -141,6 +141,8 @@ namespace fabomatic::tests const auto card_uid = get_test_uid(1); simulate_rfid_card(rfid, logic, card_uid, std::nullopt); + + Tasks::delay(fabomatic::conf::machine::DELAY_BETWEEN_SWEEPS); TEST_ASSERT_TRUE_MESSAGE(rfid.isNewCardPresent(), "New card not present"); TEST_ASSERT_TRUE_MESSAGE(rfid.readCardSerial().has_value(), "Card serial not read"); TEST_ASSERT_TRUE_MESSAGE(rfid.readCardSerial().value() == card_uid, "Card serial not equal"); @@ -271,8 +273,8 @@ namespace fabomatic::tests TEST_ASSERT_EQUAL_UINT16_MESSAGE(BoardLogic::Status::MaintenanceNeeded, logic.getStatus(), "Status not MaintenanceNeeded"); simulate_rfid_card(rfid, logic, std::nullopt); - simulate_rfid_card(rfid, logic, card_admin, conf::machine::LONG_TAP_DURATION + 10s); // Log in + Conferma manutenzione perché non ritorna prima della conclusione - simulate_rfid_card(rfid, logic, std::nullopt); // Card away + simulate_rfid_card(rfid, logic, card_admin, conf::machine::LONG_TAP_DURATION + 3s); // Log in + Conferma manutenzione perché non ritorna prima della conclusione + simulate_rfid_card(rfid, logic, std::nullopt); // Card away TEST_ASSERT_EQUAL_UINT16_MESSAGE(BoardLogic::Status::MachineInUse, logic.getStatus(), "Status not MachineInUse by admin"); TEST_ASSERT_FALSE_MESSAGE(logic.getMachine().isMaintenanceNeeded(), "Maintenance not cleared by admin"); @@ -355,7 +357,7 @@ void setup() { delay(1000); esp_log_level_set(TAG, LOG_LOCAL_LEVEL); - + auto config = fabomatic::SavedConfig::LoadFromEEPROM(); UNITY_BEGIN(); RUN_TEST(fabomatic::tests::test_machine_defaults);