add message_editor_test and register in ctx

This commit is contained in:
scawful
2024-07-28 12:10:42 -04:00
parent 2cb942a712
commit c54ca779db
5 changed files with 30 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ set(
app/editor/sprite/sprite_editor.cc
app/editor/music/music_editor.cc
app/editor/message/message_editor.cc
app/editor/message/message_editor_test.cc
app/editor/code/assembly_editor.cc
app/editor/graphics/screen_editor.cc
app/editor/graphics/graphics_editor.cc

View File

@@ -69,6 +69,7 @@ class MasterEditor : public SharedRom,
active_editors_.push_back(&graphics_editor_);
active_editors_.push_back(&palette_editor_);
active_editors_.push_back(&sprite_editor_);
active_editors_.push_back(&message_editor_);
}
void SetupScreen(std::shared_ptr<SDL_Renderer> renderer,

View File

@@ -5,6 +5,8 @@ namespace app {
namespace editor {
void MasterEditor::RegisterTests(ImGuiTestEngine* e) {
message_editor_.RegisterTests(e);
test_engine = e;
ImGuiTest* t = nullptr;

View File

@@ -13,6 +13,7 @@
#include <unordered_map>
#include <vector>
#include "app/core/testable.h"
#include "app/editor/message/message_data.h"
#include "app/editor/utils/editor.h"
#include "app/gfx/bitmap.h"
@@ -44,7 +45,6 @@ static int defaultColor = 6;
static std::vector<uint8_t> ParseMessageToData(string str);
struct TextElement {
uint8_t ID;
string Token;
@@ -242,7 +242,9 @@ static const std::unordered_map<uint8_t, wchar_t> CharEncoder = {
static TextElement DictionaryElement =
TextElement(0x80, DICTIONARYTOKEN, true, "Dictionary");
class MessageEditor : public Editor, public SharedRom {
class MessageEditor : public Editor,
public SharedRom,
public core::GuiTestable {
public:
struct DictionaryEntry {
uint8_t ID;
@@ -295,6 +297,7 @@ class MessageEditor : public Editor, public SharedRom {
return absl::UnimplementedError("Find not implemented");
}
absl::Status Save();
void RegisterTests(ImGuiTestEngine* e) override;
TextElement FindMatchingCommand(uint8_t byte);
TextElement FindMatchingSpecial(uint8_t value);

View File

@@ -0,0 +1,21 @@
#include "message_editor.h"
namespace yaze {
namespace app {
namespace editor {
void MessageEditor::RegisterTests(ImGuiTestEngine* e) {
test_engine = e;
ImGuiTest* t = nullptr;
t = IM_REGISTER_TEST(e, "message_editor", "read_all_text_data");
t->TestFunc = [](ImGuiTestContext* ctx) {
ctx->SetRef("##YazeMain/##TabBar/Message");
ctx->ItemClick("TestButton");
};
}
} // namespace editor
} // namespace app
} // namespace yaze