add MasterEditor::RegisterTests
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#include <imgui/misc/cpp/imgui_stdlib.h>
|
#include <imgui/misc/cpp/imgui_stdlib.h>
|
||||||
#include <imgui_internal.h>
|
#include <imgui_internal.h>
|
||||||
#include <imgui_memory_editor.h>
|
#include <imgui_memory_editor.h>
|
||||||
|
#include <imgui_test_engine/imgui_te_ui.h>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
@@ -421,6 +422,7 @@ void MasterEditor::DrawYazeMenu() {
|
|||||||
DrawFileMenu();
|
DrawFileMenu();
|
||||||
DrawEditMenu();
|
DrawEditMenu();
|
||||||
DrawViewMenu();
|
DrawViewMenu();
|
||||||
|
DrawTestMenu();
|
||||||
DrawProjectMenu();
|
DrawProjectMenu();
|
||||||
DrawHelpMenu();
|
DrawHelpMenu();
|
||||||
|
|
||||||
@@ -672,6 +674,73 @@ void MasterEditor::DrawViewMenu() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MasterEditor::RegisterTests(ImGuiTestEngine* e) {
|
||||||
|
test_engine = e;
|
||||||
|
ImGuiTest* t = nullptr;
|
||||||
|
|
||||||
|
t = IM_REGISTER_TEST(e, "master_editor", "open_rom");
|
||||||
|
t->GuiFunc = [](ImGuiTestContext* ctx) {
|
||||||
|
IM_UNUSED(ctx);
|
||||||
|
ImGui::Begin("Test Window", nullptr, ImGuiWindowFlags_NoSavedSettings);
|
||||||
|
ImGui::Text("Hello, automation world");
|
||||||
|
ImGui::Button("Click Me");
|
||||||
|
if (ImGui::TreeNode("Node")) {
|
||||||
|
static bool b = false;
|
||||||
|
ImGui::Checkbox("Checkbox", &b);
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
};
|
||||||
|
t->TestFunc = [](ImGuiTestContext* ctx) {
|
||||||
|
ctx->SetRef("Test Window");
|
||||||
|
ctx->ItemClick("Click Me");
|
||||||
|
ctx->ItemOpen("Node"); // Optional as ItemCheck("Node/Checkbox") can do it
|
||||||
|
ctx->ItemCheck("Node/Checkbox");
|
||||||
|
ctx->ItemUncheck("Node/Checkbox");
|
||||||
|
};
|
||||||
|
|
||||||
|
t = IM_REGISTER_TEST(e, "master_editor", "use_variables");
|
||||||
|
struct TestVars2 {
|
||||||
|
int MyInt = 42;
|
||||||
|
};
|
||||||
|
t->SetVarsDataType<TestVars2>();
|
||||||
|
t->GuiFunc = [](ImGuiTestContext* ctx) {
|
||||||
|
TestVars2& vars = ctx->GetVars<TestVars2>();
|
||||||
|
ImGui::Begin("Test Window", nullptr, ImGuiWindowFlags_NoSavedSettings);
|
||||||
|
ImGui::SliderInt("Slider", &vars.MyInt, 0, 1000);
|
||||||
|
ImGui::End();
|
||||||
|
};
|
||||||
|
t->TestFunc = [](ImGuiTestContext* ctx) {
|
||||||
|
TestVars2& vars = ctx->GetVars<TestVars2>();
|
||||||
|
ctx->SetRef("Test Window");
|
||||||
|
|
||||||
|
IM_CHECK_EQ(vars.MyInt, 42);
|
||||||
|
ctx->ItemInputValue("Slider", 123);
|
||||||
|
IM_CHECK_EQ(vars.MyInt, 123);
|
||||||
|
};
|
||||||
|
|
||||||
|
t = IM_REGISTER_TEST(e, "master_editor", "open_metrics");
|
||||||
|
t->GuiFunc = [](ImGuiTestContext* ctx) {
|
||||||
|
IM_UNUSED(ctx);
|
||||||
|
ImGui::ShowMetricsWindow();
|
||||||
|
};
|
||||||
|
t->TestFunc = [](ImGuiTestContext* ctx) {
|
||||||
|
ctx->SetRef("Dear ImGui Metrics");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void MasterEditor::DrawTestMenu() {
|
||||||
|
static bool show_tests_ = false;
|
||||||
|
|
||||||
|
if (BeginMenu("Tests")) {
|
||||||
|
MenuItem("Run Tests", nullptr, &show_tests_);
|
||||||
|
EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (show_tests_)
|
||||||
|
ImGuiTestEngine_ShowTestEngineWindows(test_engine, &show_tests_);
|
||||||
|
}
|
||||||
|
|
||||||
void MasterEditor::DrawProjectMenu() {
|
void MasterEditor::DrawProjectMenu() {
|
||||||
static bool show_resource_label_manager = false;
|
static bool show_resource_label_manager = false;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
#include <imgui/misc/cpp/imgui_stdlib.h>
|
#include <imgui/misc/cpp/imgui_stdlib.h>
|
||||||
#include <imgui_memory_editor.h>
|
#include <imgui_memory_editor.h>
|
||||||
|
#include <imgui_test_engine/imgui_te_context.h>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
@@ -35,6 +36,16 @@
|
|||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
|
namespace core {
|
||||||
|
class GuiTestable {
|
||||||
|
public:
|
||||||
|
virtual void RegisterTests(ImGuiTestEngine* e) = 0;
|
||||||
|
|
||||||
|
ImGuiTestEngine* test_engine;
|
||||||
|
};
|
||||||
|
} // namespace core
|
||||||
|
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,7 +68,8 @@ namespace editor {
|
|||||||
*/
|
*/
|
||||||
class MasterEditor : public SharedRom,
|
class MasterEditor : public SharedRom,
|
||||||
public context::GfxContext,
|
public context::GfxContext,
|
||||||
public core::ExperimentFlags {
|
public core::ExperimentFlags,
|
||||||
|
public core::GuiTestable {
|
||||||
public:
|
public:
|
||||||
MasterEditor() {
|
MasterEditor() {
|
||||||
current_editor_ = &overworld_editor_;
|
current_editor_ = &overworld_editor_;
|
||||||
@@ -75,6 +87,8 @@ class MasterEditor : public SharedRom,
|
|||||||
auto emulator() -> emu::Emulator& { return emulator_; }
|
auto emulator() -> emu::Emulator& { return emulator_; }
|
||||||
auto quit() { return quit_; }
|
auto quit() { return quit_; }
|
||||||
|
|
||||||
|
void RegisterTests(ImGuiTestEngine* e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ManageActiveEditors();
|
void ManageActiveEditors();
|
||||||
void ManageKeyboardShortcuts();
|
void ManageKeyboardShortcuts();
|
||||||
@@ -89,6 +103,7 @@ class MasterEditor : public SharedRom,
|
|||||||
void DrawFileMenu();
|
void DrawFileMenu();
|
||||||
void DrawEditMenu();
|
void DrawEditMenu();
|
||||||
void DrawViewMenu();
|
void DrawViewMenu();
|
||||||
|
void DrawTestMenu();
|
||||||
void DrawProjectMenu();
|
void DrawProjectMenu();
|
||||||
void DrawHelpMenu();
|
void DrawHelpMenu();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user