2024-07-09 20:42:56 +02:00
|
|
|
#include <gmock/gmock.h>
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
|
|
#include <uibase/iplugin.h>
|
2022-05-02 18:56:44 +02:00
|
|
|
|
|
|
|
|
#include "MockOrganizer.h"
|
|
|
|
|
#include "pythonrunner.h"
|
|
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
|
|
|
|
|
using namespace MOBase;
|
|
|
|
|
|
|
|
|
|
TEST(IPlugin, Basic)
|
|
|
|
|
{
|
2023-07-10 21:57:59 +02:00
|
|
|
const auto plugins_folder = std::filesystem::path(std::getenv("PLUGIN_DIR"));
|
2022-05-02 18:56:44 +02:00
|
|
|
|
2022-05-06 17:40:11 +02:00
|
|
|
auto runner = mo2::python::createPythonRunner();
|
2022-05-02 18:56:44 +02:00
|
|
|
runner->initialize();
|
|
|
|
|
|
|
|
|
|
// load objects
|
2023-07-10 21:57:59 +02:00
|
|
|
const auto objects =
|
|
|
|
|
runner->load("dummy_iplugin", plugins_folder / "dummy-iplugin.py");
|
2022-05-02 18:56:44 +02:00
|
|
|
EXPECT_EQ(objects.size(), 1);
|
|
|
|
|
|
|
|
|
|
// load the IPlugin
|
2023-07-10 21:57:59 +02:00
|
|
|
const IPlugin* plugin = qobject_cast<IPlugin*>(objects[0][0]);
|
2022-05-02 18:56:44 +02:00
|
|
|
EXPECT_NE(plugin, nullptr);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(plugin->name(), "The Name");
|
|
|
|
|
|
|
|
|
|
// settings
|
|
|
|
|
const auto settings = plugin->settings();
|
|
|
|
|
EXPECT_EQ(settings.size(), 1);
|
2024-08-10 12:23:12 +02:00
|
|
|
EXPECT_EQ(settings[0].name(), "a_setting");
|
|
|
|
|
EXPECT_EQ(settings[0].title(), "A Setting");
|
|
|
|
|
EXPECT_EQ(settings[0].description(), "the setting description");
|
|
|
|
|
EXPECT_EQ(settings[0].defaultValue().userType(), QMetaType::Type::Int);
|
|
|
|
|
EXPECT_EQ(settings[0].defaultValue().toInt(), 12);
|
2022-05-02 18:56:44 +02:00
|
|
|
|
|
|
|
|
// no translation, no custom implementation -> name()
|
|
|
|
|
EXPECT_EQ(plugin->localizedName(), "The Name");
|
|
|
|
|
}
|