51 lines
1.5 KiB
Dart
51 lines
1.5 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:fruitshorts/core/navigation/fade_page_route.dart';
|
|
|
|
void main() {
|
|
testWidgets('should_fade_in_without_slide_and_use_short_transitions', (
|
|
tester,
|
|
) async {
|
|
final navigatorKey = GlobalKey<NavigatorState>();
|
|
var routePushed = false;
|
|
final route = FadePageRoute<void>(
|
|
builder: (_) =>
|
|
const Scaffold(key: Key('fade-route-page'), body: SizedBox.expand()),
|
|
);
|
|
|
|
expect(route.transitionDuration, const Duration(milliseconds: 220));
|
|
expect(route.reverseTransitionDuration, const Duration(milliseconds: 180));
|
|
expect(route.opaque, isTrue);
|
|
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
navigatorKey: navigatorKey,
|
|
home: Builder(
|
|
builder: (context) => Scaffold(
|
|
body: TextButton(
|
|
onPressed: () {
|
|
navigatorKey.currentState!.push(route);
|
|
routePushed = true;
|
|
},
|
|
child: const Text('Open'),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
await tester.tap(find.text('Open'));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 100));
|
|
|
|
expect(routePushed, isTrue);
|
|
expect(find.byKey(const Key('fade-route-page')), findsOneWidget);
|
|
final fade = tester.widget<FadeTransition>(
|
|
find.byType(FadeTransition).last,
|
|
);
|
|
expect(fade.opacity.value, inExclusiveRange(0, 1));
|
|
});
|
|
}
|