Skip to content

Commit 3290218

Browse files
committed
[UPD] : update of visual_tests
1 parent ee2fc59 commit 3290218

2 files changed

Lines changed: 46 additions & 14 deletions

File tree

visualTests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ target_compile_definitions(${PROJECT} PRIVATE
6363
IMGUI_TEST_ENGINE_ENABLE_CAPTURE
6464
IMGUI_TEST_ENGINE_ENABLE_COROUTINE_STDTHREAD_IMPL
6565
CUSTOM_IMGUIFILEDIALOG_CONFIG="${CMAKE_CURRENT_SOURCE_DIR}/src/headers/customIgfdConfig.h"
66+
SAMPLES_DIRECTORY="${CMAKE_SOURCE_DIR}/samples"
6667
)
6768

6869
set_target_properties(${PROJECT} PROPERTIES CXX_STANDARD 17)

visualTests/src/tests/DialogTests.cpp

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,67 @@ void RegisterIGFDDialogTests(ImGuiTestEngine* e) {
3333

3434
ImGuiTest* t = nullptr;
3535

36-
//-----------------------------------------------------------------
37-
// ## Demo Test: Hello Automation World
38-
//-----------------------------------------------------------------
39-
40-
t = IM_REGISTER_TEST(e, "dialog_tests", "open dialog");
36+
t = IM_REGISTER_TEST(e, "dialog_tests", "open dialog and resize");
4137
t->GuiFunc = [](ImGuiTestContext* ctx) {
4238
auto& vars = ctx->GenericVars;
4339
if (ctx->IsFirstGuiFrame()) {
4440
IGFDTester::reinit();
4541
}
4642
ImGui::Begin("Test Window", nullptr, ImGuiWindowFlags_NoSavedSettings);
4743
if (ImGui::Button("Open Dialog")) {
48-
IGFDTester::ref().OpenDialog("test", "Choose a File", ".*");
44+
IGFD::FileDialogConfig config;
45+
config.path = SAMPLES_DIRECTORY;
46+
IGFDTester::ref().OpenDialog("test", "Choose a File", ".*", config);
4947
}
5048
ImGui::End();
51-
5249
if (IGFDTester::ref().Display("test", ImGuiWindowFlags_NoSavedSettings)) {
53-
if (IGFDTester::ref().IsOk()) {
54-
}
5550
IGFDTester::ref().Close();
5651
}
5752
};
5853
t->TestFunc = [](ImGuiTestContext* ctx) {
5954
auto& vars = ctx->GenericVars;
6055
ctx->SetRef("Test Window");
61-
// open dialog
62-
ctx->ItemClick("Open Dialog"); // relative to ref
63-
// resize
64-
ctx->WindowResize("//Choose a File##test", ImVec2(300, 300)); // we start with // for be relative to root
65-
//IM_CHECK(equal(vars.Color1, ImVec4(ImColor(0x11, 0x22, 0x33, 0xFF))));
56+
ctx->ItemClick("Open Dialog");
57+
ctx->WindowResize("//Choose a File##test", ImVec2(500, 300));
58+
};
59+
60+
t = IM_REGISTER_TEST(e, "dialog_tests", "open dialog, resize, select a path and a file");
61+
t->GuiFunc = [](ImGuiTestContext* ctx) {
62+
auto& vars = ctx->GenericVars;
63+
if (ctx->IsFirstGuiFrame()) {
64+
IGFDTester::reinit();
65+
}
66+
ImGui::Begin("Test Window", nullptr, ImGuiWindowFlags_NoSavedSettings);
67+
if (ImGui::Button("Open Dialog")) {
68+
IGFD::FileDialogConfig config;
69+
config.path = SAMPLES_DIRECTORY "/unicode";
70+
IGFDTester::ref().OpenDialog("test", "Choose a File", ".*", config);
71+
}
72+
ImGui::End();
73+
if (IGFDTester::ref().Display("test", ImGuiWindowFlags_NoSavedSettings, ImVec2(), ImVec2(500, 300))) {
74+
IGFDTester::ref().Close();
75+
}
6676
};
77+
t->TestFunc = [](ImGuiTestContext* ctx) {
78+
auto& vars = ctx->GenericVars;
79+
ctx->SetRef("Test Window");
80+
ctx->ItemClick("Open Dialog");
81+
ctx->SetRef("//Choose a File##test");
82+
ctx->ItemClick("**/samples");
83+
ImGuiWindow* fileTable = ctx->WindowInfo("FileDialog_fileTable").Window;
84+
IM_CHECK(fileTable != nullptr);
85+
ctx->WindowFocus(fileTable->ID);
86+
ImGui::SetScrollX(fileTable, 0);
87+
ImGui::SetScrollY(fileTable, 0);
88+
ctx->Yield();
89+
ctx->MouseSetViewport(fileTable);
90+
ctx->MouseMoveToPos(fileTable->Rect().GetCenter());
91+
IM_CHECK_EQ(fileTable->Scroll.x, 0.0f);
92+
IM_CHECK_EQ(fileTable->Scroll.y, 0.0f);
93+
ctx->MouseWheelY(5.0f); // Scroll down
94+
IM_CHECK_EQ(fileTable->Scroll.x, 0.0f);
95+
IM_CHECK_GT(fileTable->Scroll.y, 0.0f);
6796

97+
98+
};
6899
}

0 commit comments

Comments
 (0)