Livt packages

Eccelerators.Matrix

Version 1.0.1

Reusable RGB matrix drawing, color conversion, animation pacing, and HUB75 display components for Livt.

Published files (48)

tests/MatrixPictureHoldTest.lvt

namespace Eccelerators.Matrix.Tests

using Eccelerators.Matrix
using Eccelerators.Matrix.Hub75

/**
 * Verify timed advance and wraparound with a short interval in a 50 MHz context.
 * One test observes the reset-selected image and makes serialized requests.
 */
@Test
@Context(ClockFrequency = 50MHz)
component MatrixPictureHoldTest
{
	// Owned subject and elapsed test-clock edges.
	subject: MatrixPictureSequence<1us, 2, 5>
	cycles: uint

	/**
	 * Own a sequence with the same logic as the demo but a short test interval.
	 */
	new()
	{
		this.subject = new MatrixPictureSequence<1us, 2, 5>()
	}

	/**
	 * Count context edges independently of the subject's scheduled calls.
	 */
	process Count()
	{
		state {
			this.cycles++
		}
	}

	/**
	 * Each advance waits at least 250 clocks and wraps after the second picture.
	 * Allow bounded method-call overhead in addition to the exact timer interval.
	 */
	@Test
	fn WaitsAndWrapsPictures()
	{
		assert this.subject.picture == 0

		for (var i = 0; i < 2; i++) {
			var before = this.cycles
			this.subject.Next()
			assert this.cycles - before >= 250
			assert this.cycles - before <= 350
			assert this.subject.picture == (i + 1) % 2
		}
	}
}