Skip to content

Commit

Permalink
TestEngine: fixed issue using MenuXXX() functions with a relative pat…
Browse files Browse the repository at this point in the history
…h when current SetRef() value is empty.
  • Loading branch information
ocornut committed Jan 29, 2025
1 parent 3dbf348 commit d927339
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ CHANGELOG
Those changes are not all listed here.
** For a while this is going to ONLY INCLUDE BREAKING CHANGES.

2025/01/29:
- TestEngine: fixed issue using MenuXXX() functions with a relative path
when current SetRef() value is empty.

2025/01/20:
- TestEngine: added ItemReadAsString() function helpers to facilitate
retrieving value from a text editable field. (#26, #66)
Expand Down
4 changes: 2 additions & 2 deletions imgui_test_engine/imgui_te_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3417,7 +3417,7 @@ void ImGuiTestContext::MenuAction(ImGuiTestAction action, ImGuiTestRef ref)
const char* path_end = path + strlen(path);

ImGuiWindow* ref_window = nullptr;
if (path[0] == '/' && path[1] == '/')
if ((path[0] == '/' && path[1] == '/') || (RefID == 0))
{
const char* end = strstr(path + 2, "/");
IM_CHECK_SILENT(end != nullptr); // Menu interaction without any menus specified in ref.
Expand All @@ -3428,7 +3428,7 @@ void ImGuiTestContext::MenuAction(ImGuiTestAction action, ImGuiTestRef ref)
if (ref_window == nullptr)
LogError("MenuAction: missing ref window (invalid name \"//%s\" ?", window_name.c_str());
}
else if (RefID)
else
{
ref_window = GetWindowByRef(RefID);
if (ref_window == nullptr)
Expand Down
3 changes: 2 additions & 1 deletion imgui_test_engine/imgui_te_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ struct IMGUI_API ImGuiTestContext
bool TabBarCompareOrder(ImGuiTabBar* tab_bar, const char** tab_order);

// Helpers for MenuBar and Menus widgets
// - e.g. MenuCheck("File/Options/Enable grid");
// - e.g. MenuCheck("File/Options/Enable grid"); // Access menu in current ref window.
// - e.g. MenuClick("//Window/File/Quit"); // Access menu in another window.
void MenuAction(ImGuiTestAction action, ImGuiTestRef ref);
void MenuActionAll(ImGuiTestAction action, ImGuiTestRef ref_parent);
void MenuClick(ImGuiTestRef ref) { MenuAction(ImGuiTestAction_Click, ref); }
Expand Down

0 comments on commit d927339

Please sign in to comment.