Console.java

package net.morimekta.testing.console;

import net.morimekta.io.tty.TTY;
import net.morimekta.io.tty.TTYSize;

import java.io.OutputStream;

/**
 * Base interface for accessing console during testing. Implementation in framework specific
 * modules.
 */
public interface Console {
    /**
     * @return The testing TTY. This is essentially a fake TTY that reflects back the state of the testing console.
     */
    TTY tty();

    /**
     * @return Get the normal output.
     */
    String output();

    /**
     * @return Get the error output.
     */
    String error();

    /**
     * Set input to return the given bytes.
     *
     * @param in The bytes for input.
     */
    void setInput(byte[] in);

    /**
     * Set input with dynamic content.
     *
     * @param in The input values.
     */
    void setInput(Object... in);

    /**
     * Create an output stream that will feed the input stream. Handy
     * for testing interactive input.
     *
     * @return The controlling output stream.
     */
    OutputStream createInputSource();

    /**
     * Reset all the streams for the console.
     */
    void reset();

    /** The default number of rows in a fake TTY. */
    int     DEFAULT_ROWS          = 25;
    /** The default number of cols in a fake TTY. */
    int     DEFAULT_COLS          = 144;
    /** The default terminal size of a fake TTY. */
    TTYSize DEFAULT_TERMINAL_SIZE = new TTYSize(DEFAULT_ROWS, DEFAULT_COLS);
}