imgui_test_engine icon indicating copy to clipboard operation
imgui_test_engine copied to clipboard

How to get context of items that are in a 3D scene to participate in a test?

Open rudycazabon opened this issue 1 year ago • 3 comments

<please, if there is an FAQ or other place to ask these questions do let me know>

Thus far ImGui Test Engine checks off most of everything I require from a test framework. What I really would like to know is how (if at all possible) to register callbacks from items that I select within the context of the 3D scene that I have in my app such that I can use them within the test framework?

For example, if my little app has a few objects, and I select one and some behaviour happens, what might be the most sensible way for me to register the event and callback such that later, within that same scene, I can write a test that automates the given action? Is that even sensible within ImGui Test Engine?

rudycazabon avatar Apr 11 '23 21:04 rudycazabon

Hello,

I am not sure I understand your question, it's too ambiguous. What do you mean by callbacks?

If your item in the 3D scene are dear imgui widgets projected into 2D, they can register themselves using IMGUI_TEST_ENGINE_ITEM_ADD() + IMGUI_TEST_ENGINE_ITEM_INFO() like other dear imgui widgets.

If your items in the 3D scene are well... 3D items.. this isn't something the test engine needs to know about. But you can use queries from your 3D engine to retrieve relative coordinates in the 2D space and use e.g. ctx->MouseMove() calls to hover them within your viewport, or use high-level queries in your 3D engine to rotate the camera so that some object become visible and unobstructed before you can click on it. There's no limitation to what you can do as long as you can interface with your 3D engine to make actions, but the ball is in your court, Test Engine isn't going to magically guess how your 3D engine and viewport works.

ocornut avatar Apr 11 '23 22:04 ocornut

Ocornut - no, thank you for your prompt reply. I wasn't aware of how to go about registering via imgui_test_engine_item_add + _info. It is not my expectation that Test Engine should know anything about the workings of my 3D engine ... I just need to know what I need to bubble up from it and into Test Engine.

rudycazabon avatar Apr 12 '23 16:04 rudycazabon

I just do fake mouse moves in my viewport widget to particular positions and then do the ctx->MouseClick() calls.

e.g. the linked test is an easy way to move the cursor into the middle of the viewport and clicks the left mouse button to place a voxel

  • https://github.com/vengi-voxel/vengi/blob/850bc2af5f40b19bea3d316268999ec5ebfcd247/src/tools/voxedit/modules/voxedit-ui/tests/ViewportTest.cpp#L13

In this example I test the selection by spanning an aabb with the test engine:

  • https://github.com/vengi-voxel/vengi/blob/850bc2af5f40b19bea3d316268999ec5ebfcd247/src/tools/voxedit/modules/voxedit-ui/tests/BrushPanelTest.cpp#L36

mgerhardy avatar Apr 23 '24 18:04 mgerhardy