Working on tester.
This commit is contained in:
parent
72bd953a84
commit
347e55bf32
|
|
@ -43,11 +43,12 @@ LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
|
||||||
|
|
||||||
BEGIN_MIDI_NAMESPACE
|
BEGIN_MIDI_NAMESPACE
|
||||||
|
|
||||||
|
template<class SerialClass>
|
||||||
class TestFixture
|
class TestFixture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef const char* String;
|
typedef const char* String;
|
||||||
typedef bool (*Functor) (void);
|
typedef bool (*Functor) (MidiInterface<SerialClass>&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestFixture(String inTestName,
|
TestFixture(String inTestName,
|
||||||
|
|
@ -75,11 +76,11 @@ private:
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
template<class SerialPort>
|
template<class SerialClass>
|
||||||
class MidiTester
|
class MidiTester
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MidiTester(MidiInterface<SerialPort>& inInstance)
|
explicit MidiTester(MidiInterface<SerialClass>& inInstance)
|
||||||
: mInstance(inInstance)
|
: mInstance(inInstance)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +90,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline bool performTestFixture(TestFixture* inFixture)
|
inline bool performTestFixture(TestFixture<SerialClass>* inFixture)
|
||||||
{
|
{
|
||||||
if (inFixture != 0)
|
if (inFixture != 0)
|
||||||
{
|
{
|
||||||
|
|
@ -108,7 +109,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline void registerTest(TestFixture* inFixture)
|
inline void registerTest(TestFixture<SerialClass>* inFixture)
|
||||||
{
|
{
|
||||||
mTests[mNumActiveTests++] = inFixture;
|
mTests[mNumActiveTests++] = inFixture;
|
||||||
}
|
}
|
||||||
|
|
@ -132,15 +133,17 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MidiInterface<SerialPort>& mInstance;
|
MidiInterface<SerialClass>& mInstance;
|
||||||
TestFixture* mTests[NUM_TESTS];
|
TestFixture<SerialClass>* mTests[NUM_TESTS];
|
||||||
unsigned mNumActiveTests;
|
unsigned mNumActiveTests;
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool testNoteOn()
|
template<class SerialClass>
|
||||||
|
bool testNoteOn(midi::MidiInterface<SerialClass>& inMidi)
|
||||||
{
|
{
|
||||||
|
inMidi.sendNoteOn(12, 42);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,11 +178,17 @@ void setupLEDs()
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class SerialClass>
|
template<class SerialClass>
|
||||||
void setupTester(MidiTester<SerialClass>& inTester)
|
void setupTester(midi::MidiTester<SerialClass>& inTester)
|
||||||
{
|
{
|
||||||
inTester.registerTest(new midi::TestFixture("Note On", midi::testNoteOn));
|
inTester.registerTest(new midi::TestFixture("Note On", midi::testNoteOn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setupTesters()
|
||||||
|
{
|
||||||
|
setupTester<HardwareSerial>(testerHW);
|
||||||
|
setupTester<SoftwareSerial>(testerSW);
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void setProgressBar(unsigned inProgress, unsigned inTotal)
|
void setProgressBar(unsigned inProgress, unsigned inTotal)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue