Skip to content

Commit 81b7e9a

Browse files
committed
Refactor PluginManagerTests to use test fixture and improve plugin loading tests
1 parent fcf4769 commit 81b7e9a

2 files changed

Lines changed: 35 additions & 47 deletions

File tree

Tests/Processors/PluginManagerTests.cpp

Lines changed: 35 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,76 +2,64 @@
22

33
#include <ProcessorHeaders.h>
44
#include <Processors/PluginManager/PluginManager.h>
5+
class PluginManagerTest : public testing::Test
6+
{
7+
protected:
8+
void SetUp() override
9+
{
10+
files =
11+
File::getCurrentWorkingDirectory().getChildFile ("../ArduinoOutput").findChildFiles (File::findFiles, false, "ArduinoOutput.*", File::FollowSymlinks::no);
12+
13+
ASSERT_EQ (files.size(), 1);
14+
15+
String path = files[0].getFullPathName();
16+
17+
pluginManager.loadPlugin(path);
18+
19+
}
20+
21+
PluginManager pluginManager;
22+
23+
private:
24+
Array<File> files;
25+
};
526

627
/*
7-
The Plugin Manager will be passed an absolute path to a DLL containing a Plugin library.
828
The Plugin Manager should load the DLL without warning or errors.
929
The Plugin Manager should record library information from the DLL that will be verified.
1030
*/
11-
TEST(PluginManagerTest, PluginLoading)
31+
TEST_F (PluginManagerTest, PluginLoading)
1232
{
13-
PluginManager pluginManager;
14-
15-
String path =
16-
File::getCurrentWorkingDirectory().
17-
getChildFile("../Resources/ArduinoOutput.dll").
18-
getFullPathName();
19-
20-
pluginManager.loadPlugin(path);
21-
22-
EXPECT_EQ(pluginManager.getLibraryName(0), "Arduino Output");
33+
EXPECT_EQ (pluginManager.getNumProcessors(), 1);
34+
EXPECT_EQ (pluginManager.getLibraryName (0), "Arduino Output");
2335
}
2436

2537
/*
26-
The Plugin Manager will first load a Plugin DLL.
27-
A Plugin Description will be passed to the Plugin Manager,
28-
which will output an instance of the Processor by
29-
locating the associated Library Info object containing the Processor's constructor.
38+
Find the processor information from the Plugin Manager and verify the processor can be created.
3039
*/
31-
TEST(PluginManagerTest, PluginCreation)
40+
TEST_F (PluginManagerTest, PluginCreation)
3241
{
33-
PluginManager pluginManager;
34-
35-
String path =
36-
File::getCurrentWorkingDirectory().
37-
getChildFile("../Resources/ArduinoOutput.dll").
38-
getFullPathName();
39-
40-
int idx = pluginManager.loadPlugin(path) - 1;
41-
Plugin::ProcessorInfo processorInfo = pluginManager.getProcessorInfo(idx);
42+
Plugin::ProcessorInfo processorInfo = pluginManager.getProcessorInfo(0);
4243

4344
EXPECT_EQ(String(processorInfo.name), "Arduino Output");
4445
EXPECT_EQ(processorInfo.type, Plugin::Processor::SINK);
46+
EXPECT_NE(processorInfo.creator, nullptr);
4547
}
4648

47-
TEST(PluginManagerTest, getLibraryIndexFromPlugin)
49+
TEST_F (PluginManagerTest, getLibraryIndexFromPlugin)
4850
{
49-
PluginManager pluginManager;
50-
51-
String path =
52-
File::getCurrentWorkingDirectory().
53-
getChildFile("../Resources/ArduinoOutput.dll").
54-
getFullPathName();
55-
56-
int idx = pluginManager.loadPlugin(path) - 1;
5751
Plugin::Type type = Plugin::Type::PROCESSOR;
5852

59-
EXPECT_EQ(pluginManager.getLibraryIndexFromPlugin(type, idx), 0);
53+
EXPECT_EQ (pluginManager.getLibraryIndexFromPlugin (type, 0), 0);
6054
}
6155

62-
TEST(PluginManagerTest, removePlugin)
56+
TEST_F (PluginManagerTest, removePlugin)
6357
{
64-
PluginManager pluginManager;
65-
66-
String path =
67-
File::getCurrentWorkingDirectory().
68-
getChildFile("../Resources/ArduinoOutput.dll").
69-
getFullPathName();
58+
auto libName = pluginManager.getLibraryName (0);
7059

71-
int idx = pluginManager.loadPlugin(path) - 1;
72-
Plugin::ProcessorInfo processorInfo = pluginManager.getProcessorInfo(idx);
60+
ASSERT_EQ (libName, "Arduino Output");
7361

74-
pluginManager.removePlugin(processorInfo.name);
62+
pluginManager.removePlugin (libName);
7563

76-
EXPECT_EQ(pluginManager.getNumProcessors(), 0);
64+
EXPECT_EQ (pluginManager.getNumProcessors(), 0);
7765
}

Tests/Resources/ArduinoOutput.dll

-297 KB
Binary file not shown.

0 commit comments

Comments
 (0)