Skip to content

Commit

Permalink
Merge pull request #227 from TcMenu/main-unity-fixes
Browse files Browse the repository at this point in the history
#221 fix broken tests.
  • Loading branch information
davetcc authored Aug 25, 2024
2 parents 95fd259 + 44a5d69 commit 402a49f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions test/test_core_items/RuntimeItemTestCases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,15 @@ void myActionCb(int id) {

void testActionMenuItem() {
char sz[20];
menuPressMe.copyNameToBuffer(sz, sizeof(sz));
TEST_ASSERT_EQUAL_STRING("Press Me", sz);
TEST_ASSERT_TRUE(!isMenuRuntime(&menuPressMe));
TEST_ASSERT_TRUE(menuPressMe.getMenuType() == MENUTYPE_ACTION_VALUE);
TEST_ASSERT_EQUAL((uint16_t)7, menuSub.getId());
TEST_ASSERT_EQUAL((uint16_t)-1, menuSub.getEepromPosition());
AnyMenuInfo menuInfo = { "Lights, Camera", 999, 0xFFFF, 1, myActionCb };
ActionMenuItem actionMenuItem(&menuInfo, nullptr, INFO_LOCATION_RAM);
actionMenuItem.copyNameToBuffer(sz, sizeof(sz));
TEST_ASSERT_EQUAL_STRING("Lights, Camera", sz);
TEST_ASSERT_FALSE(isMenuRuntime(&actionMenuItem));
TEST_ASSERT_EQUAL(actionMenuItem.getMenuType(), MENUTYPE_ACTION_VALUE);
TEST_ASSERT_EQUAL((uint16_t)999, actionMenuItem.getId());
TEST_ASSERT_EQUAL((uint16_t)-1, actionMenuItem.getEepromPosition());
auto oldCbCount = actionCbCount;
menuPressMe.triggerCallback();
actionMenuItem.triggerCallback();
TEST_ASSERT_EQUAL(oldCbCount + 1, actionCbCount);

copyMenuItemNameAndValue(&menuPressMe, sz, sizeof sz);
TEST_ASSERT_EQUAL_STRING("Press Me: >>", sz);
}
2 changes: 1 addition & 1 deletion test/test_menumgr/tcMenuCoreTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void testIteratorGetSubMenu() {
// passing in null returns null
TEST_ASSERT_TRUE(getSubMenuFor(nullptr) == nullptr);
// root is presented as null
TEST_ASSERT_TRUE(getSubMenuFor(&menuVolume) == nullptr);
TEST_ASSERT_TRUE(getSubMenuFor(&menuVolume) == &MenuManager::ROOT);
// now check both menu levels including providing a submenu within a submenu
TEST_ASSERT_TRUE(checkMenuItem(getSubMenuFor(&menuPressMe), &menuSecondLevel));
TEST_ASSERT_TRUE(checkMenuItem(getSubMenuFor(&menuSecondLevel), &menuStatus));
Expand Down

0 comments on commit 402a49f

Please sign in to comment.