Dear ImGui Test Engine: automate and test an app, by scripting mouse and keyboard actions on its widgets.
The C++ API of Dear ImGui as it is bound to Python: the entries of the module imgui_bundle.imgui.test_engine, in the same order, with their C++ signatures and the headers’ comments. From the stubs: the functions excluded from the bindings, the typedefs and the macros are absent.
Demos using it¶
The demos of the catalog that use it (the pictures link to their code and to the playground).

Test engine¶
Three windows: the Dear ImGui demo, the ImGui Test Engine panel, and a few buttons that run tests.
More
Watch a test drive the mouse and the keyboard: it opens tree nodes, clicks buttons, types text, and checks the results. See the test engine doc.
Desktop only

Drive an app, capture screenshots¶
A test function drives the app: it clicks, moves a slider, opens a header, and takes a screenshot at each step.
More
immapp.testing.run() starts the app, runs the test function, then exits. Handy for automated checks and for documentation pictures. See the test engine doc.
Desktop only
imgui_te_exporters.h¶
Forward Declarations¶
Types¶
TestEngineExportFormat (enum)¶
| Member | Value | |
|---|---|---|
ImGuiTestEngineExportFormat_None = 0 | 0 | |
ImGuiTestEngineExportFormat_JUnitXml, } | 1 |
Functions¶
ImGuiTestEngine_PrintResultSummary¶
void ImGuiTestEngine_PrintResultSummary(ImGuiTestEngine* engine);(private API)
ImGuiTestEngine_Export¶
void ImGuiTestEngine_Export(ImGuiTestEngine* engine);(private API)
ImGuiTestEngine_ExportEx¶
void ImGuiTestEngine_ExportEx(ImGuiTestEngine* engine, ImGuiTestEngineExportFormat format, const char* filename);(private API)
imgui_te_engine.h¶
TestActiveFunc (enum)¶
Stored in ImGuiTestContext: where we are currently running GuiFunc or TestFunc
| Member | Value | |
|---|---|---|
ImGuiTestActiveFunc_None | 0 | |
ImGuiTestActiveFunc_GuiFunc | 1 | == GuiFunc() handler |
ImGuiTestActiveFunc_TestFunc | 2 | == TestFunc() handler |
ImGuiTestActiveFunc_TeardownFunc | 3 | == TeardownFunc() handler |
TestRunSpeed (enum)¶
| Member | Value | |
|---|---|---|
ImGuiTestRunSpeed_Fast = 0 | 0 | Run tests as fast as possible (teleport mouse, skip delays, etc.) |
ImGuiTestRunSpeed_Normal = 1 | 1 | Run tests at human watchable speed (for debugging) |
ImGuiTestRunSpeed_Cinematic = 2 | 2 | Run tests with pauses between actions (for e.g. tutorials) |
ImGuiTestRunSpeed_COUNT | 3 |
TestVerboseLevel (enum)¶
| Member | Value | |
|---|---|---|
ImGuiTestVerboseLevel_Silent = 0 | 0 | -v0 |
ImGuiTestVerboseLevel_Error = 1 | 1 | -v1 |
ImGuiTestVerboseLevel_Warning = 2 | 2 | -v2 |
ImGuiTestVerboseLevel_Info = 3 | 3 | -v3 |
ImGuiTestVerboseLevel_Debug = 4 | 4 | -v4 |
ImGuiTestVerboseLevel_Trace = 5 | 5 | |
ImGuiTestVerboseLevel_COUNT | 6 |
TestStatus (enum)¶
Test status (stored in ImGuiTest)
| Member | Value | |
|---|---|---|
ImGuiTestStatus_Unknown = 0 | 0 | |
ImGuiTestStatus_Success = 1 | 1 | |
ImGuiTestStatus_Queued = 2 | 2 | |
ImGuiTestStatus_Running = 3 | 3 | |
ImGuiTestStatus_Error = 4 | 4 | |
ImGuiTestStatus_Suspended = 5 | 5 | |
ImGuiTestStatus_COUNT | 6 |
TestGroup (enum)¶
Test group: this is mostly used to categorize tests in our testing UI. (Stored in ImGuiTest)
| Member | Value | |
|---|---|---|
ImGuiTestGroup_Unknown = -1 | -1 | |
ImGuiTestGroup_Tests = 0 | 0 | |
ImGuiTestGroup_Perfs = 1 | 1 | |
ImGuiTestGroup_COUNT | 2 |
TestFlags_ (enum)¶
Flags (stored in ImGuiTest)
| Member | Value | |
|---|---|---|
ImGuiTestFlags_None = 0 | 0 | |
ImGuiTestFlags_NoGuiWarmUp = 1 << 0 | 1 << 0 | Disable running the GUI func for 2 frames before starting test code. For tests which absolutely need to start before GuiFunc. |
ImGuiTestFlags_NoAutoFinish = 1 << 1 | 1 << 1 | By default, tests with no TestFunc (only a GuiFunc) will end after warmup. Setting this require test to call ctx->Finish(). |
ImGuiTestFlags_NoRecoveryWarnings = 1 << 2 | 1 << 2 | Error/recovery warnings (missing End/Pop calls etc.) will be displayed as normal debug entries, for tests which may rely on those. |
ImGuiTestFlags_RequireViewports = 1 << 10¶
TestCheckFlags_ (enum)¶
Flags for IM_CHECK* macros.
| Member | Value | |
|---|---|---|
ImGuiTestCheckFlags_None = 0 | 0 | |
ImGuiTestCheckFlags_SilentSuccess = 1 << 0 | 1 << 0 |
TestLogFlags_ (enum)¶
Flags for ImGuiTestContext::Log* functions.
| Member | Value | |
|---|---|---|
ImGuiTestLogFlags_None = 0 | 0 | |
ImGuiTestLogFlags_NoHeader = 1 << 0 | 1 << 0 | Do not display frame count and depth padding |
TestRunFlags_ (enum)¶
| Member | Value | |
|---|---|---|
ImGuiTestRunFlags_None = 0 | 0 | |
ImGuiTestRunFlags_GuiFuncDisable = 1 << 0 | 1 << 0 | Used internally to temporarily disable the GUI func (at the end of a test, etc) |
ImGuiTestRunFlags_GuiFuncOnly = 1 << 1 | 1 << 1 | Set when user selects “Run GUI func” |
ImGuiTestRunFlags_NoSuccessMsg = 1 << 2 | 1 << 2 | |
ImGuiTestRunFlags_EnableRawInputs = 1 << 3 | 1 << 3 | Disable input submission to let test submission raw input event (in order to test e.g. IO queue) |
ImGuiTestRunFlags_RunFromGui = 1 << 4 | 1 << 4 | Test ran manually from GUI, will disable watchdog. |
ImGuiTestRunFlags_RunFromCommandLine= 1 << 5 | 1 << 5 | Test queued from command-line. |
ImGuiTestRunFlags_NoError = 1 << 10 | 1 << 10 | |
ImGuiTestRunFlags_ShareVars = 1 << 11 | 1 << 11 | Share generic vars and custom vars between child and parent tests (custom vars need to be same type) |
ImGuiTestRunFlags_ShareTestContext = 1 << 12 | 1 << 12 | Share ImGuiTestContext instead of creating a new one (unsure what purpose this may be useful for yet) |
TODO: Add GuiFunc options¶
TestEngineResultSummary (struct)¶
| Member | |
|---|---|
int CountTested = 0; | Number of tests executed |
int CountSuccess = 0; | Number of tests succeeded |
int CountInQueue = 0; | Number of tests remaining in queue (e.g. aborted, crashed) |
Functions¶
Legacy version support¶
ImGuiTestEngineHook_ItemAdd¶
extern void ImGuiTestEngineHook_ItemAdd(ImGuiContext* ui_ctx, ImGuiID id, const ImRect& bb, const ImGuiLastItemData* item_data);Hooks for core imgui/ library (generally called via macros) (private API)
ImGuiTestEngineHook_Log¶
extern void ImGuiTestEngineHook_Log(ImGuiContext* ui_ctx, const char* fmt, ...);(private API)
ImGuiTestEngine_FindItemDebugLabel¶
extern const char* ImGuiTestEngine_FindItemDebugLabel(ImGuiContext* ui_ctx, ImGuiID id);(private API)
Functions (generally called via IM_CHECK() macros)¶
ImGuiTestEngine_Check¶
IMGUI_API bool ImGuiTestEngine_Check(const char* file, const char* func, int line, ImGuiTestCheckFlags flags, bool result, const char* expr);ImGuiTestEngine_CheckOpStr¶
IMGUI_API bool ImGuiTestEngine_CheckOpStr(const char* file, const char* func, int line, ImGuiTestCheckFlags flags, const char* op, const char* lhs_desc, const char* lhs_value, const char* rhs_desc, const char* rhs_value, bool* out_result);ImGuiTestEngine_Error¶
IMGUI_API bool ImGuiTestEngine_Error(const char* file, const char* func, int line, ImGuiTestCheckFlags flags, const char* fmt, ...);ImGuiTestEngine_AssertLog¶
IMGUI_API void ImGuiTestEngine_AssertLog(const char* expr, const char* file, const char* function, int line);ImGuiTestEngine_GetTempStringBuilder¶
IMGUI_API ImGuiTextBuffer* ImGuiTestEngine_GetTempStringBuilder();ImGuiTestEngine API¶
Functions: Initialization¶
ImGuiTestEngine_CreateContext¶
IMGUI_API ImGuiTestEngine* ImGuiTestEngine_CreateContext();ImGuiTestEngine_CreateContext: Create test engine
Note for python bindings users:
Integrating ImGui TestEngine directly from python, and without using HelloImGui and ImmApp is very difficult:
ImGui Test Engine uses two different threads (one for the main gui, and one for the scenario runner).
Your python code will be called from two separate threads, and this breaks the GIL!
HelloImGui and ImmApp handle this well by transferring the GIL between threads (from C++)
For gory details, see imgui
ImGuiTestEngine_DestroyContext¶
IMGUI_API void ImGuiTestEngine_DestroyContext(ImGuiTestEngine* engine);Destroy test engine. Call after ImGui::DestroyContext() so test engine specific ini data gets saved.
ImGuiTestEngine_Start¶
IMGUI_API void ImGuiTestEngine_Start(ImGuiTestEngine* engine, ImGuiContext* ui_ctx);Bind to a dear imgui context. Start coroutine.
ImGuiTestEngine_Stop¶
IMGUI_API void ImGuiTestEngine_Stop(ImGuiTestEngine* engine);Stop coroutine and export if any. (Unbind will lazily happen on context shutdown)
ImGuiTestEngine_PreSwap¶
IMGUI_API void ImGuiTestEngine_PreSwap(ImGuiTestEngine* engine);Call every frame before framebuffer present/swap (used for time measurement)
ImGuiTestEngine_PostSwap¶
IMGUI_API void ImGuiTestEngine_PostSwap(ImGuiTestEngine* engine);Call every frame after framebuffer present/swap, will process screen capture and call test_io.ScreenCaptureFunc()
ImGuiTestEngine_GetIO¶
IMGUI_API ImGuiTestEngineIO& ImGuiTestEngine_GetIO(ImGuiTestEngine* engine);ImGuiTestEngine_RegisterTest¶
IMGUI_API ImGuiTest* ImGuiTestEngine_RegisterTest(ImGuiTestEngine* engine, const char* category, const char* name, const char* src_file = nullptr, int src_line = 0);Prefer calling IM_REGISTER_TEST()
ImGuiTestEngine_UnregisterTest¶
IMGUI_API void ImGuiTestEngine_UnregisterTest(ImGuiTestEngine* engine, ImGuiTest* test);ImGuiTestEngine_UnregisterAllTests¶
IMGUI_API void ImGuiTestEngine_UnregisterAllTests(ImGuiTestEngine* engine);Functions: Main¶
ImGuiTestEngine_QueueTest¶
IMGUI_API void ImGuiTestEngine_QueueTest(ImGuiTestEngine* engine, ImGuiTest* test, ImGuiTestRunFlags run_flags = 0);ImGuiTestEngine_QueueTests¶
IMGUI_API void ImGuiTestEngine_QueueTests(ImGuiTestEngine* engine, ImGuiTestGroup group, const char* filter = nullptr, ImGuiTestRunFlags run_flags = 0);ImGuiTestEngine_TryAbortEngine¶
IMGUI_API bool ImGuiTestEngine_TryAbortEngine(ImGuiTestEngine* engine);ImGuiTestEngine_AbortCurrentTest¶
IMGUI_API void ImGuiTestEngine_AbortCurrentTest(ImGuiTestEngine* engine);ImGuiTestEngine_FindTestByName¶
IMGUI_API ImGuiTest* ImGuiTestEngine_FindTestByName(ImGuiTestEngine* engine, const char* category, const char* name);Functions: Status Queries¶
FIXME: Clarify API to avoid function calls vs raw bools in ImGuiTestEngineIO
ImGuiTestEngine_IsTestQueueEmpty¶
IMGUI_API bool ImGuiTestEngine_IsTestQueueEmpty(ImGuiTestEngine* engine);ImGuiTestEngine_IsUsingSimulatedInputs¶
IMGUI_API bool ImGuiTestEngine_IsUsingSimulatedInputs(ImGuiTestEngine* engine);ImGuiTestEngine_GetResultSummary¶
IMGUI_API void ImGuiTestEngine_GetResultSummary(ImGuiTestEngine* engine, ImGuiTestEngineResultSummary* out_results);Functions: Crash Handling¶
Ensure past test results are properly exported even if application crash during a test.
ImGuiTestEngine_InstallDefaultCrashHandler¶
IMGUI_API void ImGuiTestEngine_InstallDefaultCrashHandler();Install default crash handler (if you don’t have one)
ImGuiTestEngine_CrashHandler¶
IMGUI_API void ImGuiTestEngine_CrashHandler();Default crash handler, should be called from a custom crash handler if such exists
IO structure to configure the test engine¶
TestEngineIO (struct)¶
| Member | |
|---|---|
void* SrcFileOpenUserData = nullptr; | (Optional) User data for SrcFileOpenFunc |
void* ScreenCaptureUserData = nullptr; | (Optional) User data for ScreenCaptureFunc |
bool ConfigSavedSettings = true; | Load/Save settings in main context .ini file. |
ImGuiTestRunSpeed ConfigRunSpeed = ImGuiTestRunSpeed_Fast; | Run tests in fast/normal/cinematic mode |
bool ConfigStopOnError = false; | Stop queued tests on test error |
bool ConfigBreakOnError = false; | Break debugger on test error by calling IM_DEBUG_BREAK() |
bool ConfigKeepGuiFunc = false; | Keep test GUI running at the end of the test |
bool ConfigRestoreFocusAfterTests = true; | Restore focus back after running tests |
bool ConfigCaptureEnabled = true; | Master enable flags for capturing and saving captures. Disable to avoid e.g. lengthy saving of large PNG files. |
bool ConfigCaptureOnError = false; | |
bool ConfigNoThrottle = false; | Disable vsync for performance measurement or fast test running |
bool ConfigMouseDrawCursor = true; | Enable drawing of Dear ImGui software mouse cursor when running tests |
float ConfigFixedDeltaTime = 0.0f; | Use fixed delta time instead of calculating it from wall clock |
int PerfStressAmount = 1; | Integer to scale the amount of items submitted in test |
ImGuiTestVerboseLevel ConfigVerboseLevel = ImGuiTestVerboseLevel_Warning; | |
ImGuiTestVerboseLevel ConfigVerboseLevelOnError = ImGuiTestVerboseLevel_Info; | |
bool ConfigLogToTTY = false; | Output log entries to TTY (in addition to Test Engine UI) |
bool ConfigLogToDebugger = false; | Output log entries to Debugger (in addition to Test Engine UI) |
void* ConfigLogToFuncUserData = NULL; | |
float MouseSpeed = 600.0f; | Mouse speed (pixel/second) when not running in fast mode |
float MouseWobble = 0.25f; | (0.0..1.0) How much wobble to apply to the mouse (pixels per pixel of move distance) when not running in fast mode |
float ScrollSpeed = 1400.0f; | Scroll speed (pixel/second) when not running in fast mode |
float TypingSpeed = 20.0f; | Char input speed (characters/second) when not running in fast mode |
float ActionDelayShort = 0.15f; | Time between short actions |
float ActionDelayStandard = 0.40f; | Time between most actions |
float ConfigWatchdogWarning = 30.0f; | Warn when a test exceed this time (in second) |
float ConfigWatchdogKillTest = 60.0f; | Attempt to stop running a test when exceeding this time (in second) |
float ConfigWatchdogKillApp = FLT_MAX; | Stop application when exceeding this time (in second) |
ImGuiTestEngineExportFormat ExportResultsFormat = (ImGuiTestEngineExportFormat)0; | |
bool CheckDrawDataIntegrity = false; | Check ImDrawData integrity (buffer count, etc.). Currently cheap but may become a slow operation. |
bool IsRunningTests = false; | |
bool IsRequestingMaxAppSpeed = false; | When running in fast mode: request app to skip vsync or even skip rendering if it wants |
bool IsCapturing = false; | Capture is in progress |
TestEngineIO::ExportResultsFilename_Set¶
void ExportResultsFilename_Set(const char* filename);Set ExportResultsFilename from Python (private API)
ImGuiTestItemInfo¶
TestItemInfo (struct)¶
Information about a given item or window, result of an ItemInfo() or WindowInfo() query
| Member | |
|---|---|
ImGuiID ID = 0; | Item ID |
ImGuiWindow* Window = nullptr; | Item Window |
int TimestampMain; | Timestamp of main result (all fields) |
int TimestampStatus; | Timestamp of StatusFlags |
ImGuiID ParentID = 0; | Item Parent ID (value at top of the ID stack) |
ImRect RectFull = ImRect(); | Item Rectangle |
ImRect RectClipped = ImRect(); | Item Rectangle (clipped with window->ClipRect at time of item submission) |
ImGuiItemFlags ItemFlags = 0; | Item flags |
ImGuiItemStatusFlags StatusFlags = 0; | Item Status flags (fully updated for some items only, compare TimestampStatus to FrameCount) |
TestItemInfo::ImGuiTestItemInfo¶
ImGuiTestItemInfo();TestItemList (struct)¶
Result of an GatherItems() query
TestItemList::Clear¶
void Clear();(private API)
TestItemList::Reserve¶
void Reserve(int capacity);(private API)
TestItemList::GetSize¶
int GetSize() const;(private API)
TestItemList::GetByIndex¶
const ImGuiTestItemInfo* GetByIndex(int n);(private API)
TestItemList::GetByID¶
const ImGuiTestItemInfo* GetByID(ImGuiID id);(private API)
TestItemList::size¶
size_t size() const;(private API)
TestItemList::begin¶
const ImGuiTestItemInfo* begin() const;(private API)
TestItemList::end¶
const ImGuiTestItemInfo* end() const;(private API)
TestLogLineInfo (struct)¶
| Member | |
|---|---|
ImGuiTestVerboseLevel Level; | |
int LineOffset; |
TestLog (struct)¶
| Member | |
|---|---|
ImGuiTextBuffer Buffer; |
TestLog::ImGuiTestLog¶
ImGuiTestLog();Functions
TestLog::IsEmpty¶
bool IsEmpty() const;(private API)
TestLog::GetText¶
const char* GetText();(private API)
TestLog::GetTextLen¶
int GetTextLen();(private API)
TestLog::Clear¶
void Clear();(private API)
TestLog::ExtractLinesForVerboseLevels¶
int ExtractLinesForVerboseLevels(ImGuiTestVerboseLevel level_min, ImGuiTestVerboseLevel level_max, ImGuiTextBuffer* out_buffer);Extract log contents filtered per log-level.
Output:
- If ‘buffer != None’: all extracted lines are appended to ‘buffer’. Use ‘buffer->c_str()’ on your side to obtain the text.
- Return value: number of lines extracted (should be equivalent to number of ’
’ inside buffer->c_str()).
- You may call the function with buffer == None to only obtain a count without getting the data.
Verbose levels are inclusive:
- To get All Errors, Warnings, Debug... Use level_min == ImGuiTestVerboseLevel_Error, level_max = ImGuiTestVerboseLevel_Trace
(private API)TestLog::UpdateLineOffsets¶
void UpdateLineOffsets(ImGuiTestEngineIO* engine_io, ImGuiTestVerboseLevel level, const char* start);[Internal] (private API)
ImGuiTest¶
TestOutput (struct)¶
Storage for the output of a test run
| Member | |
|---|---|
ImGuiTestStatus Status = ImGuiTestStatus_Unknown; | |
ImGuiTestLog Log; | |
ImU64 StartTime = 0; | |
ImU64 EndTime = 0; |
Test (struct)¶
Storage for one test
| Member | |
|---|---|
Str30 Category; | Stored on the stack if len<30 |
Str30 Name; | Stored on the stack if len<30 |
ImGuiTestGroup Group = ImGuiTestGroup_Unknown; | Coarse groups: ‘Tests’ or ‘Perf’ |
int ArgVariant = 0; | User parameter. Generally we use it to run variations of a same test by sharing GuiFunc/TestFunc |
ImGuiTestFlags Flags = ImGuiTestFlags_None; | See ImGuiTestFlags_ |
Function_TestGui GuiFunc = nullptr; | GUI function (optional if your test are running over an existing GUI application) |
Function_TestRunner TestFunc = nullptr; | Test driving function |
Function_TestRunner TeardownFunc = nullptr; | Teardown driving function, executed after TestFunc regardless of TestFunc failing. |
void* UserData = nullptr; | General purpose user data (if assigning capturing lambdas on GuiFunc/TestFunc you may not need to use this) |
Str256 SourceFile; | FILE |
int SourceLine = 0; | LINE |
int SourceLineEnd = 0; | end of line (when calculated by ImGuiTestEngine_StartCalcSourceLineEnds()) |
ImGuiTestOutput Output; | |
size_t VarsSize = 0; | |
void* VarsPostConstructorUserFn = nullptr; |
Test::ImGuiTest¶
ImGuiTest();Functions
Test::SetOwnedName¶
void SetOwnedName(const char* name);[Bundle] Compatibility with upstream API: Name is owning here (Str30), no separate copy needed. (private API)
TestRunTask (struct)¶
Stored in test queue
| Member | |
|---|---|
ImGuiTest* Test = nullptr; | |
ImGuiTestRunFlags RunFlags = ImGuiTestRunFlags_None; |
imgui_te_context.h¶
ImGuiTestRef¶
TestRef (struct)¶
Weak reference to an Item/Window given an hashed ID or a string path ID.
This is most often passed as argument to function and generally has a very short lifetime.
Documentation: https://
| Member | |
|---|---|
ImGuiID ID; | Pre-hashed ID |
TestRef::ImGuiTestRef¶
ImGuiTestRef();ImGuiTestRef(ImGuiID id);ImGuiTestRef(const char* path);TestRef::IsEmpty¶
bool IsEmpty() const;(private API)
TestRefDesc (struct)¶
Debug helper to output a string showing the Path, ID or Debug Label based on what is available (some items only have ID as we couldn’t find/store a Path) (The size is arbitrary, this is only used for logging info the user/debugger)
TestRefDesc::c_str¶
const char* c_str();(private API)
TestRefDesc::ImGuiTestRefDesc¶
ImGuiTestRefDesc(const ImGuiTestRef& ref);ImGuiTestRefDesc(const ImGuiTestRef& ref, const ImGuiTestItemInfo& item);ImGuiTestContext related Flags/Enumerations¶
TestAction (enum)¶
Named actions. Generally you will call the named helpers e.g. ItemClick(). This is used by shared/low-level functions such as ItemAction().
| Member | Value | |
|---|---|---|
ImGuiTestAction_Unknown = 0 | 0 | |
ImGuiTestAction_Hover | 1 | Move mouse |
ImGuiTestAction_Click | 2 | Move mouse and click |
ImGuiTestAction_DoubleClick | 3 | Move mouse and double-click |
ImGuiTestAction_Check | 4 | Check item if unchecked (Checkbox, MenuItem or any widget reporting ImGuiItemStatusFlags_Checkable) |
ImGuiTestAction_Uncheck | 5 | Uncheck item if checked |
ImGuiTestAction_Open | 6 | Open item if closed (TreeNode, BeginMenu or any widget reporting ImGuiItemStatusFlags_Openable) |
ImGuiTestAction_Close | 7 | Close item if opened |
ImGuiTestAction_Input | 8 | Start text inputing into a field (e.g. CTRL+Click on Drags/Slider, click on InputText etc.) |
ImGuiTestAction_NavActivate | 9 | Activate item with navigation |
ImGuiTestAction_COUNT | 10 |
TestOpFlags_ (enum)¶
Generic flags for many ImGuiTestContext functions
Some flags are only supported by a handful of functions. Check function headers for list of supported flags.
| Member | Value | |
|---|---|---|
ImGuiTestOpFlags_None = 0 | 0 | |
ImGuiTestOpFlags_NoCheckHoveredId = 1 << 1 | 1 << 1 | Don’t check for HoveredId after aiming for a widget. This is automatic when there’s an active item, typically in drag and drop operation. Otherwise, a few situations may want this e.g. for items that don’t use ItemHoverable(), or when intently aiming for an item behind a popup/modal inhibition layer. |
ImGuiTestOpFlags_NoError = 1 << 2 | 1 << 2 | Don’t abort/error e.g. if the item cannot be found or the operation doesn’t succeed. |
ImGuiTestOpFlags_NoFocusWindow = 1 << 3 | 1 << 3 | Don’t focus window when aiming at an item |
ImGuiTestOpFlags_NoAutoUncollapse = 1 << 4 | 1 << 4 | Disable automatically uncollapsing windows (useful when specifically testing Collapsing behaviors) |
ImGuiTestOpFlags_NoAutoOpenFullPath = 1 << 5 | 1 << 5 | Disable automatically opening intermediaries (e.g. ItemClick(“Hello/OK”) will automatically first open “Hello” if “OK” isn’t found. Only works if ref is a string path. |
ImGuiTestOpFlags_NoYield = 1 << 6 | 1 << 6 | Don’t yield (only supported by a few functions), in case you need to manage rigorous per-frame timing. |
ImGuiTestOpFlags_IsSecondAttempt = 1 << 7 | 1 << 7 | Used by recursing functions to indicate a second attempt |
ImGuiTestOpFlags_MoveToEdgeL = 1 << 8 | 1 << 8 | Simple Dumb aiming helpers to test widget that care about clicking position. May need to replace will better functionalities. |
ImGuiTestOpFlags_MoveToEdgeR = 1 << 9 | 1 << 9 | |
ImGuiTestOpFlags_MoveToEdgeU = 1 << 10 | 1 << 10 | |
ImGuiTestOpFlags_MoveToEdgeD = 1 << 11 | 1 << 11 | |
ImGuiTestOpFlags_NoScroll = 1 << 12 | 1 << 12 | Disable automatically scrolling to reach an item. |
ImGuiTestOpFlags_NoWaitWhenMoving = 1 << 13 | 1 << 13 | Avoid waiting for item to be stable, lock current position and aim. |
TestActionFilter (struct)¶
Advanced filtering for ItemActionAll()
| Member | |
|---|---|
int MaxDepth; | |
int MaxPasses; | |
const int* MaxItemCountPerDepth; | (const) |
ImGuiItemStatusFlags RequireAllStatusFlags; | |
ImGuiItemStatusFlags RequireAnyStatusFlags; |
TestActionFilter::ImGuiTestActionFilter¶
ImGuiTestActionFilter();ImGuiTestGenericVars, ImGuiTestGenericItemStatus¶
TestGenericItemStatus (struct)¶
Helper struct to store various query-able state of an item.
This facilitate interactions between GuiFunc and TestFunc, since those state are frequently used.
| Member | |
|---|---|
int RetValue; | return value |
int Hovered; | result of IsItemHovered() |
int HoveredAllowDisabled; | result of IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) |
int Active; | result of IsItemActive() |
int Focused; | result of IsItemFocused() |
int Clicked; | result of IsItemClicked() |
int Visible; | result of IsItemVisible() |
int Edited; | result of IsItemEdited() |
int Activated; | result of IsItemActivated() |
int Deactivated; | result of IsItemDeactivated() |
int DeactivatedAfterEdit; | result of IsItemDeactivatedAfterEdit() |
TestGenericItemStatus::ImGuiTestGenericItemStatus¶
ImGuiTestGenericItemStatus();TestGenericItemStatus::Clear¶
void Clear();(private API)
TestGenericItemStatus::QuerySet¶
void QuerySet(bool ret_val = false);(private API)
TestGenericItemStatus::QueryInc¶
void QueryInc(bool ret_val = false);(private API)
TestGenericItemStatus::Draw¶
void Draw();(private API)
TestGenericVars (struct)¶
Generic structure with various storage fields.
This is useful for tests to quickly share data between GuiFunc and TestFunc without creating custom data structure.
If those fields are not enough: using test->SetVarsDataType<>() + ctx->GetVars<>() it is possible to store custom data.
| Member | |
|---|---|
int Step; | |
int Count; | |
ImGuiID DockId; | |
ImGuiID OwnerId; | |
ImVec2 WindowSize; | |
ImGuiWindowFlags WindowFlags; | |
ImGuiTableFlags TableFlags; | |
ImGuiPopupFlags PopupFlags; | |
ImGuiInputTextFlags InputTextFlags; | |
ImGuiTestGenericItemStatus Status; | |
bool ShowWindow1, | |
ShowWindow2; | |
bool UseClipper; | |
bool UseViewports; | |
bool UseMixedValue; | |
float Width; | |
ImVec2 Pos; | |
ImVec2 Pivot; | |
ImVec2 ItemSize; | |
ImVec4 Color1, | |
Color2; | |
int Int1, | |
Int2, | |
IntArray[10]; | ndarray[type=int, size=10] |
float Float1, | |
Float2, | |
FloatArray[10]; | ndarray[type=float, size=10] |
bool Bool1, | |
Bool2, | |
BoolArray[10]; | ndarray[type=bool, size=10] |
ImGuiID Id, | |
IdArray[10]; | ndarray[type=ImGuiID, size=10] |
TestGenericVars::ImGuiTestGenericVars¶
ImGuiTestGenericVars();TestGenericVars::Clear¶
void Clear();(private API)
ImGuiTestContext¶
Context for a running ImGuiTest¶
This is the interface that most tests will interact with.
TestContext (struct)¶
| Member | |
|---|---|
ImGuiTestGenericVars GenericVars; | Generic variables holder for convenience. |
void* UserVars = nullptr; | Access using ctx->GetVars(). Setup with test->SetVarsDataType<>(). |
ImGuiContext* UiContext = nullptr; | UI context |
ImGuiTestEngineIO* EngineIO = nullptr; | Test Engine IO/settings |
ImGuiTest* Test = nullptr; | Test currently running |
ImGuiTestOutput* TestOutput = nullptr; | Test output (generally == &Test->Output while executing TestFunc) |
ImGuiTestOpFlags OpFlags = ImGuiTestOpFlags_None; | Flags affecting all operation (supported: ImGuiTestOpFlags_NoAutoUncollapse) |
int PerfStressAmount = 0; | Convenience copy of engine->IO.PerfStressAmount |
int FrameCount = 0; | Test frame count (restarts from zero every time) |
int FirstTestFrameCount = 0; | First frame where TestFunc is running (after warm-up frame). This is generally -1 or 0 depending on whether we have warm up enabled |
bool FirstGuiFrame = false; | |
bool HasDock = false; | #ifdef IMGUI_HAS_DOCK expressed in an easier to test value |
ImGuiTestEngine* Engine = nullptr; | |
ImGuiTestInputs* Inputs = nullptr; | |
ImGuiTestRunFlags RunFlags = ImGuiTestRunFlags_None; | |
ImGuiTestActiveFunc ActiveFunc = ImGuiTestActiveFunc_None; | None/GuiFunc/TestFunc |
double RunningTime = 0.0; | Amount of wall clock time the Test has been running. Used by safety watchdog. |
int ActionDepth = 0; | Nested depth of ctx-> function calls (used to decorate log) |
int CaptureCounter = 0; | Number of captures |
int ErrorCounter = 0; | Number of errors (generally this maxxes at 1 as most functions will early out) |
bool Abort = false; | |
double PerfRefDt = -1.0; | |
int PerfIterations = 400; | Number of frames for PerfCapture() measurements |
ImGuiID RefID = 0; | Reference ID over which all named references are based |
ImGuiID RefWindowID = 0; | ID of a window that contains RefID item |
ImGuiInputSource InputMode = ImGuiInputSource_Mouse; | Prefer interacting with mouse/keyboard/gamepad |
ImVector<char> TempString; | |
ImVector<char> Clipboard; | Private clipboard for the test instance |
ImVector<ImGuiWindow*> ForeignWindowsToHide; | |
ImGuiTestItemInfo DummyItemInfoNull; | Storage for ItemInfoNull() |
bool CachedLinesPrintedToTTY = false; |
TestContext::Finish¶
void Finish(ImGuiTestStatus status = ImGuiTestStatus_Success);(private API)
Set test status and stop running. Usually called when running test logic from GuiFunc() only.
TestContext::RunChildTest¶
ImGuiTestStatus RunChildTest(const char* test_name, ImGuiTestRunFlags flags = 0);(private API)
[Experimental] Run another test from the current test.
TestContext::IsError¶
bool IsError() const;(private API)
TestContext::IsWarmUpGuiFrame¶
bool IsWarmUpGuiFrame() const;(private API)
Unless test->Flags has ImGuiTestFlags_NoGuiWarmUp, we run GuiFunc() twice before running TestFunc(). Those frames are called “WarmUp” frames.
TestContext::IsFirstGuiFrame¶
bool IsFirstGuiFrame() const;(private API)
TestContext::IsFirstTestFrame¶
bool IsFirstTestFrame() const;(private API)
First frame where TestFunc is running (after warm-up frame).
TestContext::IsGuiFuncOnly¶
bool IsGuiFuncOnly() const;(private API)
TestContext::SuspendTestFunc¶
bool SuspendTestFunc(const char* file = nullptr, int line = 0);(private API)
[DEBUG] Generally called via IM_SUSPEND_TESTFUNC
TestContext::LogEx¶
void LogEx(ImGuiTestVerboseLevel level, ImGuiTestLogFlags flags, const char* fmt, ...) ;(private API)
TestContext::LogToTTY¶
void LogToTTY(ImGuiTestVerboseLevel level, const char* message, const char* message_end = nullptr);(private API)
TestContext::LogToDebugger¶
void LogToDebugger(ImGuiTestVerboseLevel level, const char* message);(private API)
TestContext::LogDebug¶
void LogDebug(const char* fmt, ...) ;(private API)
ImGuiTestVerboseLevel_Debug or ImGuiTestVerboseLevel_Trace depending on context depth
TestContext::LogInfo¶
void LogInfo(const char* fmt, ...) ;(private API)
ImGuiTestVerboseLevel_Info
TestContext::LogWarning¶
void LogWarning(const char* fmt, ...) ;(private API)
ImGuiTestVerboseLevel_Warning
TestContext::LogError¶
void LogError(const char* fmt, ...) ;(private API)
ImGuiTestVerboseLevel_Error
TestContext::LogBasicUiState¶
void LogBasicUiState();(private API)
TestContext::LogItemList¶
void LogItemList(ImGuiTestItemList* list);(private API)
TestContext::Yield¶
void Yield(int count = 1);(private API)
TestContext::Sleep¶
void Sleep(float time_in_second);(private API)
Sleep for a given simulation time, unless in Fast mode
TestContext::SleepShort¶
void SleepShort();(private API)
Standard short delay of io.ActionDelayShort (~0.15), unless in Fast mode.
TestContext::SleepStandard¶
void SleepStandard();(private API)
Standard regular delay of io.ActionDelayStandard (~0.40), unless in Fast mode.
TestContext::SleepNoSkip¶
void SleepNoSkip(float time_in_second, float framestep_in_second);(private API)
TestContext::SetRef¶
void SetRef(ImGuiTestRef ref);void SetRef(ImGuiWindow* window);(private API)
TestContext::GetRef¶
ImGuiTestRef GetRef();(private API)
TestContext::WindowInfo¶
ImGuiTestItemInfo WindowInfo(ImGuiTestRef window_ref, ImGuiTestOpFlags flags = ImGuiTestOpFlags_None);(private API)
TestContext::WindowClose¶
void WindowClose(ImGuiTestRef window_ref);(private API)
TestContext::WindowCollapse¶
void WindowCollapse(ImGuiTestRef window_ref, bool collapsed);(private API)
TestContext::WindowFocus¶
void WindowFocus(ImGuiTestRef window_ref, ImGuiTestOpFlags flags = ImGuiTestOpFlags_None);(private API)
TestContext::WindowBringToFront¶
void WindowBringToFront(ImGuiTestRef window_ref, ImGuiTestOpFlags flags = ImGuiTestOpFlags_None);(private API)
TestContext::WindowMove¶
void WindowMove(ImGuiTestRef window_ref, ImVec2 pos, ImVec2 pivot = ImVec2(0.0f, 0.0f), ImGuiTestOpFlags flags = ImGuiTestOpFlags_None);TestContext::WindowResize¶
void WindowResize(ImGuiTestRef window_ref, ImVec2 sz);(private API)
TestContext::WindowTeleportToMakePosVisible¶
bool WindowTeleportToMakePosVisible(ImGuiTestRef window_ref, ImVec2 pos_in_window);(private API)
TestContext::GetWindowByRef¶
ImGuiWindow*GetWindowByRef(ImGuiTestRef window_ref);(private API)
TestContext::PopupCloseOne¶
void PopupCloseOne();(private API)
TestContext::PopupCloseAll¶
void PopupCloseAll();(private API)
TestContext::PopupGetWindowID¶
ImGuiID PopupGetWindowID(ImGuiTestRef ref);(private API)
TestContext::GetID¶
ImGuiID GetID(ImGuiTestRef ref);ImGuiID GetID(ImGuiTestRef ref, ImGuiTestRef seed_ref);(private API)
Get hash for a decorated ID Path.
Note: for windows you may use WindowInfo()
TestContext::GetPosOnVoid¶
ImVec2 GetPosOnVoid(ImGuiViewport* viewport);(private API)
Find a point that has no windows // FIXME: This needs error return and flag to enable/disable forcefully finding None.
TestContext::GetWindowTitlebarPoint¶
ImVec2 GetWindowTitlebarPoint(ImGuiTestRef window_ref);(private API)
Return a clickable point on window title-bar (window tab for docked windows) that will e.g. move this single window.
TestContext::GetMainMonitorWorkPos¶
ImVec2 GetMainMonitorWorkPos();(private API)
Work pos and size of main viewport when viewports are disabled, or work pos and size of monitor containing main viewport when viewports are enabled.
TestContext::GetMainMonitorWorkSize¶
ImVec2 GetMainMonitorWorkSize();(private API)
TestContext::CaptureReset¶
void CaptureReset();(private API)
Reset state (use when doing multiple captures)
TestContext::CaptureSetExtension¶
void CaptureSetExtension(const char* ext);(private API)
Set capture file format (otherwise for video this default to EngineIO->VideoCaptureExtension)
TestContext::CaptureSetFilename¶
void CaptureSetFilename(const char* filename);[ADAPT_IMGUI_BUNDLE]
Where to save the next CaptureScreenshot*/CaptureBeginVideo (length: 256 max!)
(private API)
TestContext::CaptureAddWindow¶
bool CaptureAddWindow(ImGuiTestRef ref);(private API)
Add window to be captured (default to capture everything)
TestContext::CaptureScreenshotWindow¶
void CaptureScreenshotWindow(ImGuiTestRef ref, int capture_flags = 0);(private API)
Trigger a screen capture of a single window (== CaptureAddWindow() + CaptureScreenshot())
TestContext::CaptureScreenshot¶
bool CaptureScreenshot(int capture_flags = 0);(private API)
Trigger a screen capture
TestContext::CaptureBeginVideo¶
bool CaptureBeginVideo();(private API)
Start a video capture
TestContext::CaptureEndVideo¶
bool CaptureEndVideo();(private API)
TestContext::MouseMove¶
void MouseMove(ImGuiTestRef ref, ImGuiTestOpFlags flags = ImGuiTestOpFlags_None);(private API)
TestContext::MouseMoveToPos¶
void MouseMoveToPos(ImVec2 pos);(private API)
TestContext::MouseTeleportToPos¶
void MouseTeleportToPos(ImVec2 pos, ImGuiTestOpFlags flags = ImGuiTestOpFlags_None);(private API)
TestContext::MouseClick¶
void MouseClick(ImGuiMouseButton button = 0);(private API)
TestContext::MouseClickMulti¶
void MouseClickMulti(ImGuiMouseButton button, int count);(private API)
TestContext::MouseDoubleClick¶
void MouseDoubleClick(ImGuiMouseButton button = 0);(private API)
TestContext::MouseDown¶
void MouseDown(ImGuiMouseButton button = 0);(private API)
TestContext::MouseUp¶
void MouseUp(ImGuiMouseButton button = 0);(private API)
TestContext::MouseLiftDragThreshold¶
void MouseLiftDragThreshold(ImGuiMouseButton button = 0);(private API)
TestContext::MouseDragWithDelta¶
void MouseDragWithDelta(ImVec2 delta, ImGuiMouseButton button = 0);(private API)
TestContext::MouseWheel¶
void MouseWheel(ImVec2 delta);(private API)
TestContext::MouseWheelX¶
void MouseWheelX(float dx);(private API)
TestContext::MouseWheelY¶
void MouseWheelY(float dy);(private API)
+1: up, -1: down
TestContext::MouseMoveToVoid¶
void MouseMoveToVoid(ImGuiViewport* viewport = nullptr);(private API)
TestContext::MouseClickOnVoid¶
void MouseClickOnVoid(ImGuiMouseButton button = 0, ImGuiViewport* viewport = nullptr);(private API)
TestContext::FindHoveredWindowAtPos¶
ImGuiWindow*FindHoveredWindowAtPos(const ImVec2& pos);(private API)
TestContext::FindExistingVoidPosOnViewport¶
bool FindExistingVoidPosOnViewport(ImGuiViewport* viewport, ImVec2* out);(private API)
TestContext::MouseSetViewport¶
void MouseSetViewport(ImGuiWindow* window);(private API)
TestContext::MouseSetViewportID¶
void MouseSetViewportID(ImGuiID viewport_id);(private API)
TestContext::KeyDown¶
void KeyDown(ImGuiKeyChord key_chord);(private API)
TestContext::KeyUp¶
void KeyUp(ImGuiKeyChord key_chord);(private API)
TestContext::KeyPress¶
void KeyPress(ImGuiKeyChord key_chord, int count = 1);(private API)
TestContext::KeyHold¶
void KeyHold(ImGuiKeyChord key_chord, float time);(private API)
TestContext::KeySetEx¶
void KeySetEx(ImGuiKeyChord key_chord, bool is_down, float time);(private API)
TestContext::KeyChars¶
void KeyChars(const char* chars);(private API)
Input characters
TestContext::KeyCharsAppend¶
void KeyCharsAppend(const char* chars);(private API)
Input characters at end of field
TestContext::KeyCharsAppendEnter¶
void KeyCharsAppendEnter(const char* chars);(private API)
Input characters at end of field, press Enter
TestContext::KeyCharsReplace¶
void KeyCharsReplace(const char* chars);(private API)
Delete existing field then input characters
TestContext::KeyCharsReplaceEnter¶
void KeyCharsReplaceEnter(const char* chars);(private API)
Delete existing field then input characters, press Enter
TestContext::SetInputMode¶
void SetInputMode(ImGuiInputSource input_mode);(private API)
Mouse or Keyboard or Gamepad. In Keyboard or Gamepad mode, actions such as ItemClick or ItemInput are using nav facilities instead of Mouse.
TestContext::NavMoveTo¶
void NavMoveTo(ImGuiTestRef ref);(private API)
TestContext::NavActivate¶
void NavActivate();(private API)
Activate current selected item: activate button, tweak sliders/drags. Equivalent of pressing Space on keyboard, ImGuiKey_GamepadFaceUp on a gamepad.
TestContext::NavInput¶
void NavInput();(private API)
Input into select item: input sliders/drags. Equivalent of pressing Enter on keyboard, ImGuiKey_GamepadFaceDown on a gamepad.
TestContext::ScrollTo¶
void ScrollTo(ImGuiTestRef ref, ImGuiAxis axis, float scroll_v, ImGuiTestOpFlags flags = ImGuiTestOpFlags_None);Scrolling (private API)
TestContext::ScrollToX¶
void ScrollToX(ImGuiTestRef ref, float scroll_x);(private API)
TestContext::ScrollToY¶
void ScrollToY(ImGuiTestRef ref, float scroll_y);(private API)
TestContext::ScrollToTop¶
void ScrollToTop(ImGuiTestRef ref);(private API)
TestContext::ScrollToBottom¶
void ScrollToBottom(ImGuiTestRef ref);(private API)
TestContext::ScrollToPos¶
void ScrollToPos(ImGuiTestRef window_ref, float pos_v, ImGuiAxis axis, ImGuiTestOpFlags flags = ImGuiTestOpFlags_None);(private API)
TestContext::ScrollToPosX¶
void ScrollToPosX(ImGuiTestRef window_ref, float pos_x);(private API)
TestContext::ScrollToPosY¶
void ScrollToPosY(ImGuiTestRef window_ref, float pos_y);(private API)
TestContext::ScrollToItem¶
void ScrollToItem(ImGuiTestRef ref, ImGuiAxis axis, ImGuiTestOpFlags flags = ImGuiTestOpFlags_None);(private API)
TestContext::ScrollToItemX¶
void ScrollToItemX(ImGuiTestRef ref);(private API)
TestContext::ScrollToItemY¶
void ScrollToItemY(ImGuiTestRef ref);(private API)
TestContext::ScrollToTabItem¶
void ScrollToTabItem(ImGuiTabBar* tab_bar, ImGuiID tab_id);(private API)
TestContext::ItemInfo¶
ImGuiTestItemInfo ItemInfo(ImGuiTestRef ref, ImGuiTestOpFlags flags = ImGuiTestOpFlags_None);(private API)
TestContext::ItemInfoOpenFullPath¶
ImGuiTestItemInfo ItemInfoOpenFullPath(ImGuiTestRef ref, ImGuiTestOpFlags flags = ImGuiTestOpFlags_None);(private API)
TestContext::ItemInfoHandleWildcardSearch¶
ImGuiID ItemInfoHandleWildcardSearch(const char* wildcard_prefix_start, const char* wildcard_prefix_end, const char* wildcard_suffix_start);(private API)
TestContext::ItemInfoNull¶
ImGuiTestItemInfo ItemInfoNull();(private API)
TestContext::GatherItems¶
void GatherItems(ImGuiTestItemList* out_list, ImGuiTestRef parent, int depth = -1);(private API)
TestContext::ItemAction¶
void ItemAction(ImGuiTestAction action, ImGuiTestRef ref, ImGuiTestOpFlags flags = 0, void* action_arg = nullptr);Item/Widgets manipulation (private API)
TestContext::ItemClick¶
void ItemClick(ImGuiTestRef ref, ImGuiMouseButton button = 0, ImGuiTestOpFlags flags = 0);(private API)
TestContext::ItemDoubleClick¶
void ItemDoubleClick(ImGuiTestRef ref, ImGuiTestOpFlags flags = 0);(private API)
TestContext::ItemCheck¶
void ItemCheck(ImGuiTestRef ref, ImGuiTestOpFlags flags = 0);(private API)
TestContext::ItemUncheck¶
void ItemUncheck(ImGuiTestRef ref, ImGuiTestOpFlags flags = 0);(private API)
TestContext::ItemOpen¶
void ItemOpen(ImGuiTestRef ref, ImGuiTestOpFlags flags = 0);(private API)
TestContext::ItemClose¶
void ItemClose(ImGuiTestRef ref, ImGuiTestOpFlags flags = 0);(private API)
TestContext::ItemInput¶
void ItemInput(ImGuiTestRef ref, ImGuiTestOpFlags flags = 0);(private API)
TestContext::ItemNavActivate¶
void ItemNavActivate(ImGuiTestRef ref, ImGuiTestOpFlags flags = 0);(private API)
TestContext::ItemActionAll¶
void ItemActionAll(ImGuiTestAction action, ImGuiTestRef ref_parent, const ImGuiTestActionFilter* filter = nullptr);(private API)
TestContext::ItemOpenAll¶
void ItemOpenAll(ImGuiTestRef ref_parent, int depth = -1, int passes = -1);(private API)
TestContext::ItemCloseAll¶
void ItemCloseAll(ImGuiTestRef ref_parent, int depth = -1, int passes = -1);(private API)
TestContext::ItemInputValue¶
void ItemInputValue(ImGuiTestRef ref, int v);void ItemInputValue(ImGuiTestRef ref, float f);void ItemInputValue(ImGuiTestRef ref, const char* str);(private API)
TestContext::ItemReadAsInt¶
int ItemReadAsInt(ImGuiTestRef ref);(private API)
Item/Widgets: Helpers to easily read a value by selecting Slider/Drag/Input text, copying it and parsing it.
This requires the item to be selectable (we will later provide helpers that works in more general manner)
(this temporarily use the internal test clipboard, but original clipboard value is restored afterwards)
See https://github .com /ocornut /imgui _test _engine /wiki /Automation -API #accessing -your -data
TestContext::ItemReadAsFloat¶
float ItemReadAsFloat(ImGuiTestRef ref);(private API)
TestContext::ItemReadAsScalar¶
bool ItemReadAsScalar(ImGuiTestRef ref, ImGuiDataType data_type, void* out_data, ImGuiTestOpFlags flags = ImGuiTestOpFlags_None);(private API)
TestContext::ItemExists¶
bool ItemExists(ImGuiTestRef ref);(private API)
TestContext::ItemIsChecked¶
bool ItemIsChecked(ImGuiTestRef ref);(private API)
TestContext::ItemIsOpened¶
bool ItemIsOpened(ImGuiTestRef ref);(private API)
TestContext::ItemIsVisible¶
bool ItemIsVisible(ImGuiTestRef ref);(private API)
TestContext::ItemMakeVisible¶
void ItemMakeVisible(ImGuiTestRef ref, ImGuiTestOpFlags flags);(private API)
TestContext::ItemVerifyCheckedIfAlive¶
void ItemVerifyCheckedIfAlive(ImGuiTestRef ref, bool checked);(private API)
TestContext::ItemHold¶
void ItemHold(ImGuiTestRef ref, float time);(private API)
TestContext::ItemHoldForFrames¶
void ItemHoldForFrames(ImGuiTestRef ref, int frames);(private API)
TestContext::ItemDragOverAndHold¶
void ItemDragOverAndHold(ImGuiTestRef ref_src, ImGuiTestRef ref_dst);(private API)
TestContext::ItemDragAndDrop¶
void ItemDragAndDrop(ImGuiTestRef ref_src, ImGuiTestRef ref_dst, ImGuiMouseButton button = 0);(private API)
TestContext::ItemDragToPos¶
void ItemDragToPos(ImGuiTestRef ref_src, const ImVec2& pos);(private API)
TestContext::ItemDragWithDelta¶
void ItemDragWithDelta(ImGuiTestRef ref_src, const ImVec2& pos_delta);(private API)
TestContext::TabClose¶
void TabClose(ImGuiTestRef ref);(private API)
TestContext::MenuAction¶
void MenuAction(ImGuiTestAction action, ImGuiTestRef ref);(private API)
TestContext::MenuActionAll¶
void MenuActionAll(ImGuiTestAction action, ImGuiTestRef ref_parent);(private API)
TestContext::MenuClick¶
void MenuClick(ImGuiTestRef ref);(private API)
TestContext::MenuCheck¶
void MenuCheck(ImGuiTestRef ref);(private API)
TestContext::MenuUncheck¶
void MenuUncheck(ImGuiTestRef ref);(private API)
TestContext::MenuCheckAll¶
void MenuCheckAll(ImGuiTestRef ref_parent);(private API)
TestContext::MenuUncheckAll¶
void MenuUncheckAll(ImGuiTestRef ref_parent);(private API)
TestContext::ComboClick¶
void ComboClick(ImGuiTestRef ref);(private API)
TestContext::ComboClickAll¶
void ComboClickAll(ImGuiTestRef ref);(private API)
TestContext::TableOpenContextMenu¶
void TableOpenContextMenu(ImGuiTestRef ref, int column_n = -1);(private API)
TestContext::TableClickHeader¶
ImGuiSortDirection TableClickHeader(ImGuiTestRef ref, const char* label, ImGuiKeyChord key_mods = 0);(private API)
TestContext::TableSetColumnEnabled¶
void TableSetColumnEnabled(ImGuiTestRef ref, int column_n, bool enabled);void TableSetColumnEnabled(ImGuiTestRef ref, const char* label, bool enabled);(private API)
TestContext::TableResizeColumn¶
void TableResizeColumn(ImGuiTestRef ref, int column_n, float width);void TableResizeColumn(ImGuiTestRef ref, const char* label, float width);(private API)
TestContext::TableGetSortSpecs¶
const ImGuiTableSortSpecs* TableGetSortSpecs(ImGuiTestRef ref);(private API)
TestContext::DockClear¶
void DockClear(const char* window_name, ...);(private API)
TestContext::DockInto¶
void DockInto(ImGuiTestRef src_id, ImGuiTestRef dst_id, ImGuiDir split_dir = ImGuiDir_None, bool is_outer_docking = false, ImGuiTestOpFlags flags = 0);TestContext::UndockNode¶
void UndockNode(ImGuiID dock_id);(private API)
TestContext::UndockWindow¶
void UndockWindow(const char* window_name);(private API)
TestContext::WindowIsUndockedOrStandalone¶
bool WindowIsUndockedOrStandalone(ImGuiWindow* window);(private API)
TestContext::DockIdIsUndockedOrStandalone¶
bool DockIdIsUndockedOrStandalone(ImGuiID dock_id);(private API)
TestContext::DockNodeHideTabBar¶
void DockNodeHideTabBar(ImGuiDockNode* node, bool hidden);(private API)
TestContext::PerfCalcRef¶
void PerfCalcRef();(private API)
ImVec2 GetDockNodeTitlebarPos(ImGuiDockNode* node);
#endifPerformances Measurement (use along with Dear ImGui Perf Tool)
TestContext::PerfCapture¶
void PerfCapture(const char* category = nullptr, const char* test_name = nullptr, const char* csv_file = nullptr);(private API)
imgui_te_internal.h¶
FORWARD DECLARATIONS¶
DATA STRUCTURES¶
TestInfoTask (struct)¶
Query item position/window/state given ID.
| Member | |
|---|---|
ImGuiID ID = 0; | |
int FrameCount = -1; | Timestamp of request |
ImGuiTestItemInfo Result; |
TestGatherTask (struct)¶
Gather item list in given parent ID.
| Member | |
|---|---|
ImGuiID InParentID = 0; | |
int InMaxDepth = 0; | |
short InLayerMask = 0; | |
ImGuiTestItemList* OutList = nullptr; | |
ImGuiTestItemInfo* LastItemInfo = nullptr; |
TestGatherTask::Clear¶
void Clear();(private API)
TestFindByLabelTask (struct)¶
Find item ID given a label and a parent id
Usually used by queries with wildcards such as ItemInfo(“hello/**/foo/bar”)
| Member | |
|---|---|
ImGuiID InPrefixId = 0; | A known base ID which appears BEFORE the wildcard ID (for “hello/**/foo/bar” it would be hash of “hello”) |
int InSuffixDepth = 0; | Number of labels in a path, after unknown base ID (for “hello/**/foo/bar” it would be 2) |
const char* InSuffix = nullptr; | A label string which appears on ID stack after unknown base ID (for “hello/**/foo/bar” it would be “foo/bar”) # (const) |
const char* InSuffixLastItem = nullptr; | A last label string (for “hello/**/foo/bar” it would be “bar”) # (const) |
ImGuiID InSuffixLastItemHash = 0; | |
ImGuiItemStatusFlags InFilterItemStatusFlags = 0; | Flags required for item to be returned |
ImGuiID OutItemId = 0; | Result item ID |
TestInputType (enum)¶
| Member | Value | |
|---|---|---|
ImGuiTestInputType_None | 0 | |
ImGuiTestInputType_Key | 1 | |
ImGuiTestInputType_Char | 2 | |
ImGuiTestInputType_ViewportFocus | 3 | |
ImGuiTestInputType_ViewportSetPos | 4 | |
ImGuiTestInputType_ViewportSetSize | 5 | |
ImGuiTestInputType_ViewportClose | 6 |
TestInput (struct)¶
FIXME: May want to strip further now that core imgui is using its own input queue
| Member | |
|---|---|
ImGuiTestInputType Type = ImGuiTestInputType_None; | |
ImGuiKeyChord KeyChord = ImGuiKey_None; | |
ImWchar Char = 0; | |
bool Down = false; | |
ImGuiID ViewportId = 0; | |
ImVec2 ViewportPosSize; |
TestInput::ForKeyChord¶
static ImGuiTestInput ForKeyChord(ImGuiKeyChord key_chord, bool down);(private API)
TestInput::ForChar¶
static ImGuiTestInput ForChar(ImWchar v);(private API)
TestInput::ForViewportFocus¶
static ImGuiTestInput ForViewportFocus(ImGuiID viewport_id);(private API)
TestInput::ForViewportSetPos¶
static ImGuiTestInput ForViewportSetPos(ImGuiID viewport_id, const ImVec2& pos);(private API)
TestInput::ForViewportSetSize¶
static ImGuiTestInput ForViewportSetSize(ImGuiID viewport_id, const ImVec2& size);(private API)
TestInput::ForViewportClose¶
static ImGuiTestInput ForViewportClose(ImGuiID viewport_id);(private API)
TestInputs (struct)¶
| Member | |
|---|---|
ImVec2 MousePosValue; | Own non-rounded copy of MousePos in order facilitate simulating mouse movement very slow speed and high-framerate |
ImVec2 MouseWheel; | |
ImGuiID MouseHoveredViewport = 0; | |
int MouseButtonsValue = 0x00; | FIXME-TESTS: Use simulated_io.MouseDown[] ? |
bool HostEscDown = false; | |
float HostEscDownDuration = -1.0f; | Maintain our own DownDuration for host/backend ESC key so we can abort. |
ImVec2 HostMousePos; |
TestEnginePerfRecord (struct)¶
| Member | |
|---|---|
double RawValueMs; | For current frame |
TestEnginePerfRecord::ImGuiTestEnginePerfRecord¶
ImGuiTestEnginePerfRecord();TestEnginePerfRecord::UpdateValueForCurrentFrame¶
void UpdateValueForCurrentFrame(double v_ms);(private API)
TestEngine (struct)¶
[Internal] Test Engine Context
| Member | |
|---|---|
ImGuiTestEngineIO IO; | |
ImGuiContext* UiContextTarget = nullptr; | imgui context for testing |
ImGuiContext* UiContextActive = nullptr; | imgui context for testing == UiContextTarget or None |
bool Started = false; | |
bool UiContextHasHooks = false; | |
ImU64 BatchStartTime = 0; | |
ImU64 BatchEndTime = 0; | |
int FrameCount = 0; | |
float OverrideDeltaTime = -1.0f; | Inject custom delta time into imgui context to simulate clock passing faster than wall clock time. |
ImGuiTestContext* TestContext = nullptr; | Running test context |
bool TestsSourceLinesDirty = false; | |
ImGuiTestGatherTask GatherTask; | |
ImGuiTestFindByLabelTask FindByLabelTask; | |
ImGuiTextBuffer StringBuilderForChecks; | |
ImGuiTestInputs Inputs; | |
bool Abort = false; | |
ImGuiTest* UiSelectAndScrollToTest = nullptr; | |
ImGuiTest* UiSelectedTest = nullptr; | |
bool UiMetricsOpen = false; | |
bool UiDebugLogOpen = false; | |
bool UiCaptureToolOpen = false; | |
bool UiStackToolOpen = false; | |
bool UiPerfToolOpen = false; | |
float UiLogHeight = 150.0f; | |
ImU64 PerfTimestampPreNewFrame; | |
ImU64 PerfTimestampPreRender; | |
ImU64 PerfTimestampPreSwap; | |
ImU64 PerfTimestampPostSwap; | |
ImGuiTestEnginePerfRecord PerfDtApp; | |
ImGuiTestEnginePerfRecord PerfDtPreNewFrameToPreRender; | |
ImGuiTestEnginePerfRecord PerfDtPreRenderToPreSwap; | |
ImGuiTestEnginePerfRecord PerfDtPreNewFrameToPreSwap; | |
ImGuiTestEnginePerfRecord PerfDtPreSwapToPostSwap; | |
bool PreSwapCalled = false; | |
bool PostSwapCalled = false; | |
bool ToolDebugRebootUiContext = false; | Completely shutdown and recreate the dear imgui context in place |
bool ToolSlowDown = false; | |
int ToolSlowDownMs = 100; | |
ImGuiTestRunSpeed BackupConfigRunSpeed = ImGuiTestRunSpeed_Fast; | |
bool BackupConfigNoThrottle = false; |
TestEngine::ImGuiTestEngine¶
ImGuiTestEngine();Functions
INTERNAL FUNCTIONS¶
ImGuiTestEngine_FindItemInfo¶
ImGuiTestItemInfo* ImGuiTestEngine_FindItemInfo(ImGuiTestEngine* engine, ImGuiID id, const char* debug_id);(private API)
ImGuiTestEngine_Yield¶
void ImGuiTestEngine_Yield(ImGuiTestEngine* engine);(private API)
ImGuiTestEngine_SetDeltaTime¶
void ImGuiTestEngine_SetDeltaTime(ImGuiTestEngine* engine, float delta_time);(private API)
ImGuiTestEngine_GetFrameCount¶
int ImGuiTestEngine_GetFrameCount(ImGuiTestEngine* engine);(private API)
ImGuiTestEngine_PassFilter¶
bool ImGuiTestEngine_PassFilter(ImGuiTest* test, const char* filter);(private API)
ImGuiTestEngine_RunTest¶
void ImGuiTestEngine_RunTest(ImGuiTestEngine* engine, ImGuiTestContext* ctx, ImGuiTest* test, ImGuiTestRunFlags run_flags);(private API)
ImGuiTestEngine_BindImGuiContext¶
void ImGuiTestEngine_BindImGuiContext(ImGuiTestEngine* engine, ImGuiContext* ui_ctx);(private API)
ImGuiTestEngine_UnbindImGuiContext¶
void ImGuiTestEngine_UnbindImGuiContext(ImGuiTestEngine* engine, ImGuiContext* ui_ctx);(private API)
ImGuiTestEngine_RebootUiContext¶
void ImGuiTestEngine_RebootUiContext(ImGuiTestEngine* engine);(private API)
ImGuiTestEngine_UpdateTestsSourceLines¶
void ImGuiTestEngine_UpdateTestsSourceLines(ImGuiTestEngine* engine);(private API)
Helper functions¶
ImGuiTestEngine_GetStatusName¶
const char* ImGuiTestEngine_GetStatusName(ImGuiTestStatus v);(private API)
ImGuiTestEngine_GetRunSpeedName¶
const char* ImGuiTestEngine_GetRunSpeedName(ImGuiTestRunSpeed v);(private API)
ImGuiTestEngine_GetVerboseLevelName¶
const char* ImGuiTestEngine_GetVerboseLevelName(ImGuiTestVerboseLevel v);(private API)
imgui_te_ui.h¶
Functions¶
ImGuiTestEngine_ShowTestEngineWindows¶
IMGUI_API void ImGuiTestEngine_ShowTestEngineWindows(ImGuiTestEngine* engine, bool* p_open);ImGuiTestEngine_OpenSourceFile¶
IMGUI_API void ImGuiTestEngine_OpenSourceFile(ImGuiTestEngine* engine, const char* source_filename, int source_line_no);imgui_capture_tool.h¶
Forward declarations¶
Our types¶
External types
CaptureFlags_ (enum)¶
| Member | Value | |
|---|---|---|
ImGuiCaptureFlags_None = 0 | 0 | |
ImGuiCaptureFlags_StitchAll = 1 << 0 | 1 << 0 | Capture entire window scroll area (by scrolling and taking multiple screenshot). Only works for a single window. |
ImGuiCaptureFlags_IncludeOtherWindows = 1 << 1 | 1 << 1 | Disable hiding other windows (when CaptureAddWindow has been called by default other windows are hidden) |
ImGuiCaptureFlags_IncludePopups = 1 << 2 | 1 << 2 | Expand capture area to automatically include visible popups (Unused if ImGuiCaptureFlags_IncludeOtherWindows is set) |
ImGuiCaptureFlags_HideMouseCursor = 1 << 3 | 1 << 3 | Hide render software mouse cursor during capture. |
ImGuiCaptureFlags_Instant = 1 << 4 | 1 << 4 | Perform capture on very same frame. Only works when capturing a rectangular region. Unsupported features: content stitching, window hiding, window relocation. |
ImGuiCaptureFlags_NoSave = 1 << 5 | 1 << 5 | Do not save output image. |
CaptureArgs (struct)¶
Defines input and output arguments for capture process.
When capturing from tests you can usually use the ImGuiTestContext::CaptureXXX() helpers functions.
| Member | |
|---|---|
ImGuiCaptureFlags InFlags = 0; | Flags for customizing behavior of screenshot tool. |
ImVector<ImGuiWindow*> InCaptureWindows; | Windows to capture. All other windows will be hidden. May be used with InCaptureRect to capture only some windows in specified rect. |
ImRect InCaptureRect; | Screen rect to capture. Does not include padding. |
float InPadding = 16.0f; | Extra padding at the edges of the screenshot. Ensure that there is available space around capture rect horizontally, also vertically if ImGuiCaptureFlags_StitchAll is not used. |
int InRecordFPSTarget = 30; | FPS target for recording videos. |
int InSizeAlign = 0; | Resolution alignment (0 = auto, 1 = no alignment, >= 2 = align width/height to be multiple of given value) |
ImVec2 OutImageSize; | Produced image size. |
CaptureStatus (enum)¶
| Member | Value | |
|---|---|---|
ImGuiCaptureStatus_InProgress | 0 | |
ImGuiCaptureStatus_Done | 1 | |
ImGuiCaptureStatus_Error | 2 |
CaptureWindowData (struct)¶
| Member | |
|---|---|
ImGuiWindow* Window; | |
ImRect BackupRect; | |
ImVec2 PosDuringCapture; |