#include "gtest/gtest.h" #include "lumacs/editor_core.hpp" #include "lumacs/lua_api.hpp" #include "lumacs/keybinding.hpp" #include "lumacs/command_system.hpp" #include using namespace lumacs; class DefaultsLoadingTest : public ::testing::Test { protected: void SetUp() override { core = std::make_unique(); // Load the REAL defaults (this is what main.cpp does) core->lua_api()->load_init_file(); // Ensure buffer is ready core->new_buffer("*scratch*"); core->set_cursor({0,0}); } void TearDown() override { core.reset(); } std::unique_ptr core; }; TEST_F(DefaultsLoadingTest, SelfInsertFromDefaults) { std::string input_key = "h"; // 1. Process key (should be unbound in defaults) auto result = core->keybinding_manager().process_key(input_key); EXPECT_EQ(result.type, KeyResult::Unbound); // 2. Simulate GtkEditor fallback logic if (result.type == KeyResult::Unbound) { if (input_key.length() == 1) { // This executes the LUA version of self-insert-command defined in defaults.hpp auto cmd_result = core->command_system().execute("self-insert-command", {input_key}); EXPECT_EQ(cmd_result.status, CommandStatus::Success) << "Message: " << cmd_result.message; } } // 3. Verify state EXPECT_EQ(core->buffer().content(), "h"); }