62 lines
1.9 KiB
Dart
62 lines
1.9 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:fruitshorts/core/widgets/drama_grid_skeleton.dart';
|
|
|
|
void main() {
|
|
testWidgets('renders one narrow highlight overlay per skeleton card', (
|
|
tester,
|
|
) async {
|
|
tester.view.physicalSize = const Size(390, 1000);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
|
|
await tester.pumpWidget(
|
|
const MaterialApp(
|
|
home: Scaffold(
|
|
body: DramaGridSkeleton(
|
|
columns: 3,
|
|
horizontalPadding: 14,
|
|
crossAxisSpacing: 8,
|
|
mainAxisSpacing: 12,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pump(const Duration(milliseconds: 100));
|
|
|
|
expect(find.byType(GridView), findsOneWidget);
|
|
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.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));
|
|
}
|
|
});
|
|
}
|