Files
desktop-plugin/test/pavo_ffi_layout_test.dart
dzc 1deb3125be fix: Pavo 布局自检期望值错误(80→88)——上一轮审查时手数错了指针数
用户 Windows 实测触发 HitiCardPrintParameter 布局 assert。mac 实测 sizeOf
坐实:HitiCardPrintParameter=88(4×uint32 + 8×uint8 + 8×pointer = 24+64,
8 个指针=front BGR/K/O + back BGR/K/O + Reserve×2),其余三个(32/16/48)
正确——结构体布局本身与 C# 实机版一致,错的只是 assert 里手写的期望值 80。

顺带:此错误当时被 pavo_isolate_test 的 catch 转 offline 文案掩盖(断言只查
unsendable),新增 test/pavo_ffi_layout_test 直接 expect 四个 sizeOf,
布局回归在 mac 上即红,不必等 Windows 实机。15 测试全过。
2026-09-21 16:19:32 +08:00

17 lines
622 B
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'dart:ffi';
import 'package:desktop_plugin/print/pavo/pavo_ffi.dart';
import 'package:flutter_test/flutter_test.dart';
/// Pavo ffi 结构体布局守护:与 C# 实机验证版的 sizeof 逐一核对。
/// 布局错误在 mac 上跑本测试即红,不必等 Windows 实机。
/// (HitiCardPrintParameter = 4×uint32 + 8×uint8 + 8×pointer = 24+64 = 88)
void main() {
test('Pavo ffi 结构体布局与 C ABI 一致', () {
expect(sizeOf<HitiCardPrintParameter>(), 88);
expect(sizeOf<GdiBitmap>(), 32);
expect(sizeOf<HitiHeatingEnergy>(), 16);
expect(sizeOf<HitiSettings>(), 48);
});
}