chore(release): 合并 develop 到 main
flutter-ci / test (push) Failing after 19m28s

This commit is contained in:
Vicky committed 2026-11-02 14:54:00 +08:00
commit e8b9a090e0
115 files changed
+1362 -847

No files matched your search

@@ -1,114 +0,0 @@
// Author: fruit.com.cn
// 职责:验证图片占位扫光生命周期及默认兜底接入。
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/core/widgets/image_placeholder_shimmer.dart';
import 'package:fruitshorts/core/widgets/remote_image.dart';
const _frame = Duration(milliseconds: 350);
const double _width = 120;
const double _height = 160;
const _size = Size(_width, _height);
Widget _placeholder({bool reduceMotion = false, bool active = true}) {
return MaterialApp(
home: MediaQuery(
data: MediaQueryData(disableAnimations: reduceMotion),
child: TickerMode(
enabled: active,
child: const Center(
child: SizedBox(
width: _width,
height: _height,
child: ImagePlaceholderShimmer(
child: ColoredBox(color: Colors.black),
),
),
),
),
),
);
}
void main() {
testWidgets('should_paint_clipped_sweep_when_placeholder_is_loading', (
tester,
) async {
await tester.pumpWidget(_placeholder());
final shimmer = find.byType(ImagePlaceholderShimmer);
final paintFinder = find.descendant(
of: shimmer,
matching: find.byType(CustomPaint),
);
final paint = tester.widget<CustomPaint>(paintFinder);
var repaints = 0;
paint.foregroundPainter!.addListener(() => repaints++);
await tester.pump(_frame);
expect(repaints, greaterThan(0));
expect(tester.getSize(shimmer), _size);
expect(
find.descendant(of: shimmer, matching: find.byType(ClipRect)),
findsOneWidget,
);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump(_frame);
expect(tester.binding.hasScheduledFrame, isFalse);
});
testWidgets('should_pause_sweep_when_motion_is_disabled_or_page_is_hidden', (
tester,
) async {
await tester.pumpWidget(_placeholder());
await tester.pump(_frame);
await tester.pumpWidget(_placeholder(reduceMotion: true));
await tester.pump(_frame);
expect(tester.binding.hasScheduledFrame, isFalse);
await tester.pumpWidget(_placeholder(active: false));
await tester.pump(_frame);
expect(tester.binding.hasScheduledFrame, isFalse);
await tester.pumpWidget(_placeholder());
await tester.pump(_frame);
expect(tester.binding.hasScheduledFrame, isTrue);
await tester.pumpWidget(const SizedBox.shrink());
});
testWidgets(
'should_sweep_only_default_loading_fallback_when_image_is_pending',
(tester) async {
await tester.pumpWidget(
const MaterialApp(
home: SizedBox(
width: _width,
height: _height,
child: RemoteImage('/files/pending-cover.jpg'),
),
),
);
final image = tester.widget<Image>(find.byType(Image));
final context = tester.element(find.byType(RemoteImage));
const loaded = SizedBox(key: Key('loaded'));
expect(
image.frameBuilder!(context, loaded, null, false),
isA<ImagePlaceholderShimmer>(),
);
expect(image.frameBuilder!(context, loaded, 0, false), same(loaded));
expect(
image.errorBuilder!(context, Exception('failed'), null),
isNot(isA<ImagePlaceholderShimmer>()),
);
await tester.pumpWidget(const MaterialApp(home: RemoteImage('')));
expect(find.byType(ImagePlaceholderShimmer), findsNothing);
await tester.pumpWidget(
const MaterialApp(
home: RemoteImage(
'/files/custom-cover.jpg',
fallbackWidget: SizedBox(key: Key('custom')),
),
),
);
expect(find.byKey(const Key('custom')), findsOneWidget);
expect(find.byType(ImagePlaceholderShimmer), findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
},
);
}