Keep par0dy with a3270
Build and Test j3270 / Build JAR & Run Tests (push) Successful in 1m1s

This commit is contained in:
2026-08-24 20:46:45 +00:00
parent d2bdb9bb0a
commit b5a4978b24
9 changed files with 458 additions and 131 deletions
@@ -234,6 +234,12 @@ public class GocaDecoderTest {
assertEquals(0, plane.mapY(257));
// Bottom edge (-258) should map to 515
assertEquals(515, plane.mapY(-258));
// Bidirectional roundtrip mapping must be exact
assertEquals(0, plane.unmapX(plane.mapX(0)));
assertEquals(0, plane.unmapY(plane.mapY(0)));
assertEquals(100, plane.unmapY(plane.mapY(100)));
assertEquals(-200, plane.unmapY(plane.mapY(-200)));
}
@Test
@@ -288,4 +294,45 @@ public class GocaDecoderTest {
assertFalse(dsp.getGraphicsPlane().hasContent(), "Expected graphics plane to be cleared after SF_OBJCNTL P_ERASE");
}
@Test
public void testGcallAndGscsWithLengthBytes() {
GraphicsPlane plane = new GraphicsPlane(400, 300);
GocaDecoder decoder = new GocaDecoder(plane);
// Construct Segment 2: Begin Segment (id=2), Set Color, draw line, End Segment
ByteArrayOutputStream s2 = new ByteArrayOutputStream();
s2.write(GocaConstants.G_BEGSEGM);
s2.write(0x0C);
s2.write(0x00); s2.write(0x00); s2.write(0x00); s2.write(0x02); // id=2
s2.write(0x00); s2.write(0x00); s2.write(0x00); s2.write(0x00);
s2.write(0x00); s2.write(0x00); s2.write(0x00); s2.write(0x00);
s2.write(GocaConstants.G_GSCS); s2.write(0x01); s2.write(0x40); // charSet = 0x40
s2.write(GocaConstants.G_GSCOL); s2.write(0x02); // Color = Red
s2.write(GocaConstants.G_GLINE); s2.write(0x08);
s2.write(0x00); s2.write(0x00); s2.write(0x00); s2.write(0x00);
s2.write(0x00); s2.write(0x32); s2.write(0x00); s2.write(0x32);
s2.write(GocaConstants.G_ENDSEGM); s2.write(0x00);
byte[] s2Bytes = s2.toByteArray();
decoder.decodeStream(s2Bytes, 0, s2Bytes.length);
// Segment 1 calls Segment 2 via GCALL (0x2A len=4 segId=2)
ByteArrayOutputStream s1 = new ByteArrayOutputStream();
s1.write(GocaConstants.G_BEGSEGM);
s1.write(0x0C);
s1.write(0x00); s1.write(0x00); s1.write(0x00); s1.write(0x01); // id=1
s1.write(0x00); s1.write(0x00); s1.write(0x00); s1.write(0x00);
s1.write(0x00); s1.write(0x00); s1.write(0x00); s1.write(0x00);
// GCALL (0x2A len=4 segId=2)
s1.write(GocaConstants.G_GCALL); s1.write(0x04);
s1.write(0x00); s1.write(0x00); s1.write(0x00); s1.write(0x02);
s1.write(GocaConstants.G_ENDSEGM); s1.write(0x00);
byte[] s1Bytes = s1.toByteArray();
decoder.decodeStream(s1Bytes, 0, s1Bytes.length);
assertEquals(0x40, decoder.getCharSet());
assertTrue(plane.hasContent(), "Expected plane to have content after GCALL segment execution");
}
}