From e8745f30142a2299713120d0c7c4afceadacfe41 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 24 Aug 2024 11:43:30 +0100 Subject: [PATCH] #221 move unit test code around for successful compilation --- test/test_core_items/DateTimeItemTestCases.cpp | 3 --- test/test_core_items/test_main.cpp | 7 +++++++ test/test_menumgr/tcMenuCoreTests.cpp | 13 +------------ test/test_menumgr/test_main.cpp | 2 +- test/tutils/fixtures_extern.h | 17 +++++++++++++++-- 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/test/test_core_items/DateTimeItemTestCases.cpp b/test/test_core_items/DateTimeItemTestCases.cpp index 99cd779..0100541 100644 --- a/test/test_core_items/DateTimeItemTestCases.cpp +++ b/test/test_core_items/DateTimeItemTestCases.cpp @@ -4,9 +4,6 @@ #include "../tutils/fixtures_extern.h" #include -void printMenuItem(MenuItem* menuItem); - - RENDERING_CALLBACK_NAME_INVOKE(timeMenuItemTestCb, timeItemRenderFn, "Time", 103, NULL) RENDERING_CALLBACK_NAME_INVOKE(dateFormattedTestCb, dateItemRenderFn, "Date", 999, NULL) diff --git a/test/test_core_items/test_main.cpp b/test/test_core_items/test_main.cpp index a9403b1..2da8540 100644 --- a/test/test_core_items/test_main.cpp +++ b/test/test_core_items/test_main.cpp @@ -4,6 +4,13 @@ #include #include "../tutils/tcMenuFixturesExtra.h" +const char *uuid1 = "07cd8bc6-734d-43da-84e7-6084990becfc"; +const char *uuid2 = "07cd8bc6-734d-43da-84e7-6084990becfd"; +const char *uuid3 = "07cd8bc6-734d-43da-84e7-6084990becfe"; + +NoRenderer noRenderer; +MockEepromAbstraction eeprom(400); + // core menu item tests void testIpAddressItem(); void testSettingIpItemDirectly(); diff --git a/test/test_menumgr/tcMenuCoreTests.cpp b/test/test_menumgr/tcMenuCoreTests.cpp index f3a5326..2a76612 100644 --- a/test/test_menumgr/tcMenuCoreTests.cpp +++ b/test/test_menumgr/tcMenuCoreTests.cpp @@ -4,6 +4,7 @@ #include #include #include +#include "../tutils/fixtures_extern.h" // here we set the pressMe menu item callback to our standard action callback. void myActionCb(int id); @@ -21,18 +22,6 @@ const char PROGMEM pgmMyName[] = "UnitTest"; int counter = 0; const PROGMEM ConnectorLocalInfo applicationInfo = { "DfRobot", "2ba37227-a412-40b7-94e7-42caf9bb0ff4" }; - -void printMenuItem(MenuItem* menuItem) { - if(menuItem == nullptr) { - serdebugF("NULL"); - } - else { - char buffer[20]; - menuItem->copyNameToBuffer(buffer, sizeof buffer); - serdebug3(menuItem->getId(), menuItem->getMenuType(),buffer); - } -} - bool checkMenuItem(MenuItem* actual, MenuItem* expected) { if(expected != actual) { serdebugF("Menu items are not equal: expected="); diff --git a/test/test_menumgr/test_main.cpp b/test/test_menumgr/test_main.cpp index 3a4aa82..cba4fa6 100644 --- a/test/test_menumgr/test_main.cpp +++ b/test/test_menumgr/test_main.cpp @@ -1,8 +1,8 @@ #include #include -#include "../tutils/fixtures_extern.h" #include "../tutils/tcMenuFixturesExtra.h" #include +#include "../tutils/fixtures_extern.h" // core tests void testTcUtilGetParentAndVisit(); diff --git a/test/tutils/fixtures_extern.h b/test/tutils/fixtures_extern.h index e940a09..9b2fc12 100644 --- a/test/tutils/fixtures_extern.h +++ b/test/tutils/fixtures_extern.h @@ -31,11 +31,12 @@ extern SubMenuItem menuSettings; extern EnumMenuItem menuChannel; extern AnalogMenuItem menuVolume; +extern AnalogMenuItem menuSimple1; +extern AnalogMenuItem menuSimple2; + extern int idOfCallback; extern MockEepromAbstraction eeprom; -void printMenuItem(MenuItem* menuItem); - extern const char pgmMyName[]; extern NoRenderer noRenderer; @@ -45,4 +46,16 @@ extern const char *uuid3; bool checkEditorHints(int start, int end, CurrentEditorRenderingHints::EditorRenderingType ty); +inline void printMenuItem(MenuItem* menuItem) { + if(menuItem == nullptr) { + serdebugF("NULL"); + } + else { + char buffer[20]; + menuItem->copyNameToBuffer(buffer, sizeof buffer); + serdebug3(menuItem->getId(), menuItem->getMenuType(),buffer); + } +} + + #endif //TCLIBRARYDEV_FIXTURES_EXTERN_H