Skip to content

Commit

Permalink
TestEngine: added ImGuiTestEngine_UnregisterAllTests() helper functio…
Browse files Browse the repository at this point in the history
…n. (#67)
  • Loading branch information
ocornut committed Jan 20, 2025
1 parent e6b97aa commit c0c97eb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CHANGELOG
- TestEngine: *BREAKING* renamed ItemSelectAndReadValue() functions
to ItemReadAsInt(), ItemReadAsFloat(), ItemReadAsScalar(), simplified
their use and signatures.
- TestEngine: added ImGuiTestEngine_UnregisterAllTests() helper function.

2024/12/20:
- TestEngine: fixed error recovery mis-asserting after a GuiFunc triggered
Expand Down
11 changes: 11 additions & 0 deletions imgui_test_engine/imgui_te_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,17 @@ void ImGuiTestEngine_UnregisterTest(ImGuiTestEngine* engine, ImGuiTest* test)
IM_DELETE(test);
}

void ImGuiTestEngine_UnregisterAllTests(ImGuiTestEngine* engine)
{
// Cannot unregister a running test. Please contact us if you need this.
IM_ASSERT(engine->TestContext == NULL);

engine->TestsAll.clear_delete();
engine->TestsQueue.clear();
engine->UiSelectAndScrollToTest = NULL;
engine->UiSelectedTest = NULL;
}

ImGuiPerfTool* ImGuiTestEngine_GetPerfTool(ImGuiTestEngine* engine)
{
return engine->PerfTool;
Expand Down
1 change: 1 addition & 0 deletions imgui_test_engine/imgui_te_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ IMGUI_API ImGuiTestEngineIO& ImGuiTestEngine_GetIO(ImGuiTestEngine* engine);
#define IM_REGISTER_TEST(_ENGINE, _CATEGORY, _NAME) ImGuiTestEngine_RegisterTest(_ENGINE, _CATEGORY, _NAME, __FILE__, __LINE__)
IMGUI_API ImGuiTest* ImGuiTestEngine_RegisterTest(ImGuiTestEngine* engine, const char* category, const char* name, const char* src_file = NULL, int src_line = 0); // Prefer calling IM_REGISTER_TEST()
IMGUI_API void ImGuiTestEngine_UnregisterTest(ImGuiTestEngine* engine, ImGuiTest* test);
IMGUI_API void ImGuiTestEngine_UnregisterAllTests(ImGuiTestEngine* engine);

// Functions: Main
IMGUI_API void ImGuiTestEngine_QueueTest(ImGuiTestEngine* engine, ImGuiTest* test, ImGuiTestRunFlags run_flags = 0);
Expand Down

0 comments on commit c0c97eb

Please sign in to comment.