summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-08-27 22:09:16 +0300
committeraqua <aqua@iserlohn-fortress.net>2022-08-27 22:44:31 +0300
commit86db843bc53a93dbf566b24df1462a22fccb619a (patch)
treee4a48a8e9053294f62ed5ea1d66d5c8f9d3d901e /src/plugins
parentRename rView to RekonqView (diff)
downloadrekonq-86db843bc53a93dbf566b24df1462a22fccb619a.tar.xz
Add parseCommandLine tests
- use PluginLoader in plugin tests
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/CMakeLists.txt2
-rw-r--r--src/plugins/pluginloader.h1
-rw-r--r--src/plugins/test/pluginloader.cpp23
3 files changed, 14 insertions, 12 deletions
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index ab4d8950..a978542f 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -3,5 +3,5 @@ target_link_libraries(pluginloader PUBLIC Qt6::Core Qt6::Widgets)
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_executable(load_plugin test/pluginloader.cpp)
- target_link_libraries(load_plugin GTest::gtest GTest::gtest_main Qt6::Core)
+ target_link_libraries(load_plugin GTest::gtest GTest::gtest_main pluginloader)
endif()
diff --git a/src/plugins/pluginloader.h b/src/plugins/pluginloader.h
index 319e985a..23c884b1 100644
--- a/src/plugins/pluginloader.h
+++ b/src/plugins/pluginloader.h
@@ -16,6 +16,7 @@ class PluginLoader : public QPluginLoader {
public:
explicit PluginLoader(const QString &path, QObject *parent = nullptr);
+ ~PluginLoader() override = default;
[[nodiscard]] auto schemes() const { return m_schemes; }
[[nodiscard]] bool hasScheme(const QString &scheme) const { return m_schemes.contains(scheme); }
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 <QJsonArray>
-#include <QPluginLoader>
#include <gtest/gtest.h>
-#include <iostream>
+
+#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();
}