blob: 83b30c4025d931eefd34fa6ceceb94b1727e333c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include <QJsonArray>
#include <QPluginLoader>
#include <gtest/gtest.h>
#include <iostream>
char *pluginPath;
class PluginLoaderTest : public ::testing::Test {
protected:
void SetUp() override { loader = new QPluginLoader; }
void TearDown() override { delete loader; }
QPluginLoader *loader = nullptr;
};
TEST_F(PluginLoaderTest, InterfaceTest)
{
// Ensure plugin loads
loader->setFileName(pluginPath);
EXPECT_TRUE(loader->load()) << "For plugin: " << pluginPath << '\n' << qUtf8Printable(loader->errorString());
// Ensure plugin has metadata
const auto metadata = loader->metaData()["MetaData"].toObject();
EXPECT_TRUE(metadata.contains("name"));
EXPECT_FALSE(metadata["name"].toString().isEmpty());
EXPECT_TRUE(metadata.contains("schemes"));
EXPECT_FALSE(metadata["schemes"].toArray().isEmpty());
}
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];
return RUN_ALL_TESTS();
}
|