Browse Source

Restructure OpenGLDemo and UnitTestsDemo and remove unused macro from DemoRunner

tags/2021-05-28
ed 6 years ago
parent
commit
d6fb474c39
5 changed files with 990 additions and 1002 deletions
  1. +36
    -36
      examples/DemoRunner/Source/Demos/DemoPIPs1.cpp
  2. +26
    -26
      examples/DemoRunner/Source/Demos/DemoPIPs2.cpp
  3. +0
    -1
      examples/DemoRunner/Source/Demos/JUCEDemos.h
  4. +817
    -819
      examples/GUI/OpenGLDemo.h
  5. +111
    -120
      examples/Utilities/UnitTestsDemo.h

+ 36
- 36
examples/DemoRunner/Source/Demos/DemoPIPs1.cpp View File

@@ -80,50 +80,50 @@
void registerDemos_One() noexcept
{
REGISTER_DEMO (AudioAppDemo, Audio, false)
REGISTER_DEMO (AudioLatencyDemo, Audio, false)
REGISTER_DEMO (AudioPlaybackDemo, Audio, false)
REGISTER_DEMO (AudioRecordingDemo, Audio, false)
REGISTER_DEMO (AudioSettingsDemo, Audio, false)
REGISTER_DEMO (AudioSynthesiserDemo, Audio, false)
REGISTER_DEMO (MidiDemo, Audio, false)
REGISTER_DEMO (MPEDemo, Audio, false)
REGISTER_DEMO (PluckedStringsDemo, Audio, false)
REGISTER_DEMO (AudioAppDemo, Audio, false)
REGISTER_DEMO (AudioLatencyDemo, Audio, false)
REGISTER_DEMO (AudioPlaybackDemo, Audio, false)
REGISTER_DEMO (AudioRecordingDemo, Audio, false)
REGISTER_DEMO (AudioSettingsDemo, Audio, false)
REGISTER_DEMO (AudioSynthesiserDemo, Audio, false)
REGISTER_DEMO (MidiDemo, Audio, false)
REGISTER_DEMO (MPEDemo, Audio, false)
REGISTER_DEMO (PluckedStringsDemo, Audio, false)
#if JUCE_HAS_CONSTEXPR
REGISTER_DEMO (SimpleFFTDemo, Audio, false)
REGISTER_DEMO (BlocksDrawingDemo, BLOCKS, false)
REGISTER_DEMO (BlocksMonitorDemo, BLOCKS, false)
REGISTER_DEMO (BlocksSynthDemo, BLOCKS, false)
REGISTER_DEMO (ConvolutionDemo, DSP, false)
REGISTER_DEMO (FIRFilterDemo, DSP, false)
REGISTER_DEMO (GainDemo, DSP, false)
REGISTER_DEMO (IIRFilterDemo, DSP, false)
REGISTER_DEMO (OscillatorDemo, DSP, false)
REGISTER_DEMO (OverdriveDemo, DSP, false)
REGISTER_DEMO (SimpleFFTDemo, Audio, false)
REGISTER_DEMO (BlocksDrawingDemo, BLOCKS, false)
REGISTER_DEMO (BlocksMonitorDemo, BLOCKS, false)
REGISTER_DEMO (BlocksSynthDemo, BLOCKS, false)
REGISTER_DEMO (ConvolutionDemo, DSP, false)
REGISTER_DEMO (FIRFilterDemo, DSP, false)
REGISTER_DEMO (GainDemo, DSP, false)
REGISTER_DEMO (IIRFilterDemo, DSP, false)
REGISTER_DEMO (OscillatorDemo, DSP, false)
REGISTER_DEMO (OverdriveDemo, DSP, false)
#if JUCE_USE_SIMD
REGISTER_DEMO (SIMDRegisterDemo, DSP, false)
REGISTER_DEMO (SIMDRegisterDemo, DSP, false)
#endif
REGISTER_DEMO (StateVariableFilterDemo, DSP, false)
REGISTER_DEMO (WaveShaperTanhDemo, DSP, false)
REGISTER_DEMO (StateVariableFilterDemo, DSP, false)
REGISTER_DEMO (WaveShaperTanhDemo, DSP, false)
#endif
REGISTER_DEMO (Box2DDemo, Utilities, false)
REGISTER_DEMO (Box2DDemo, Utilities, false)
#if JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX
REGISTER_DEMO (ChildProcessDemo, Utilities, false)
REGISTER_DEMO (ChildProcessDemo, Utilities, false)
#endif
REGISTER_DEMO (CryptographyDemo, Utilities, false)
REGISTER_DEMO (JavaScriptDemo, Utilities, false)
REGISTER_DEMO (LiveConstantDemo, Utilities, false)
REGISTER_DEMO (MultithreadingDemo, Utilities, false)
REGISTER_DEMO (NetworkingDemo, Utilities, false)
REGISTER_DEMO (OSCDemo, Utilities, false)
REGISTER_DEMO (SystemInfoDemo, Utilities, false)
REGISTER_DEMO (TimersAndEventsDemo, Utilities, false)
REGISTER_DEMO_WITH_FILENAME (UnitTestClasses::UnitTestsDemo, Utilities, UnitTestsDemo, false)
REGISTER_DEMO (ValueTreesDemo, Utilities, false)
REGISTER_DEMO (XMLandJSONDemo, Utilities, false)
REGISTER_DEMO (CryptographyDemo, Utilities, false)
REGISTER_DEMO (JavaScriptDemo, Utilities, false)
REGISTER_DEMO (LiveConstantDemo, Utilities, false)
REGISTER_DEMO (MultithreadingDemo, Utilities, false)
REGISTER_DEMO (NetworkingDemo, Utilities, false)
REGISTER_DEMO (OSCDemo, Utilities, false)
REGISTER_DEMO (SystemInfoDemo, Utilities, false)
REGISTER_DEMO (TimersAndEventsDemo, Utilities, false)
REGISTER_DEMO (UnitTestsDemo, Utilities, false)
REGISTER_DEMO (ValueTreesDemo, Utilities, false)
REGISTER_DEMO (XMLandJSONDemo, Utilities, false)
}
Component* createIntroDemo()


