From 86db843bc53a93dbf566b24df1462a22fccb619a Mon Sep 17 00:00:00 2001 From: aqua Date: Sat, 27 Aug 2022 22:09:16 +0300 Subject: Add parseCommandLine tests - use PluginLoader in plugin tests --- src/plugins/test/pluginloader.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/plugins/test/pluginloader.cpp') diff --git a/src/plugins/test/pluginloader.cpp b/src/plugins/test/pluginloader.cpp index 83b30c40..7c2791a4 100644 --- a/src/plugins/test/pluginloader.cpp +++ b/src/plugins/test/pluginloader.cpp @@ -1,24 +1,23 @@ #include -#include #include -#include + +#include "../pluginloader.h" char *pluginPath; class PluginLoaderTest : public ::testing::Test { protected: - void SetUp() override { loader = new QPluginLoader; } + void SetUp() override { loader = new PluginLoader(pluginPath); } void TearDown() override { delete loader; } - QPluginLoader *loader = nullptr; + PluginLoader *loader = nullptr; }; TEST_F(PluginLoaderTest, InterfaceTest) { // Ensure plugin loads - loader->setFileName(pluginPath); - EXPECT_TRUE(loader->load()) << "For plugin: " << pluginPath << '\n' << qUtf8Printable(loader->errorString()); + EXPECT_TRUE(loader->load()) << "plugin: " << pluginPath << '\n' << qUtf8Printable(loader->errorString()); // Ensure plugin has metadata const auto metadata = loader->metaData()["MetaData"].toObject(); @@ -26,15 +25,17 @@ TEST_F(PluginLoaderTest, InterfaceTest) EXPECT_FALSE(metadata["name"].toString().isEmpty()); EXPECT_TRUE(metadata.contains("schemes")); EXPECT_FALSE(metadata["schemes"].toArray().isEmpty()); + + // check available schemes + EXPECT_FALSE(loader->schemes().isEmpty()); + + // check interface cast + EXPECT_FALSE(loader->interface() == nullptr); } int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); - if (argc != 2) { - std::cerr << "Usage: " << argv[0] << " [path to plugin]" << std::endl; - return -1; - } - pluginPath = argv[1]; + pluginPath = argv[argc - 1]; return RUN_ALL_TESTS(); } -- cgit v1.2.1