package cloud.molberg.mgutility; public final class PushToTalkPressTest { public static void main(String[] args) { PushToTalkPress press = new PushToTalkPress(); require(!press.end(1, 42, 120, 100), "Ignore orphan release"); require(press.begin(1, 42, 120, 100, 0), "Start on initial down"); require(!press.begin(1, 42, 120, 100, 0), "Duplicate down must not restart recording"); require(!press.begin(1, 42, 120, 100, 1), "Repeat must not restart recording"); require(press.matches(1, 42, 120, 100), "Repeat remains consumed"); require(!press.end(2, 42, 120, 100), "Other input device cannot release"); require(!press.end(1, 43, 121, 100), "Other key cannot release"); require(!press.end(1, 42, 120, 99), "Stale release cannot end current press"); require(press.end(1, 0, 120, 100), "OEM unknown keycode release matches actual scan code"); require(!press.end(1, 42, 120, 100), "Submit only once"); require(press.begin(1, 42, 120, 200, 0), "Next turn starts immediately"); require(press.end(1, 42, 0, 200), "Release with omitted scan code matches actual key"); require(press.begin(1, 0, 120, 300, 0), "Unknown key down is supported"); require(press.end(1, 42, 120, 300), "Mapped keycode can change on up"); require(!press.begin(1, 42, 120, 400, 2), "Orphan repeat cannot start"); require(press.begin(1, 42, 120, 500, 0), "Start before cancellation"); press.clear(); require(!press.end(1, 42, 120, 500), "Cancelled press cannot submit"); require(press.begin(1, 42, 120, 600, 0), "Restart after cancellation"); require(!press.begin(2, 42, 120, 700, 0), "Other device cannot replace a held key"); require(press.begin(1, 42, 120, 800, 0), "Recover when previous release was lost"); require(!press.end(1, 42, 120, 600), "Delayed old release cannot submit new turn"); require(press.end(1, 42, 120, 800), "Recovered turn releases normally"); System.out.println("PushToTalkPressTest: OK"); } private static void require(boolean condition, String message) { if (!condition) throw new AssertionError(message); } }