Skip to content

Commit d6117d4

Browse files
committed
Update ProcessorTester to optionally create audio component and control panel
1 parent 33d5330 commit d6117d4

2 files changed

Lines changed: 39 additions & 13 deletions

File tree

Tests/Processors/RecordNodeTests.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class RecordNodeTests : public testing::Test {
2323
numChannels,
2424
sampleRate,
2525
bitVolts
26-
}));
26+
}),
27+
ProcessorTesterMode::FullApp);
2728

2829
parentRecordingDir = std::filesystem::temp_directory_path() / "record_node_tests";
2930
if (std::filesystem::exists(parentRecordingDir)) {
@@ -285,7 +286,8 @@ class HardwareSynced_RecordNodeTests : public RecordNodeTests {
285286
1,
286287
0,
287288
true
288-
}));
289+
}),
290+
ProcessorTesterMode::FullApp);
289291

290292
parentRecordingDir = std::filesystem::temp_directory_path() / "record_node_hardware_sync_tests";
291293
if (std::filesystem::exists(parentRecordingDir)) {
@@ -873,7 +875,8 @@ class SingleChannel_RecordNodeTests : public RecordNodeTests {
873875
numChannels,
874876
sampleRate,
875877
bitVolts
876-
}));
878+
}),
879+
ProcessorTesterMode::FullApp);
877880

878881
parentRecordingDir = std::filesystem::temp_directory_path() / "record_node_single_ch_tests";
879882
if (std::filesystem::exists(parentRecordingDir)) {
@@ -961,7 +964,8 @@ class MultiStream_RecordNodeTests : public testing::Test {
961964
30000, // sample rate
962965
1.0f, // bitVolts
963966
3 // streams
964-
}));
967+
}),
968+
ProcessorTesterMode::FullApp);
965969

966970
parentRecordingDir = std::filesystem::temp_directory_path() / "record_node_multi_stream_tests";
967971
if (std::filesystem::exists(parentRecordingDir)) {
@@ -1055,7 +1059,8 @@ class BufferResize_RecordNodeTests : public RecordNodeTests {
10551059
numChannels,
10561060
sampleRate,
10571061
bitVolts
1058-
}));
1062+
}),
1063+
ProcessorTesterMode::FullApp);
10591064

10601065
parentRecordingDir = std::filesystem::temp_directory_path() / "record_node_buffer_resize_tests";
10611066
if (std::filesystem::exists(parentRecordingDir)) {
@@ -1120,7 +1125,8 @@ class ManyChannels_RecordNodeTests : public RecordNodeTests {
11201125
numChannels,
11211126
sampleRate,
11221127
bitVolts
1123-
}));
1128+
}),
1129+
ProcessorTesterMode::FullApp);
11241130

11251131
parentRecordingDir = std::filesystem::temp_directory_path() / "record_node_many_ch_tests";
11261132
if (std::filesystem::exists(parentRecordingDir)) {

Tests/TestHelpers/include/TestFixtures.h

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,20 @@
1010
#include <UI/ControlPanel.h>
1111
#include <juce_audio_processors/juce_audio_processors.h>
1212
#include <Processors/GenericProcessor/GenericProcessor.h>
13+
#include <stdexcept>
1314

1415
enum class TestSourceNodeType
1516
{
1617
Fake,
1718
Base
1819
};
1920

21+
enum class ProcessorTesterMode
22+
{
23+
GraphOnly,
24+
FullApp
25+
};
26+
2027
class TestSourceNodeBuilder
2128
{
2229
public:
@@ -64,7 +71,8 @@ class TestSourceNodeBuilder
6471
class ProcessorTester
6572
{
6673
public:
67-
ProcessorTester (TestSourceNodeBuilder sourceNodeBuilder)
74+
ProcessorTester (TestSourceNodeBuilder sourceNodeBuilder,
75+
ProcessorTesterMode mode = ProcessorTesterMode::GraphOnly)
6876
{
6977
// Singletons...
7078
MessageManager::deleteInstance();
@@ -79,10 +87,14 @@ class ProcessorTester
7987
customLookAndFeel = std::make_unique<CustomLookAndFeel>();
8088
LookAndFeel::setDefaultLookAndFeel (customLookAndFeel.get());
8189

82-
// All of these sets the global state in AccessClass in their constructors
83-
audioComponent = std::make_unique<AudioComponent>();
8490
processorGraph = std::make_unique<ProcessorGraph> (true);
85-
controlPanel = std::make_unique<ControlPanel> (processorGraph.get(), audioComponent.get(), true);
91+
92+
if (mode == ProcessorTesterMode::FullApp)
93+
{
94+
// These set global state in AccessClass and require a real audio-capable test environment.
95+
audioComponent = std::make_unique<AudioComponent>();
96+
controlPanel = std::make_unique<ControlPanel> (processorGraph.get(), audioComponent.get(), true);
97+
}
8698

8799
SourceNode* snTemp = sourceNodeBuilder.buildSourceNode();
88100
sourceNodeId = nextProcessorId++;
@@ -98,12 +110,14 @@ class ProcessorTester
98110
sn->initialize (false);
99111
sn->setDestNode (nullptr);
100112

101-
controlPanel->updateRecordEngineList();
113+
if (controlPanel != nullptr)
114+
controlPanel->updateRecordEngineList();
102115

103116
// Refresh everything
104117
processorGraph->updateSettings (sn);
105118

106-
controlPanel->colourChanged();
119+
if (controlPanel != nullptr)
120+
controlPanel->colourChanged();
107121
}
108122

109123
virtual ~ProcessorTester()
@@ -159,6 +173,9 @@ class ProcessorTester
159173

160174
void startAcquisition (bool startRecording, bool forceRecording = false)
161175
{
176+
if (controlPanel == nullptr)
177+
throw std::logic_error ("ProcessorTester::startAcquisition requires FullApp mode");
178+
162179
if (startRecording)
163180
{
164181
// Do it this way to ensure the GUI elements (which apparently control logic) are set properly
@@ -196,6 +213,9 @@ class ProcessorTester
196213

197214
void stopAcquisition()
198215
{
216+
if (controlPanel == nullptr)
217+
throw std::logic_error ("ProcessorTester::stopAcquisition requires FullApp mode");
218+
199219
controlPanel->stopAcquisition();
200220
}
201221

@@ -304,7 +324,7 @@ class DataThreadTester : public ProcessorTester
304324
{
305325
public:
306326
DataThreadTester (TestSourceNodeBuilder sourceNodeBuilder) :
307-
ProcessorTester (sourceNodeBuilder)
327+
ProcessorTester (sourceNodeBuilder, ProcessorTesterMode::GraphOnly)
308328
{}
309329

310330
template <

0 commit comments

Comments
 (0)