assertEquals(1, tr.size());
assertEquals(0, tr.ticks());
byte[] bt = new byte[] {1, 2, 3};
MidiMessage1 message = new MidiMessage1(bt);
MidiEvent event = new MidiEvent(message, 10L);
assertTrue(tr.add(event));
assertFalse(tr.add(event));
bt[0] = 10;
bt[1] = 20;
assertFalse(tr.add(event));
/*
* values change
*/
assertEquals(10, tr.get(0).getMessage().getMessage()[0]);
assertEquals(20, tr.get(0).getMessage().getMessage()[1]);
assertEquals(3, tr.get(0).getMessage().getMessage()[2]);
/*
* if event is equals null, so it doesn't add to Track, i.e.
* method add(MidiEvent) return 'false'
*/
assertFalse(tr.add(null));
/*
* In the first place, the MidiMessage with the array MidiMessage.data contains
* -1, 47 and 0 is the meta-event End of Track, and so it
* accrue to Track always, even it contains meta-event already, i.e. method
* add(MidiEvent) always return 'true' in this case, but size of
* Track doesn't increase.
*
* In the second place, other events accrue to Track taking
* into account value of tick of MidiEvent, i.e. the MidiEvent
* with the smallest value of tick will be the first in the Track
* and so on and the MidiEvent with the biggest value of tick
* will be the last but one; the last is the meta-event End of Track
*
* If values of ticks of two or more events are equals, they add
* to Track on the basis of addition, i.e. if any event adds to Track,
* it will be after events with the same value of tick
*/
assertTrue(tr.add(new MidiEvent(new MidiMessage1(new byte[] {-1, 47, 0}), -20)));
assertTrue(tr.add(new MidiEvent(new MidiMessage1(new byte[] {-1, 47, 0}), 0)));
assertTrue(tr.add(new MidiEvent(new MidiMessage1(new byte[] {-23, 92, 89}), 8)));
assertTrue(tr.add(new MidiEvent(new MidiMessage1(new byte[] {23, 2, -9}), 8)));
assertEquals(-23, tr.get(0).getMessage().getMessage()[0]);
assertEquals(23, tr.get(1).getMessage().getMessage()[0]);
assertEquals(10, tr.get(2).getMessage().getMessage()[0]);
assertEquals(-1, tr.get(3).getMessage().getMessage()[0]);