Add missing menus back

This commit is contained in:
2026-08-30 23:46:29 +00:00
parent a3c4b95379
commit 27976dd31f
6 changed files with 62 additions and 56 deletions
@@ -81,21 +81,19 @@ public class QueryReplyBuilderTest {
byte[] replies = qrBuilder.buildCompleteQueryReplies(80, 43, 80 * 43);
assertNotNull(replies);
// Vector Graphics (0xB0) must be present and Charsets must have LoadPS (0x0A)
// Vector Graphics (0xB0) must be present and Charsets must be present (0x85)
boolean hasB0 = false;
boolean hasCharsetsWithLoadPs = false;
boolean hasCharsets = false;
for (int i = 0; i < replies.length - 3; i++) {
if ((replies[i] & 0xFF) == 0x81 && (replies[i + 1] & 0xFF) == QR_SEGMENT) {
hasB0 = true;
}
if ((replies[i] & 0xFF) == 0x81 && (completeReplyIsCharsets(replies, i))) {
if (i + 6 < replies.length && (replies[i + 6] & 0xFF) == 0x0A) {
hasCharsetsWithLoadPs = true;
}
hasCharsets = true;
}
}
assertTrue(hasB0);
assertTrue(hasCharsetsWithLoadPs);
assertTrue(hasCharsets);
}
private boolean completeReplyIsCharsets(byte[] replies, int i) {
@@ -283,24 +281,24 @@ public class QueryReplyBuilderTest {
assertEquals(0x81, replies[3] & 0xFF);
assertEquals(QR_USABLE_AREA, replies[4] & 0xFF);
// Flags: 12/14 bit addressing (0x01), 0x00
assertEquals(0x01, replies[5] & 0xFF);
// Flags: 12/14 bit addressing | Graphics (0x03), 0x00
assertEquals(0x03, replies[5] & 0xFF);
assertEquals(0x00, replies[6] & 0xFF);
// Usable width and height: 80, 43
assertEquals(80, ((replies[7] & 0xFF) << 8) | (replies[8] & 0xFF));
assertEquals(43, ((replies[9] & 0xFF) << 8) | (replies[10] & 0xFF));
// Units: 0x00 (Inches, matching IBM Host On-Demand QR_USEAREA_STRING)
// Units: 0x00 (Inches, matching IBM Host On-Demand DS3270.java)
assertEquals(0x00, replies[11] & 0xFF);
// Xr (4 bytes): 0x00020089 (matching HOD)
// Xr (4 bytes): 0x00010060 (96 dpi matching HOD)
int xr = ((replies[12] & 0xFF) << 24) | ((replies[13] & 0xFF) << 16) | ((replies[14] & 0xFF) << 8) | (replies[15] & 0xFF);
assertEquals(0x00020089, xr);
assertEquals(0x00010060, xr);
// Yr (4 bytes): 0x00020085 (matching HOD)
// Yr (4 bytes): 0x00010060 (96 dpi matching HOD)
int yr = ((replies[16] & 0xFF) << 24) | ((replies[17] & 0xFF) << 16) | ((replies[18] & 0xFF) << 8) | (replies[19] & 0xFF);
assertEquals(0x00020085, yr);
assertEquals(0x00010060, yr);
// AW and AH: 9 and 16
assertEquals(9, replies[20] & 0xFF);
@@ -309,4 +307,17 @@ public class QueryReplyBuilderTest {
// Buffer size: 80 * 43 = 3440
assertEquals(80 * 43, ((replies[22] & 0xFF) << 8) | (replies[23] & 0xFF));
}
@Test
public void testGrSymbolSetMatchesHOD() {
qrBuilder.setGraphicsMode(GraphicsMode.VECTOR_GRAPHICS);
byte[] requested = new byte[] { (byte) QR_GRSYMBOLSET };
byte[] replies = qrBuilder.buildQueryReplies(requested, 80, 43, 80 * 43);
assertNotNull(replies);
assertEquals((byte) AID_SF, replies[0]);
assertEquals(33, ((replies[1] & 0xFF) << 8) | (replies[2] & 0xFF));
assertEquals(0x81, replies[3] & 0xFF);
assertEquals(QR_GRSYMBOLSET, replies[4] & 0xFF);
}
}