yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
test_editor.cc
Go to the documentation of this file.
2
3#include <SDL.h>
4
7#include "app/gui/style.h"
8#include "imgui/backends/imgui_impl_sdl2.h"
9#include "imgui/backends/imgui_impl_sdlrenderer2.h"
10#include "imgui/imgui.h"
11#include "imgui_test_engine/imgui_te_context.h"
12#include "imgui_test_engine/imgui_te_engine.h"
13#include "imgui_test_engine/imgui_te_imconfig.h"
14#include "imgui_test_engine/imgui_te_ui.h"
15
16namespace yaze {
17namespace test {
18namespace integration {
19
20absl::Status TestEditor::Update() {
21 ImGui::NewFrame();
22 if (ImGui::Begin("My Window")) {
23 ImGui::Text("Hello, world!");
24 ImGui::Button("My Button");
25 }
26
27 static bool show_demo_window = true;
28
29 ImGuiTestEngine_ShowTestEngineWindows(engine_, &show_demo_window);
30
31 ImGui::End();
32
33 return absl::OkStatus();
34}
35
36void TestEditor::RegisterTests(ImGuiTestEngine* engine) {
37 engine_ = engine;
38 ImGuiTest* test = IM_REGISTER_TEST(engine, "demo_test", "test1");
39 test->TestFunc = [](ImGuiTestContext* ctx) {
40 ctx->SetRef("My Window");
41 ctx->ItemClick("My Button");
42 ctx->ItemCheck("Node/Checkbox");
43 };
44}
45
49 controller.init_test_editor(&test_editor);
50
51 if (!controller.CreateSDL_Window().ok()) {
52 return EXIT_FAILURE;
53 }
54 if (!controller.CreateRenderer().ok()) {
55 return EXIT_FAILURE;
56 }
57 IMGUI_CHECKVERSION();
58 ImGui::CreateContext();
59
60 // Initialize Test Engine
61 ImGuiTestEngine* engine = ImGuiTestEngine_CreateContext();
62 ImGuiTestEngineIO& test_io = ImGuiTestEngine_GetIO(engine);
63 test_io.ConfigVerboseLevel = ImGuiTestVerboseLevel_Info;
64 test_io.ConfigVerboseLevelOnError = ImGuiTestVerboseLevel_Debug;
65
66 ImGuiIO& io = ImGui::GetIO();
67 io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
68
69 // Initialize ImGui for SDL
70 ImGui_ImplSDL2_InitForSDLRenderer(
72 ImGui_ImplSDLRenderer2_Init(
74
75 test_editor.RegisterTests(engine);
76 ImGuiTestEngine_Start(engine, ImGui::GetCurrentContext());
77 controller.set_active(true);
78
79 // Set the default style
81
82 // Build a new ImGui frame
83 ImGui_ImplSDLRenderer2_NewFrame();
84 ImGui_ImplSDL2_NewFrame();
85
86 while (controller.IsActive()) {
87 controller.OnInput();
88 if (const auto status = controller.OnTestLoad(); !status.ok()) {
89 return EXIT_FAILURE;
90 }
91 controller.DoRender();
92 }
93
94 ImGuiTestEngine_Stop(engine);
95 controller.OnExit();
96 return EXIT_SUCCESS;
97}
98
99} // namespace integration
100} // namespace test
101} // namespace yaze
Main controller for the application.
Definition controller.h:34
absl::Status CreateSDL_Window()
void set_active(bool active)
Definition controller.h:59
auto window() -> SDL_Window *
Definition controller.h:57
absl::Status CreateRenderer()
void init_test_editor(editor::Editor *editor)
Definition controller.h:58
auto renderer() -> SDL_Renderer *
Definition renderer.h:47
static Renderer & GetInstance()
Definition renderer.h:30
absl::Status Update() override
void RegisterTests(ImGuiTestEngine *engine)
void ColorsYaze()
Definition style.cc:423
Definition common.cc:21