Hi all,
I’m trying to write some tests for a juce::JUCEApplication
derived class.
I can happily create an instance of the app like so:
JUCE_CREATE_APPLICATION_DEFINE (mvp::Application)
std::unique_ptr<juce::JUCEApplicationBase> createApplicationInstance()
{
return std::unique_ptr<juce::JUCEApplicationBase> {juce::JUCEApplicationBase::createInstance()};
}
// Test space
{
juce::JUCEApplicationBase::CreateInstance = &juce_CreateApplication;
juce::ScopedJuceinitialiser_GUI libraryInitialiser;
{
const auto app = createAppliationInstance();
REQUIRE (app != nullptr);
REQUIRE (app->initialiseApp());
REQUIRE (app->shutdownApp() != 0);
}
}
However, in the next test when I want to initialise a fresh instance of the app, like so:
const auto app = createApplicationInstance();
app->initialiseApp();
I hit an assertion in juce_Singleton.h, line 72
because the JuceMainMenuBarHolder
is set to not be recreated after deletion.
Is there any workaround for this that will let me create new instances on the app during my tests? In a real world scenario it would of course make sense to not create multiple instances, but for tests it’s extremely useful.