Files
modorganizer-plugin_python/tests/runner/test_iplugin.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.2 KiB
C++
Raw Normal View History

2025-05-29 11:03:51 +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)
{
const auto plugins_folder = QString(std::getenv("PLUGIN_DIR"));
auto runner = mo2::python::createPythonRunner();
2022-05-02 18:56:44 +02:00
runner->initialize();
// load objects
const auto objects = runner->load(plugins_folder + "/dummy-iplugin.py");
EXPECT_EQ(objects.size(), 1);
// load the IPlugin
const IPlugin* plugin = qobject_cast<IPlugin*>(objects[0]);
EXPECT_NE(plugin, nullptr);
EXPECT_EQ(plugin->author(), "The Author");
EXPECT_EQ(plugin->name(), "The Name");
EXPECT_EQ(plugin->version(), VersionInfo(1, 3, 0));
EXPECT_EQ(plugin->description(), "The Description");
// settings
const auto settings = plugin->settings();
EXPECT_EQ(settings.size(), 1);
EXPECT_EQ(settings[0].key, "a setting");
EXPECT_EQ(settings[0].description, "the setting description");
2025-05-29 11:03:51 +02:00
EXPECT_EQ(settings[0].defaultValue.userType(), QMetaType::Type::Int);
2022-05-02 18:56:44 +02:00
EXPECT_EQ(settings[0].defaultValue.toInt(), 12);
// no translation, no custom implementation -> name()
EXPECT_EQ(plugin->localizedName(), "The Name");
}