42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
// E2E tests for chart_demo — Dear ImGui Test Engine.
|
|
// Built only when -DFN_BUILD_TESTS=ON. The same main.cpp from chart_demo is
|
|
// compiled here with FN_TEST_BUILD defined so its int main() is excluded and
|
|
// only render() is reused.
|
|
|
|
#include "app_base.h"
|
|
#include "imgui.h"
|
|
#include "imgui_te_engine.h"
|
|
#include "imgui_te_context.h"
|
|
|
|
void render(); // defined in chart_demo/main.cpp
|
|
|
|
static void register_tests(ImGuiTestEngine* e) {
|
|
ImGuiTest* t = nullptr;
|
|
|
|
// Smoke test: the main window appears and is non-empty.
|
|
t = IM_REGISTER_TEST(e, "chart_demo", "smoke_window_visible");
|
|
t->TestFunc = [](ImGuiTestContext* ctx) {
|
|
ctx->SetRef("fn_registry \xe2\x80\x94 Chart Demo"); // em-dash
|
|
IM_CHECK(ctx->WindowInfo("").ID != 0);
|
|
};
|
|
|
|
// Cycle through all four tabs. Test engine fails the test if any tab item
|
|
// is not found or cannot be activated — that is our implicit assertion.
|
|
t = IM_REGISTER_TEST(e, "chart_demo", "tabs_cycle_all");
|
|
t->TestFunc = [](ImGuiTestContext* ctx) {
|
|
ctx->SetRef("fn_registry \xe2\x80\x94 Chart Demo");
|
|
ctx->ItemClick("##charts/Line Plot");
|
|
ctx->ItemClick("##charts/Scatter Plot");
|
|
ctx->ItemClick("##charts/Bar Chart");
|
|
ctx->ItemClick("##charts/Heatmap");
|
|
};
|
|
}
|
|
|
|
int main() {
|
|
fn::AppConfig cfg{};
|
|
cfg.title = "chart_demo_tests";
|
|
cfg.width = 1280;
|
|
cfg.height = 800;
|
|
return fn::run_app_test(cfg, render, register_tests);
|
|
}
|