yaze 0.2.2
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 {
18
19absl::Status TestEditor::Update() {
20 ImGui::NewFrame();
21 if (ImGui::Begin("My Window")) {
22 ImGui::Text("Hello, world!");
23 ImGui::Button("My Button");
24 }
25
26 static bool show_demo_window = true;
27
28 ImGuiTestEngine_ShowTestEngineWindows(engine_, &show_demo_window);
29
30 ImGui::End();
31
32 return absl::OkStatus();
33}
34
35void TestEditor::RegisterTests(ImGuiTestEngine* engine) {
36 engine_ = engine;
37 ImGuiTest* test = IM_REGISTER_TEST(engine, "demo_test", "test1");
38 test->TestFunc = [](ImGuiTestContext* ctx) {
39 ctx->SetRef("My Window");
40 ctx->ItemClick("My Button");
41 ctx->ItemCheck("Node/Checkbox");
42 };
43}
44
46 yaze::core::Controller controller;
47 if (!controller.CreateWindow().ok()) {
48 return EXIT_FAILURE;
49 }
50 if (!controller.CreateRenderer().ok()) {
51 return EXIT_FAILURE;
52 }
53 IMGUI_CHECKVERSION();
54 ImGui::CreateContext();
55
56 // Initialize Test Engine
57 ImGuiTestEngine* engine = ImGuiTestEngine_CreateContext();
58 ImGuiTestEngineIO& test_io = ImGuiTestEngine_GetIO(engine);
59 test_io.ConfigVerboseLevel = ImGuiTestVerboseLevel_Info;
60 test_io.ConfigVerboseLevelOnError = ImGuiTestVerboseLevel_Debug;
61
62 ImGuiIO& io = ImGui::GetIO();
63 io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
64
65 // Initialize ImGui for SDL
66 ImGui_ImplSDL2_InitForSDLRenderer(
67 controller.window(), yaze::core::Renderer::GetInstance().renderer());
68 ImGui_ImplSDLRenderer2_Init(yaze::core::Renderer::GetInstance().renderer());
69
71 test_editor.RegisterTests(engine);
72 ImGuiTestEngine_Start(engine, ImGui::GetCurrentContext());
73 controller.set_active(true);
74
75 // Set the default style
77
78 // Build a new ImGui frame
79 ImGui_ImplSDLRenderer2_NewFrame();
80 ImGui_ImplSDL2_NewFrame();
81
82 while (controller.IsActive()) {
83 controller.OnInput();
84 test_editor.Update();
85 controller.DoRender();
86 }
87
88 ImGuiTestEngine_Stop(engine);
89 controller.OnExit();
90 return EXIT_SUCCESS;
91}
92
93} // namespace test
94} // namespace yaze
Main controller for the application.
Definition controller.h:29
absl::Status CreateWindow()
auto window() -> SDL_Window *
Definition controller.h:44
bool IsActive() const
Definition controller.h:31
void set_active(bool active)
Definition controller.h:45
absl::Status CreateRenderer()
static Renderer & GetInstance()
Definition renderer.h:26
absl::Status Update() override
void RegisterTests(ImGuiTestEngine *engine)
void ColorsYaze()
Definition style.cc:132
int RunIntegrationTest()
Main namespace for the application.
Definition controller.cc:18