Added test for larger SysEx frames. #47
This commit is contained in:
parent
597a75e638
commit
2e816e3e39
|
|
@ -13,8 +13,6 @@ BEGIN_UNNAMED_NAMESPACE
|
||||||
|
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
USING_NAMESPACE_UNIT_TESTS
|
USING_NAMESPACE_UNIT_TESTS
|
||||||
typedef test_mocks::SerialMock<32> SerialMock;
|
|
||||||
typedef midi::MidiInterface<SerialMock> MidiInterface;
|
|
||||||
|
|
||||||
template<unsigned Size>
|
template<unsigned Size>
|
||||||
struct VariableSysExSettings : midi::DefaultSettings
|
struct VariableSysExSettings : midi::DefaultSettings
|
||||||
|
|
@ -22,6 +20,10 @@ struct VariableSysExSettings : midi::DefaultSettings
|
||||||
static const unsigned SysExMaxSize = Size;
|
static const unsigned SysExMaxSize = Size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef test_mocks::SerialMock<256> SerialMock;
|
||||||
|
typedef VariableSysExSettings<256> Settings;
|
||||||
|
typedef midi::MidiInterface<SerialMock, Settings> MidiInterface;
|
||||||
|
|
||||||
MidiInterface* midi;
|
MidiInterface* midi;
|
||||||
|
|
||||||
class MidiInputCallbacks : public Test
|
class MidiInputCallbacks : public Test
|
||||||
|
|
@ -347,6 +349,50 @@ TEST_F(MidiInputCallbacks, sysEx)
|
||||||
EXPECT_THAT(sysExData, ElementsAreArray(rxData));
|
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)
|
void handleMtcQuarterFrame(byte inData)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue