Added test for larger SysEx frames. #47

This commit is contained in:
Francois Best 2016-10-29 09:53:05 +02:00
parent 597a75e638
commit 2e816e3e39
1 changed files with 48 additions and 2 deletions

View File

@ -13,8 +13,6 @@ BEGIN_UNNAMED_NAMESPACE
using namespace testing;
USING_NAMESPACE_UNIT_TESTS
typedef test_mocks::SerialMock<32> SerialMock;
typedef midi::MidiInterface<SerialMock> MidiInterface;
template<unsigned Size>
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<SerialMock, Settings> 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<byte> sysExData(mMidi.getSysExArray(),
mMidi.getSysExArray() + rxSize);
EXPECT_THAT(sysExData, ElementsAreArray(rxData));
}
// --
void handleMtcQuarterFrame(byte inData)