fix(ui): 骨架屏扫光收窄压淡
This commit is contained in:
1 parent
a5dbae7fff
commit
bd826a9236
2 files changed
+57
-36
No files matched your search
@@ -5,7 +5,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/widgets/drama_grid_skeleton.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('renders one local shimmer mask per skeleton card', (
|
||||
testWidgets('renders one narrow highlight overlay per skeleton card', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(390, 1000);
|
||||
@@ -28,20 +28,34 @@ void main() {
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
expect(find.byType(GridView), findsOneWidget);
|
||||
expect(
|
||||
find.ancestor(
|
||||
of: find.byType(GridView),
|
||||
matching: find.byType(ShaderMask),
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.byType(ShaderMask), findsNothing);
|
||||
for (var index = 0; index < 9; index++) {
|
||||
final card = find.byKey(Key('drama-grid-skeleton-$index'));
|
||||
expect(card, findsOneWidget);
|
||||
expect(
|
||||
find.ancestor(of: card, matching: find.byType(ShaderMask)),
|
||||
find.descendant(of: card, matching: find.byType(IgnorePointer)),
|
||||
findsOneWidget,
|
||||
);
|
||||
final overlay = find.descendant(
|
||||
of: card,
|
||||
matching: find.byWidgetPredicate(
|
||||
(widget) =>
|
||||
widget is DecoratedBox &&
|
||||
widget.decoration is BoxDecoration &&
|
||||
(widget.decoration as BoxDecoration).gradient != null,
|
||||
),
|
||||
);
|
||||
expect(overlay, findsOneWidget);
|
||||
final decoration =
|
||||
tester.widget<DecoratedBox>(overlay).decoration as BoxDecoration;
|
||||
final gradient = decoration.gradient! as LinearGradient;
|
||||
expect(gradient.colors, const [
|
||||
Colors.transparent,
|
||||
Color(0x0DFFFFFF),
|
||||
Colors.transparent,
|
||||
]);
|
||||
expect(gradient.stops, const [0.42, 0.5, 0.58]);
|
||||
expect(gradient.stops![2] - gradient.stops![0], lessThanOrEqualTo(0.25));
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user