This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package org.lib3270j.input;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.lib3270j.TerminalModel;
|
||||
import org.lib3270j.charset.EbcdicTranslator;
|
||||
import org.lib3270j.screen.ScreenBuffer;
|
||||
import org.lib3270j.telnet.TelnetFSM;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.lib3270j.protocol.DS3270Constants.*;
|
||||
|
||||
public class InputProcessorTest {
|
||||
|
||||
private final EbcdicTranslator translator = new EbcdicTranslator();
|
||||
private final ScreenBuffer screen = new ScreenBuffer(TerminalModel.IBM_3279_4, translator);
|
||||
|
||||
@Test
|
||||
public void testKybdPrimeOnUnformattedScreen() {
|
||||
InputProcessor input = new InputProcessor(screen, translator, null);
|
||||
int cap = input.kybdPrime();
|
||||
assertEquals(screen.getRows() * screen.getCols(), cap);
|
||||
assertEquals(0, screen.getCursorAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKybdPrimeOnFormattedScreen() {
|
||||
InputProcessor input = new InputProcessor(screen, translator, null);
|
||||
screen.erase(false);
|
||||
screen.setCellFA(0, (byte) FA_PRINTABLE); // Unprotected field at 0 (length = 19)
|
||||
screen.setCellFA(20, (byte) (FA_PRINTABLE | FA_PROTECT)); // Protected field at 20
|
||||
|
||||
int cap = input.kybdPrime();
|
||||
assertEquals(19, cap);
|
||||
assertEquals(1, screen.getCursorAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEraseInput() {
|
||||
InputProcessor input = new InputProcessor(screen, translator, null);
|
||||
screen.erase(false);
|
||||
screen.setCellFA(0, (byte) FA_PRINTABLE);
|
||||
screen.setCursorAddress(1);
|
||||
input.typeCharacter('A');
|
||||
input.typeCharacter('B');
|
||||
|
||||
assertEquals('A', screen.getCell(1).ucs4);
|
||||
assertEquals('B', screen.getCell(2).ucs4);
|
||||
|
||||
input.eraseInput();
|
||||
|
||||
assertEquals(0, screen.getCell(1).ec);
|
||||
assertEquals(0, screen.getCell(2).ec);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user