← Back

ofxImGuiTestSuite

github.com/ofxyz/ofxImGuiTestSuite · @ofxyz
OF 0.12 GUI Templates

ofxImGui Test Engine

2 0 Last commit 5mo ago Created 5mo ago

README

ofxImGuiTestSuite



OpenFrameworks addon wrapping Dear ImGui Test Engine so you can write IM_REGISTER_TEST GUI-automation tests against apps built with ofxImGui.

preview

---

Quick start



1. Clone with submodules



git clone --recurse-submodules <this-repo-url>


If you already cloned without --recurse-submodules:

git submodule update --init libs/imgui_test_engine


The engine source lives at libs/imgui_test_engine/imgui_test_engine/ and is added to the build automatically via addon_config.mk.

2. Enable ImGui test-engine hooks



The hooks live inside Dear ImGui's compilation units, so the define must reach every TU that compiles ImGui — including ofxImGui itself.

Makefile / Project Generator — in your app's config.make:

PROJECT_CFLAGS += -DOFX_IMGUI_ENABLE_TEST_ENGINE


Visual Studio — add OFX_IMGUI_ENABLE_TEST_ENGINE to Preprocessor Definitions for all configs that compile ofxImGui and your app.

This activates the guarded block at the bottom of addons/ofxImGui/src/imconfig.h, which includes imgui_te_imconfig.h from the addon's include path.

3. Add to addons.make



ofxImGui
ofxImGuiTestSuite


4. Wire up in your app



#include "ofxImGuiTestSuite.h"

ofxImGuiTestSuite testSuite;

void ofApp::setup() {
    gui.setup();               // ofxImGui — creates ImGui context
    testSuite.setup();         // must come after gui.setup()
    RegisterTests(testSuite.getEngine(), ...);
}

void ofApp::exit() {
    testSuite.shutdown();      // before ofxImGui destroys the ImGui context
}

void ofApp::draw() {
    gui.begin();
    // ... your UI ...
    testSuite.showUi();        // optional: Test Engine UI panel
    gui.end();
    testSuite.postSwap();      // once per frame, after gui.end()
}


Register tests with IM_REGISTER_TEST — see example-test/src/tests.cpp for a working example and the upstream wiki.

---

Screen capture



The test engine's built-in capture path (imgui_capture_tool) is compiled in but capture is disabled by default (IMGUI_TEST_ENGINE_ENABLE_CAPTURE=0 in imconfig.h) to avoid an ffmpeg dependency. Re-enable it by setting the define to 1 in the guarded block in addons/ofxImGui/src/imconfig.h if you need automated screenshots.

---

References



Get this addon

HTTPS
SSH