Trim redundant cursor density and alpha test combinations

This commit is contained in:
fufesou
2026-09-14 10:40:32 +08:00
parent f6c89aa06c
commit 2d5d11282b
2 changed files with 13 additions and 43 deletions

View File

@@ -18,35 +18,18 @@ void main() {
_rasterBoundsTests();
final registrations = <Map<dynamic, dynamic>>[];
captureNativeCursors(registrations);
_legacySizingTests(registrations);
for (final style in [kRemoteViewStyleAdaptive, kRemoteViewStyleCustom]) {
for (final density in ['0', '1', '2', '1e-300', '0.001']) {
for (final (density, width, dpr) in [
(null, 4, 1.0),
('0', 4, 2.0),
(null, 32, 2.0),
('0', 32, 1.0),
]) {
testWidgets(
'density boundary $style density=$density',
(tester) => tester.runAsync(
() => checkDensity(tester, (style, density), registrations)));
}
}
}
void _legacySizingTests(List<Map<dynamic, dynamic>> registrations) {
for (final style in [kRemoteViewStyleAdaptive, kRemoteViewStyleCustom]) {
for (final density in [null, '0']) {
for (final (width, height, dpr) in [
(4, 32, 1.0),
(4, 32, 2.0),
(9, 18, 1.0),
(9, 18, 2.0),
(32, 32, 1.0),
(32, 32, 2.0),
]) {
testWidgets(
'legacy $style density=$density ${width}x$height DPR=$dpr',
(tester) => tester.runAsync(() => checkDensity(
tester, (style, density), registrations,
sourceSize: Size(width.toDouble(), height.toDouble()),
dpr: dpr)));
}
'legacy $style density=$density ${width}x32 DPR=$dpr',
(tester) => tester.runAsync(() => checkDensity(
tester, (style, density), registrations,
sourceSize: Size(width.toDouble(), 32), dpr: dpr)));
}
}
}
@@ -54,7 +37,6 @@ void _legacySizingTests(List<Map<dynamic, dynamic>> registrations) {
void _rasterBoundsTests() {
for (final (width, height, scale, legacy, rasterScale) in [
(32, 32, 1e300, false, 1.0),
(32, 32, 129.0, false, 1.0),
(32, 32, 100.0, false, 2.0),
(512, 1, 0.1, true, 1.0),
]) {
@@ -106,13 +88,7 @@ Future<void> checkDensity(WidgetTester tester, (String, String?) input,
canvas.dispose();
});
await cursor.updateCursorData(_cursorEvent(id, density, size: sourceSize));
final rejected = density == '1e-300' || density == '0.001';
if (rejected) {
expect(cursor.cache, isNull,
reason: 'Reject density before publishing a cursor');
await cursor.updateCursorData(_cursorEvent(id, '2'));
}
expect(cursor.cache!.pixelRatio, rejected ? 2 : double.parse(density ?? '0'));
expect(cursor.cache!.pixelRatio, 0);
await _paintCursor(tester, ffi, cursor);
expect(tester.takeException(), isNull);
for (final key in cursor.cachedKeys) {
@@ -120,10 +96,8 @@ Future<void> checkDensity(WidgetTester tester, (String, String?) input,
}
expect(registrations, hasLength(1));
await tester.pumpWidget(const SizedBox.shrink());
if (density == null || density == '0') {
expect(cursor.cache!.scale, 1.0);
_expectLegacyRaster(registrations.single, sourceSize, dpr);
}
expect(cursor.cache!.scale, 1.0);
_expectLegacyRaster(registrations.single, sourceSize, dpr);
}
Future<void> _paintCursor(

View File

@@ -38,10 +38,6 @@ void main() {
tearDown(view.resetDevicePixelRatio);
for (final testCase in <(String, String?, List<int>)>[
(kPeerPlatformMacOS, null, [64, 32, 16, 128]),
(kPeerPlatformMacOS, '0', [64, 32, 16, 128]),
(kPeerPlatformMacOS, '1', [64, 32, 16, 128]),
(kPeerPlatformMacOS, '2', [64, 32, 16, 128]),
(kPeerPlatformWindows, null, [64, 32, 16, 128]),
(kPeerPlatformWindows, '0', [64, 32, 16, 128]),
(kPeerPlatformLinux, '0', [32, 16, 8, 128]),
]) {