mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Removed MIDI devices unit tests
This commit is contained in:
parent
4fa131f5a7
commit
c9fe0afd0f
1 changed files with 0 additions and 117 deletions
|
|
@ -157,121 +157,4 @@ void MidiOutput::run()
|
|||
clearAllPendingMessages();
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//==============================================================================
|
||||
#if JUCE_UNIT_TESTS
|
||||
|
||||
class MidiDevicesUnitTests : public UnitTest
|
||||
{
|
||||
public:
|
||||
MidiDevicesUnitTests() : UnitTest ("MidiInput/MidiOutput", "MIDI/MPE") {}
|
||||
|
||||
void runTest() override
|
||||
{
|
||||
beginTest ("default device (input)");
|
||||
{
|
||||
auto devices = MidiInput::getAvailableDevices();
|
||||
auto defaultDevice = MidiInput::getDefaultDevice();
|
||||
|
||||
if (devices.size() == 0)
|
||||
expect (defaultDevice == MidiDeviceInfo());
|
||||
else
|
||||
expect (devices.contains (defaultDevice));
|
||||
}
|
||||
|
||||
beginTest ("default device (output)");
|
||||
{
|
||||
auto devices = MidiOutput::getAvailableDevices();
|
||||
auto defaultDevice = MidiOutput::getDefaultDevice();
|
||||
|
||||
if (devices.size() == 0)
|
||||
expect (defaultDevice == MidiDeviceInfo());
|
||||
else
|
||||
expect (devices.contains (defaultDevice));
|
||||
}
|
||||
|
||||
#if JUCE_MAC || JUCE_LINUX || JUCE_IOS
|
||||
String testDeviceName ("TestDevice");
|
||||
String testDeviceName2 ("TestDevice2");
|
||||
|
||||
struct MessageCallbackHandler : public MidiInputCallback
|
||||
{
|
||||
void handleIncomingMidiMessage (MidiInput* source, const MidiMessage& message) override
|
||||
{
|
||||
const ScopedLock sl (messageLock);
|
||||
|
||||
messageSource = source;
|
||||
messageReceived = message;
|
||||
}
|
||||
|
||||
MidiInput* messageSource = nullptr;
|
||||
MidiMessage messageReceived;
|
||||
CriticalSection messageLock;
|
||||
};
|
||||
|
||||
MessageCallbackHandler handler;
|
||||
|
||||
beginTest ("create device (input)");
|
||||
{
|
||||
std::unique_ptr<MidiInput> device (MidiInput::createNewDevice (testDeviceName, &handler));
|
||||
|
||||
expect (device.get() != nullptr);
|
||||
expect (device->getName() == testDeviceName);
|
||||
|
||||
device->setName (testDeviceName2);
|
||||
expect (device->getName() == testDeviceName2);
|
||||
}
|
||||
|
||||
beginTest ("create device (output)");
|
||||
{
|
||||
std::unique_ptr<MidiOutput> device (MidiOutput::createNewDevice (testDeviceName));
|
||||
|
||||
expect (device.get() != nullptr);
|
||||
expect (device->getName() == testDeviceName);
|
||||
}
|
||||
|
||||
#if JUCE_MODAL_LOOPS_PERMITTED
|
||||
auto testMessage = MidiMessage::noteOn (5, 12, (uint8) 51);
|
||||
|
||||
beginTest ("send messages");
|
||||
{
|
||||
std::unique_ptr<MidiInput> midiInput (MidiInput::createNewDevice (testDeviceName, &handler));
|
||||
expect (midiInput.get() != nullptr);
|
||||
midiInput->start();
|
||||
|
||||
auto inputInfo = midiInput->getDeviceInfo();
|
||||
|
||||
expect (MidiOutput::getAvailableDevices().contains (inputInfo));
|
||||
|
||||
std::unique_ptr<MidiOutput> midiOutput (MidiOutput::openDevice (midiInput->getIdentifier()));
|
||||
expect (midiOutput.get() != nullptr);
|
||||
|
||||
midiOutput->sendMessageNow (testMessage);
|
||||
|
||||
// Pump the message thread for a bit to allow the message to be delivered
|
||||
MessageManager::getInstance()->runDispatchLoopUntil (100);
|
||||
|
||||
{
|
||||
const ScopedLock sl (handler.messageLock);
|
||||
|
||||
expect (handler.messageSource == midiInput.get());
|
||||
|
||||
expect (handler.messageReceived.getChannel() == testMessage.getChannel());
|
||||
expect (handler.messageReceived.getNoteNumber() == testMessage.getNoteNumber());
|
||||
expect (handler.messageReceived.getVelocity() == testMessage.getVelocity());
|
||||
}
|
||||
|
||||
midiInput->stop();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
static MidiDevicesUnitTests MidiDevicesUnitTests;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace juce
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue