From 2e816e3e39337a79862d659b4796ac271d7b1b39 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Sat, 29 Oct 2016 09:53:05 +0200 Subject: [PATCH] Added test for larger SysEx frames. #47 --- .../tests/unit-tests_MidiInputCallbacks.cpp | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/test/unit-tests/tests/unit-tests_MidiInputCallbacks.cpp b/test/unit-tests/tests/unit-tests_MidiInputCallbacks.cpp index f8642e2..803e738 100644 --- a/test/unit-tests/tests/unit-tests_MidiInputCallbacks.cpp +++ b/test/unit-tests/tests/unit-tests_MidiInputCallbacks.cpp @@ -13,8 +13,6 @@ BEGIN_UNNAMED_NAMESPACE using namespace testing; USING_NAMESPACE_UNIT_TESTS -typedef test_mocks::SerialMock<32> SerialMock; -typedef midi::MidiInterface MidiInterface; template struct VariableSysExSettings : midi::DefaultSettings @@ -22,6 +20,10 @@ struct VariableSysExSettings : midi::DefaultSettings static const unsigned SysExMaxSize = Size; }; +typedef test_mocks::SerialMock<256> SerialMock; +typedef VariableSysExSettings<256> Settings; +typedef midi::MidiInterface MidiInterface; + MidiInterface* midi; class MidiInputCallbacks : public Test @@ -347,6 +349,50 @@ TEST_F(MidiInputCallbacks, sysEx) EXPECT_THAT(sysExData, ElementsAreArray(rxData)); } +TEST_F(MidiInputCallbacks, sysExLong) +{ + mMidi.setHandleSystemExclusive(handleSysEx); + mMidi.begin(MIDI_CHANNEL_OMNI); + mMidi.turnThruOff(); + + static const unsigned rxSize = 210; + static const byte rxData[rxSize] = { + 0xf0, + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 'H','e','l','l','o',',',' ','W','o','r','l','d','!', + 0xf7 + }; + mSerial.mRxBuffer.write(rxData, rxSize); + + for (unsigned i = 0; i < rxSize - 1; ++i) + { + EXPECT_EQ(mMidi.read(), false); + } + EXPECT_EQ(mMidi.read(), true); + EXPECT_EQ(mMidi.getType(), midi::SystemExclusive); + EXPECT_EQ(mMidi.getChannel(), 0); + EXPECT_EQ(mMidi.getSysExArrayLength(), rxSize); + + EXPECT_EQ(unsigned(mSerial.mTxBuffer.getLength()), rxSize); + const std::vector sysExData(mMidi.getSysExArray(), + mMidi.getSysExArray() + rxSize); + EXPECT_THAT(sysExData, ElementsAreArray(rxData)); +} + // -- void handleMtcQuarterFrame(byte inData)