Skip to content

Commit 670a812

Browse files
committed
some progress
1 parent 4c10620 commit 670a812

4 files changed

Lines changed: 88 additions & 19 deletions

File tree

3rdparty/imgui

Submodule imgui updated 81 files

ImGuiFileDialog

visualTests/src/tests/DialogTests.cpp

Lines changed: 85 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <tests/DialogTests.h>
22

33
#include <memory>
4+
#include <iostream>
45

56
#include <ImGuiFileDialog/ImGuiFileDialog.h>
67

@@ -57,7 +58,7 @@ void RegisterIGFDDialogTests(ImGuiTestEngine* e) {
5758
ctx->WindowResize("//Choose a File##test", ImVec2(500, 300));
5859
};
5960

60-
t = IM_REGISTER_TEST(e, "dialog_tests", "open dialog, resize, select a path and a file");
61+
t = IM_REGISTER_TEST(e, "dialog_tests", "open dialog, resize, select a path and a file");
6162
t->GuiFunc = [](ImGuiTestContext* ctx) {
6263
auto& vars = ctx->GenericVars;
6364
if (ctx->IsFirstGuiFrame()) {
@@ -70,30 +71,98 @@ void RegisterIGFDDialogTests(ImGuiTestEngine* e) {
7071
IGFDTester::ref().OpenDialog("test", "Choose a File", ".*", config);
7172
}
7273
ImGui::End();
73-
if (IGFDTester::ref().Display("test", ImGuiWindowFlags_NoSavedSettings, ImVec2(), ImVec2(500, 300))) {
74+
if (IGFDTester::ref().Display("test", ImGuiWindowFlags_NoSavedSettings, ImVec2(500, 300), ImVec2(1000, 600))) {
7475
IGFDTester::ref().Close();
7576
}
7677
};
7778
t->TestFunc = [](ImGuiTestContext* ctx) {
7879
auto& vars = ctx->GenericVars;
7980
ctx->SetRef("Test Window");
8081
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);
82+
// https://github.com/ocornut/imgui_test_engine/wiki/Named-References#using-windowinfo-to-easily-access-child-windows
83+
ctx->SetRef(ctx->WindowInfo("//Choose a File##test/childContent").Window);
84+
// https://github.com/ocornut/imgui_test_engine/wiki/Named-References#using-123-to-easily-encode-pushid-integers-in-a-string
85+
ctx->ItemClick("$$6/samples");
8886
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);
87+
//std::string path = "//" + std::string(ctx->RefStr) + "/FileTable";
88+
//ctx->SetRef(ctx->WindowInfo("//Choose a File##test/childContent/FileTable").Window);
89+
ImGuiTestItemList lst;
90+
ctx->GatherItems(&lst, ctx->GetRef());
91+
for (const auto it : lst) {
92+
std::cout << it.DebugLabel << "\n";
93+
}
94+
ImGuiTable* fileTable = ImGui::TableFindByID(ctx->GetID("FileTable"));
95+
IM_CHECK(fileTable != nullptr);
9696

9797

9898
};
9999
}
100+
101+
/*
102+
t = IM_REGISTER_TEST(e, "widgets", "widgets_multiselect_boxselect_2");
103+
struct BoxSelectTestVars { ImGuiTableFlags TableFlags = ImGuiTableFlags_ScrollY; ImGuiSelectionBasicStorage Selection; bool FrozenHeaders = false; };
104+
t->SetVarsDataType<BoxSelectTestVars>();
105+
t->GuiFunc = [](ImGuiTestContext* ctx)
106+
{
107+
auto& vars = ctx->GetVars<BoxSelectTestVars>();
108+
ImGui::SetNextWindowSize(ImVec2(400.0f, 300.0f), ImGuiCond_Appearing);
109+
ImGui::Begin("Test Window", NULL, ImGuiWindowFlags_NoSavedSettings);
110+
ImGui::CheckboxFlags("BordersOuter", &vars.TableFlags, ImGuiTableFlags_BordersOuter);
111+
ImGui::SameLine();
112+
ImGui::CheckboxFlags("BordersInner", &vars.TableFlags, ImGuiTableFlags_BordersInner);
113+
if (ImGui::BeginTable("table1", 1, vars.TableFlags))
114+
{
115+
auto ms = ImGui::BeginMultiSelect(ImGuiMultiSelectFlags_BoxSelect1d, vars.Selection.Size, 1000);
116+
vars.Selection.ApplyRequests(ms);
117+
if (vars.FrozenHeaders)
118+
{
119+
ImGui::TableSetupScrollFreeze(0, 1);
120+
ImGui::TableHeadersRow();
121+
}
122+
for (unsigned i = 0; i < 1000; i++)
123+
{
124+
char buf[32];
125+
snprintf(buf, sizeof buf, "Item %03d", i);
126+
ImGui::SetNextItemSelectionUserData(i);
127+
ImGui::TableNextColumn();
128+
ImGui::Selectable(buf, vars.Selection.Contains(i));
129+
}
130+
ms = ImGui::EndMultiSelect();
131+
vars.Selection.ApplyRequests(ms);
132+
ImGui::EndTable();
133+
}
134+
ImGui::End();
135+
};
136+
t->TestFunc = [](ImGuiTestContext* ctx)
137+
{
138+
auto& vars = ctx->GetVars<BoxSelectTestVars>();
139+
ImGuiTable* table = ImGui::TableFindByID(ctx->GetID("Test Window/table1"));
140+
IM_CHECK(table != NULL);
141+
142+
for (int step = 0; step < 4; step++)
143+
{
144+
vars.Selection.Clear();
145+
vars.TableFlags = (step & 1) ? (vars.TableFlags | ImGuiTableFlags_BordersOuter) : (vars.TableFlags & ~ImGuiTableFlags_BordersOuter);
146+
vars.FrozenHeaders = (step & 2) != 0;
147+
148+
ctx->SetRef(table->ID);
149+
ctx->MouseMove("Item 001");
150+
ctx->MouseDown(ImGuiMouseButton_Left);
151+
//ctx->SetRef("//$FOCUSED");
152+
ctx->MouseMoveToPos(ImGui::GetIO().MousePos + ImVec2(0, ctx->GetWindowByRef("//Test Window")->Size.y));
153+
ctx->SleepNoSkip(1.0f, 0.05f);
154+
ctx->MouseUp(ImGuiMouseButton_Left);
155+
IM_CHECK(vars.Selection.Contains(0) == false);
156+
int first_selected = 1;
157+
int last_selected = 1;
158+
for (int n = 1; n < 1000; n++)
159+
{
160+
if (vars.Selection.Contains(n) == false)
161+
break;
162+
last_selected = n;
163+
}
164+
IM_CHECK(vars.Selection.Size > 1);
165+
IM_CHECK_EQ(vars.Selection.Size, last_selected - first_selected + 1); // Check no selection gap (#7970)
166+
}
167+
};
168+
*/

0 commit comments

Comments
 (0)