+ 26
- 26
examples/DemoRunner/Source/Demos/DemoPIPs2.cpp View File

@@ -70,42 +70,42 @@
void registerDemos_Two() noexcept
{
REGISTER_DEMO (AnimationAppDemo, GUI, false)
REGISTER_DEMO (AnimationDemo, GUI, false)
REGISTER_DEMO (BouncingBallWavetableDemo, GUI, false)
REGISTER_DEMO (AnimationAppDemo, GUI, false)
REGISTER_DEMO (AnimationDemo, GUI, false)
REGISTER_DEMO (BouncingBallWavetableDemo, GUI, false)
#if JUCE_USE_CAMERA && ! JUCE_LINUX
REGISTER_DEMO (CameraDemo, GUI, true)
REGISTER_DEMO (CameraDemo, GUI, true)
#endif
#if ! JUCE_ANDROID
REGISTER_DEMO (CodeEditorDemo, GUI, false)
REGISTER_DEMO (CodeEditorDemo, GUI, false)
#endif
REGISTER_DEMO (ComponentDemo, GUI, false)
REGISTER_DEMO (ComponentTransformsDemo, GUI, false)
REGISTER_DEMO (DialogsDemo, GUI, false)
REGISTER_DEMO (FlexBoxDemo, GUI, false)
REGISTER_DEMO (FontsDemo, GUI, false)
REGISTER_DEMO (GraphicsDemo, GUI, false)
REGISTER_DEMO (ComponentDemo, GUI, false)
REGISTER_DEMO (ComponentTransformsDemo, GUI, false)
REGISTER_DEMO (DialogsDemo, GUI, false)
REGISTER_DEMO (FlexBoxDemo, GUI, false)
REGISTER_DEMO (FontsDemo, GUI, false)
REGISTER_DEMO (GraphicsDemo, GUI, false)
#if JUCE_HAS_CONSTEXPR
REGISTER_DEMO (GridDemo, GUI, false)
REGISTER_DEMO (GridDemo, GUI, false)
#endif
REGISTER_DEMO (ImagesDemo, GUI, false)
REGISTER_DEMO (KeyMappingsDemo, GUI, false)
REGISTER_DEMO (LookAndFeelDemo, GUI, false)
REGISTER_DEMO (MDIDemo, GUI, false)
REGISTER_DEMO (MenusDemo, GUI, false)
REGISTER_DEMO (MultiTouchDemo, GUI, false)
REGISTER_DEMO (ImagesDemo, GUI, false)
REGISTER_DEMO (KeyMappingsDemo, GUI, false)
REGISTER_DEMO (LookAndFeelDemo, GUI, false)
REGISTER_DEMO (MDIDemo, GUI, false)
REGISTER_DEMO (MenusDemo, GUI, false)
REGISTER_DEMO (MultiTouchDemo, GUI, false)
#if JUCE_OPENGL
REGISTER_DEMO (OpenGLAppDemo, GUI, true)
REGISTER_DEMO (OpenGLDemo2D, GUI, true)
REGISTER_DEMO_WITH_FILENAME (OpenGLDemoClasses::OpenGLDemo, GUI, OpenGLDemo, true)
REGISTER_DEMO (OpenGLAppDemo, GUI, true)
REGISTER_DEMO (OpenGLDemo2D, GUI, true)
REGISTER_DEMO (OpenGLDemo, GUI, true)
#endif
REGISTER_DEMO (PropertiesDemo, GUI, false)
REGISTER_DEMO (PropertiesDemo, GUI, false)
#if ! JUCE_LINUX
REGISTER_DEMO (VideoDemo, GUI, true)
REGISTER_DEMO (VideoDemo, GUI, true)
#endif
REGISTER_DEMO (WebBrowserDemo, GUI, true)
REGISTER_DEMO (WidgetsDemo, GUI, false)
REGISTER_DEMO (WindowsDemo, GUI, false)
REGISTER_DEMO (WebBrowserDemo, GUI, true)
REGISTER_DEMO (WidgetsDemo, GUI, false)
REGISTER_DEMO (WindowsDemo, GUI, false)
}
CodeEditorComponent::ColourScheme getDarkColourScheme()


