summaryrefslogtreecommitdiff
path: root/src/plugins/test/pluginloader.cpp
blob: 7c2791a4c594f656696b2727064c35eeffc32aa6 (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
41
#include <QJsonArray>
#include <gtest/gtest.h>

#include "../pluginloader.h"

char *pluginPath;

class PluginLoaderTest : public ::testing::Test {

protected:
  void SetUp() override { loader = new PluginLoader(pluginPath); }
  void TearDown() override { delete loader; }

  PluginLoader *loader = nullptr;
};

TEST_F(PluginLoaderTest, InterfaceTest)
{
  // Ensure plugin loads
  EXPECT_TRUE(loader->load()) << "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());

  // 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);
  pluginPath = argv[argc - 1];
  return RUN_ALL_TESTS();
}