Skip to content

Commit d927339

Browse files
committed
TestEngine: fixed issue using MenuXXX() functions with a relative path when current SetRef() value is empty.
1 parent 3dbf348 commit d927339

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

docs/CHANGELOG.txt

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ CHANGELOG
55
Those changes are not all listed here.
66
** For a while this is going to ONLY INCLUDE BREAKING CHANGES.
77

8+
2025/01/29:
9+
- TestEngine: fixed issue using MenuXXX() functions with a relative path
10+
when current SetRef() value is empty.
11+
812
2025/01/20:
913
- TestEngine: added ItemReadAsString() function helpers to facilitate
1014
retrieving value from a text editable field. (#26, #66)

imgui_test_engine/imgui_te_context.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3417,7 +3417,7 @@ void ImGuiTestContext::MenuAction(ImGuiTestAction action, ImGuiTestRef ref)
34173417
const char* path_end = path + strlen(path);
34183418

34193419
ImGuiWindow* ref_window = nullptr;
3420-
if (path[0] == '/' && path[1] == '/')
3420+
if ((path[0] == '/' && path[1] == '/') || (RefID == 0))
34213421
{
34223422
const char* end = strstr(path + 2, "/");
34233423
IM_CHECK_SILENT(end != nullptr); // Menu interaction without any menus specified in ref.
@@ -3428,7 +3428,7 @@ void ImGuiTestContext::MenuAction(ImGuiTestAction action, ImGuiTestRef ref)
34283428
if (ref_window == nullptr)
34293429
LogError("MenuAction: missing ref window (invalid name \"//%s\" ?", window_name.c_str());
34303430
}
3431-
else if (RefID)
3431+
else
34323432
{
34333433
ref_window = GetWindowByRef(RefID);
34343434
if (ref_window == nullptr)

imgui_test_engine/imgui_te_context.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ struct IMGUI_API ImGuiTestContext
462462
bool TabBarCompareOrder(ImGuiTabBar* tab_bar, const char** tab_order);
463463

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

0 commit comments

Comments
 (0)