+ 0
- 1
examples/DemoRunner/Source/Demos/JUCEDemos.h View File

@@ -34,7 +34,6 @@
#define CREATE_FILEPATH(DemoName, category) JUCE_STRINGIFY(EXPAND(category)/EXPAND(DemoName)EXPAND(FILE_EXT))
#define REGISTER_DEMO(DemoName, category, heavyweight) JUCEDemos::registerDemo ([] { return new DemoName(); }, CREATE_FILEPATH(DemoName, category), JUCE_STRINGIFY (category), heavyweight);
#define REGISTER_DEMO_WITH_FILENAME(DemoName, category, fileName, heavyweight) JUCEDemos::registerDemo ([] { return new DemoName(); }, CREATE_FILEPATH(fileName, category), JUCE_STRINGIFY (category), heavyweight);
//==============================================================================
struct JUCEDemos


+ 817
- 819
examples/GUI/OpenGLDemo.h
File diff suppressed because it is too large
View File


+ 111
- 120
examples/Utilities/UnitTestsDemo.h View File

@@ -40,7 +40,7 @@
defines: JUCE_UNIT_TESTS=1
type: Component
mainClass: UnitTestClasses::UnitTestsDemo
mainClass: UnitTestsDemo
useLocalCopy: 1
@@ -53,35 +53,98 @@
#include "../Assets/DemoUtilities.h"
//==============================================================================
struct UnitTestClasses
class UnitTestsDemo : public Component
{
class UnitTestsDemo;
class TestRunnerThread;
public:
UnitTestsDemo()
{
setOpaque (true);
addAndMakeVisible (startTestButton);
startTestButton.onClick = [this] { start(); };
addAndMakeVisible (testResultsBox);
testResultsBox.setMultiLine (true);
testResultsBox.setFont (Font (Font::getDefaultMonospacedFontName(), 12.0f, Font::plain));
addAndMakeVisible (categoriesBox);
categoriesBox.addItem ("All Tests", 1);
auto categories = UnitTest::getAllCategories();
categories.sort (true);
categoriesBox.addItemList (categories, 2);
categoriesBox.setSelectedId (1);
logMessage ("This panel runs the built-in JUCE unit-tests from the selected category.\n");
logMessage ("To add your own unit-tests, see the JUCE_UNIT_TESTS macro.");
setSize (500, 500);
}
~UnitTestsDemo()
{
stopTest();
}
//==============================================================================
// This subclass of UnitTestRunner is used to redirect the test output to our
// TextBox, and to interrupt the running tests when our thread is asked to stop..
class CustomTestRunner : public UnitTestRunner
void paint (Graphics& g) override
{
public:
CustomTestRunner (TestRunnerThread& trt) : owner (trt) {}
g.fillAll (getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::windowBackground,
Colours::grey));
}
void logMessage (const String& message) override
{
owner.logMessage (message);
}
void resized() override
{
auto bounds = getLocalBounds().reduced (6);
auto topSlice = bounds.removeFromTop (25);
startTestButton.setBounds (topSlice.removeFromLeft (200));
topSlice.removeFromLeft (10);
categoriesBox .setBounds (topSlice.removeFromLeft (250));
bounds.removeFromTop (5);
testResultsBox.setBounds (bounds);
}
void start()
{
startTest (categoriesBox.getText());
}
void startTest (const String& category)
{
testResultsBox.clear();
startTestButton.setEnabled (false);
currentTestThread.reset (new TestRunnerThread (*this, category));
currentTestThread->startThread();
}
bool shouldAbortTests() override
void stopTest()
{
if (currentTestThread.get() != nullptr)
{
return owner.threadShouldExit();
currentTestThread->stopThread (15000);
currentTestThread.reset();
}
}
private:
TestRunnerThread& owner;
void logMessage (const String& message)
{
testResultsBox.moveCaretToEnd();
testResultsBox.insertTextAtCaret (message + newLine);
testResultsBox.moveCaretToEnd();
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CustomTestRunner)
};
void testFinished()
{
stopTest();
startTestButton.setEnabled (true);
logMessage (newLine + "*** Tests finished ***");
}
private:
//==============================================================================
class TestRunnerThread : public Thread,
private Timer
@@ -121,117 +184,45 @@ struct UnitTestClasses
}
private:
UnitTestsDemo& owner;
const String category;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TestRunnerThread)
};
//==============================================================================
class UnitTestsDemo : public Component
{
public:
UnitTestsDemo()
{
setOpaque (true);
addAndMakeVisible (startTestButton);
startTestButton.onClick = [this] { start(); };
addAndMakeVisible (testResultsBox);
testResultsBox.setMultiLine (true);
testResultsBox.setFont (Font (Font::getDefaultMonospacedFontName(), 12.0f, Font::plain));
addAndMakeVisible (categoriesBox);
categoriesBox.addItem ("All Tests", 1);
auto categories = UnitTest::getAllCategories();
categories.sort (true);
categoriesBox.addItemList (categories, 2);
categoriesBox.setSelectedId (1);
logMessage ("This panel runs the built-in JUCE unit-tests from the selected category.\n");
logMessage ("To add your own unit-tests, see the JUCE_UNIT_TESTS macro.");
setSize (500, 500);
}
~UnitTestsDemo()
{
stopTest();
}
//==============================================================================
void paint (Graphics& g) override
{
g.fillAll (getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::windowBackground,
Colours::grey));
}
void resized() override
{
auto bounds = getLocalBounds().reduced (6);
auto topSlice = bounds.removeFromTop (25);
startTestButton.setBounds (topSlice.removeFromLeft (200));
topSlice.removeFromLeft (10);
categoriesBox .setBounds (topSlice.removeFromLeft (250));
bounds.removeFromTop (5);
testResultsBox.setBounds (bounds);
}
void start()
// This subclass of UnitTestRunner is used to redirect the test output to our
// TextBox, and to interrupt the running tests when our thread is asked to stop..
class CustomTestRunner : public UnitTestRunner
{
startTest (categoriesBox.getText());
}
public:
CustomTestRunner (TestRunnerThread& trt) : owner (trt) {}
void startTest (const String& category)
{
testResultsBox.clear();
startTestButton.setEnabled (false);
currentTestThread.reset (new TestRunnerThread (*this, category));
currentTestThread->startThread();
}
void logMessage (const String& message) override
{
owner.logMessage (message);
}
void stopTest()
{
if (currentTestThread.get() != nullptr)
bool shouldAbortTests() override
{
currentTestThread->stopThread (15000);
currentTestThread.reset();
return owner.threadShouldExit();
}
}
void logMessage (const String& message)
{
testResultsBox.moveCaretToEnd();
testResultsBox.insertTextAtCaret (message + newLine);
testResultsBox.moveCaretToEnd();
}
private:
TestRunnerThread& owner;
void testFinished()
{
stopTest();
startTestButton.setEnabled (true);
logMessage (newLine + "*** Tests finished ***");
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CustomTestRunner)
};
private:
std::unique_ptr<TestRunnerThread> currentTestThread;
UnitTestsDemo& owner;
const String category;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TestRunnerThread)
};
std::unique_ptr<TestRunnerThread> currentTestThread;
TextButton startTestButton { "Run Unit Tests..." };
ComboBox categoriesBox;
TextEditor testResultsBox;
TextButton startTestButton { "Run Unit Tests..." };
ComboBox categoriesBox;
TextEditor testResultsBox;
void lookAndFeelChanged() override
{
testResultsBox.applyFontToAllText (testResultsBox.getFont());
}
void lookAndFeelChanged() override
{
testResultsBox.applyFontToAllText (testResultsBox.getFont());
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UnitTestsDemo)
};
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UnitTestsDemo)
};

Loading…
Cancel
Save