This commit is contained in:
@@ -54,6 +54,52 @@ public class QueryReplyBuilderTest {
|
||||
assertTrue(hasB4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildAllQueryRepliesWithBoth() {
|
||||
qrBuilder.setGraphicsMode(GraphicsMode.BOTH);
|
||||
byte[] replies = qrBuilder.buildAllQueryReplies(80, 43, 80 * 43);
|
||||
assertNotNull(replies);
|
||||
|
||||
// Vector Graphics (0xB0) must be present and Charsets must have LoadPS (0x0A)
|
||||
boolean hasB0 = false;
|
||||
boolean hasCharsetsWithLoadPs = false;
|
||||
for (int i = 0; i < replies.length - 3; i++) {
|
||||
if ((replies[i] & 0xFF) == 0x81 && (replies[i + 1] & 0xFF) == QR_GRAPHICS) {
|
||||
hasB0 = true;
|
||||
}
|
||||
if ((replies[i] & 0xFF) == 0x81 && (replies[i + 1] & 0xFF) == QR_CHARSETS) {
|
||||
if (i + 6 < replies.length && (replies[i + 6] & 0xFF) == 0x0A) {
|
||||
hasCharsetsWithLoadPs = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
assertTrue(hasB0);
|
||||
assertTrue(hasCharsetsWithLoadPs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildAllQueryRepliesWithProgrammedSymbols() {
|
||||
qrBuilder.setGraphicsMode(GraphicsMode.PROGRAMMED_SYMBOLS);
|
||||
byte[] replies = qrBuilder.buildAllQueryReplies(80, 43, 80 * 43);
|
||||
assertNotNull(replies);
|
||||
|
||||
// Charsets with LoadPS (0x0A) must be present, and QR_GRAPHICS must NOT be present
|
||||
boolean hasB0 = false;
|
||||
boolean hasCharsetsWithLoadPs = false;
|
||||
for (int i = 0; i < replies.length - 3; i++) {
|
||||
if ((replies[i] & 0xFF) == 0x81 && (replies[i + 1] & 0xFF) == QR_GRAPHICS) {
|
||||
hasB0 = true;
|
||||
}
|
||||
if ((replies[i] & 0xFF) == 0x81 && (replies[i + 1] & 0xFF) == QR_CHARSETS) {
|
||||
if (i + 6 < replies.length && (replies[i + 6] & 0xFF) == 0x0A) {
|
||||
hasCharsetsWithLoadPs = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
assertFalse(hasB0);
|
||||
assertTrue(hasCharsetsWithLoadPs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildFilteredQueryRepliesWithSupportedCodes() {
|
||||
byte[] requested = new byte[] { (byte) QR_DDM, (byte) QR_USABLE_AREA };
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package org.lib3270j.graphics;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class ProgramSymbolManagerTest {
|
||||
@@ -62,12 +59,13 @@ public class ProgramSymbolManagerTest {
|
||||
assertNotNull(pixels);
|
||||
assertEquals(1, pixels[0]); // Row 0 Col 0 is 1
|
||||
|
||||
// Test rendering into BufferedImage
|
||||
BufferedImage canvas = new BufferedImage(80, 24, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2 = canvas.createGraphics();
|
||||
boolean drawn = manager.drawSymbol(g2, 0x40, 0x41, 0, 0, 10, 20, Color.GREEN, Color.BLACK);
|
||||
g2.dispose();
|
||||
assertTrue(drawn);
|
||||
// Test rendering into 32-bit ARGB pixels
|
||||
int fg = 0xFF00FF00; // Green
|
||||
int bg = 0xFF000000; // Black
|
||||
int[] rgb = slot.getRgbPixels(fg, bg);
|
||||
assertNotNull(rgb);
|
||||
assertEquals(9 * 16, rgb.length);
|
||||
assertEquals(fg, rgb[0]); // Row 0 Col 0 pixel should be foreground Green
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,16 +102,18 @@ public class ProgramSymbolManagerTest {
|
||||
byte[] pixels = slot.getPixelData();
|
||||
assertEquals(7, pixels[0] & 0xFF);
|
||||
|
||||
// Render image
|
||||
BufferedImage img = slot.getImage(Color.WHITE, Color.BLACK);
|
||||
assertNotNull(img);
|
||||
// Render ARGB pixels
|
||||
int[] rgb = slot.getRgbPixels(0xFFFFFFFF, 0xFF000000);
|
||||
assertNotNull(rgb);
|
||||
|
||||
// Pixel (0,0) should be white composite (Red=255, Green=255, Blue=255)
|
||||
int rgb = img.getRGB(0, 0);
|
||||
Color pixelColor = new Color(rgb, true);
|
||||
assertEquals(255, pixelColor.getRed());
|
||||
assertEquals(255, pixelColor.getGreen());
|
||||
assertEquals(255, pixelColor.getBlue());
|
||||
// Pixel (0,0) should be white composite (0xFFFFFFFF)
|
||||
int pixelArgb = rgb[0];
|
||||
int r = (pixelArgb >> 16) & 0xFF;
|
||||
int g = (pixelArgb >> 8) & 0xFF;
|
||||
int b = pixelArgb & 0xFF;
|
||||
assertEquals(255, r);
|
||||
assertEquals(255, g);
|
||||
assertEquals(255, b);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user