Test remaining transitions api examples (#148302)
Adds tests for `relative_positioned_transition`, `positioned_transition`, `sliver_fade_transition`, `align_transition`, `animated_builder`, `rotation_transition`, `animated_widget`, `slide_transition`, `listenable_builder`, `scale_transition`, `default_text_style_transition`, `decorated_box_transition`, `size_transition` api examples. Makes double type in the `align_transition` example explicit. A test for `fade_transition` is already in currently open #148178. Part of #130459.
This commit is contained in:
parent
aaa4d336f6
commit
7fb7192304
@ -380,19 +380,6 @@ final Set<String> _knownMissingTests = <String>{
|
||||
'examples/api/test/widgets/media_query/media_query_data.system_gesture_insets.0_test.dart',
|
||||
'examples/api/test/widgets/async/future_builder.0_test.dart',
|
||||
'examples/api/test/widgets/animated_switcher/animated_switcher.0_test.dart',
|
||||
'examples/api/test/widgets/transitions/relative_positioned_transition.0_test.dart',
|
||||
'examples/api/test/widgets/transitions/positioned_transition.0_test.dart',
|
||||
'examples/api/test/widgets/transitions/sliver_fade_transition.0_test.dart',
|
||||
'examples/api/test/widgets/transitions/align_transition.0_test.dart',
|
||||
'examples/api/test/widgets/transitions/animated_builder.0_test.dart',
|
||||
'examples/api/test/widgets/transitions/rotation_transition.0_test.dart',
|
||||
'examples/api/test/widgets/transitions/animated_widget.0_test.dart',
|
||||
'examples/api/test/widgets/transitions/slide_transition.0_test.dart',
|
||||
'examples/api/test/widgets/transitions/listenable_builder.2_test.dart',
|
||||
'examples/api/test/widgets/transitions/scale_transition.0_test.dart',
|
||||
'examples/api/test/widgets/transitions/default_text_style_transition.0_test.dart',
|
||||
'examples/api/test/widgets/transitions/decorated_box_transition.0_test.dart',
|
||||
'examples/api/test/widgets/transitions/size_transition.0_test.dart',
|
||||
'examples/api/test/widgets/animated_list/animated_list.0_test.dart',
|
||||
'examples/api/test/widgets/focus_traversal/focus_traversal_group.0_test.dart',
|
||||
'examples/api/test/widgets/focus_traversal/ordered_traversal_policy.0_test.dart',
|
||||
|
@ -58,7 +58,7 @@ class _AlignTransitionExampleState extends State<AlignTransitionExample> with Ti
|
||||
child: AlignTransition(
|
||||
alignment: _animation,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: FlutterLogo(size: 150.0),
|
||||
),
|
||||
),
|
||||
|
@ -0,0 +1,49 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/align_transition.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Shows flutter logo in transition', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.AlignTransitionExampleApp());
|
||||
expect(find.byType(ColoredBox), findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget padding) => padding is Padding
|
||||
&& padding.padding == const EdgeInsets.all(8.0)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(FlutterLogo), findsOneWidget);
|
||||
expect(find.byType(AlignTransition), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Animates repeatedly every 2 seconds', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.AlignTransitionExampleApp());
|
||||
final Finder paddingFinder = find.byWidgetPredicate(
|
||||
(Widget padding) => padding is Padding
|
||||
&& padding.padding == const EdgeInsets.all(8.0));
|
||||
|
||||
expect(
|
||||
tester.getBottomLeft(paddingFinder),
|
||||
tester.getBottomLeft(find.byType(AlignTransition)),
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(
|
||||
tester.getCenter(paddingFinder),
|
||||
tester.getCenter(find.byType(AlignTransition)),
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(
|
||||
tester.getBottomLeft(paddingFinder),
|
||||
tester.getBottomLeft(find.byType(AlignTransition)),
|
||||
);
|
||||
});
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/animated_builder.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Rotates text and container', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.AnimatedBuilderExampleApp());
|
||||
expect(find.text('Whee!'), findsOneWidget);
|
||||
expect(find.byType(Container), findsOneWidget);
|
||||
expect(tester.widget(find.byType(Container)), isA<Container>()
|
||||
.having((Container container) => container.color, 'color', Colors.green));
|
||||
|
||||
expect(find.byWidgetPredicate((Widget widget) => widget is Transform
|
||||
&& widget.transform == Transform.rotate(angle: 0.0).transform),
|
||||
findsOneWidget);
|
||||
|
||||
await tester.pump(const Duration(seconds: 5));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byWidgetPredicate((Widget widget) => widget is Transform
|
||||
&& widget.transform == Transform.rotate(angle: math.pi).transform),
|
||||
findsOneWidget);
|
||||
});
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/animated_widget.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Rotates green container', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.AnimatedWidgetExampleApp());
|
||||
expect(find.byType(Container), findsOneWidget);
|
||||
expect(tester.widget(find.byType(Container)), isA<Container>()
|
||||
.having((Container container) => container.color, 'color', Colors.green));
|
||||
|
||||
expect(find.byWidgetPredicate((Widget widget) => widget is Transform
|
||||
&& widget.transform == Transform.rotate(angle: 0.0).transform),
|
||||
findsOneWidget);
|
||||
|
||||
await tester.pump(const Duration(seconds: 5));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byWidgetPredicate((Widget widget) => widget is Transform
|
||||
&& widget.transform == Transform.rotate(angle: math.pi).transform),
|
||||
findsOneWidget);
|
||||
});
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/decorated_box_transition.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Shows container in 3 second loop', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.DecoratedBoxTransitionExampleApp());
|
||||
expect(find.byType(FlutterLogo), findsOneWidget);
|
||||
expect(find.byType(Center), findsOneWidget);
|
||||
expect(find.descendant(
|
||||
of: find.byType(Center),
|
||||
matching: find.byType(FlutterLogo)
|
||||
), findsOneWidget);
|
||||
expect(find.ancestor(
|
||||
of: find.byType(FlutterLogo),
|
||||
matching: find.byType(Container)
|
||||
), findsAtLeast(1));
|
||||
expect(find.byType(DecoratedBoxTransition), findsOneWidget);
|
||||
|
||||
expect(
|
||||
tester.widget(find.byType(DecoratedBoxTransition)),
|
||||
isA<DecoratedBoxTransition>()
|
||||
.having(
|
||||
(DecoratedBoxTransition transition) => transition.decoration.value,
|
||||
'decoration',
|
||||
BoxDecoration(
|
||||
color: const Color(0xFFFFFFFF),
|
||||
border: Border.all(style: BorderStyle.none),
|
||||
borderRadius: BorderRadius.circular(60.0),
|
||||
boxShadow: const <BoxShadow>[
|
||||
BoxShadow(
|
||||
color: Color(0x66666666),
|
||||
blurRadius: 10.0,
|
||||
spreadRadius: 3.0,
|
||||
offset: Offset(0, 6.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 3));
|
||||
await tester.pump();
|
||||
|
||||
expect(
|
||||
tester.widget(find.byType(DecoratedBoxTransition)),
|
||||
isA<DecoratedBoxTransition>()
|
||||
.having(
|
||||
(DecoratedBoxTransition transition) => transition.decoration.value,
|
||||
'decoration',
|
||||
BoxDecoration(
|
||||
color: const Color(0xFFFFFFFF),
|
||||
border: Border.all(
|
||||
style: BorderStyle.none,
|
||||
),
|
||||
borderRadius: BorderRadius.zero,
|
||||
// No shadow.
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/default_text_style_transition.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Transforms text style periodically', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.DefaultTextStyleTransitionExampleApp());
|
||||
expect(find.byType(Center), findsOneWidget);
|
||||
expect(find.byType(Text), findsOneWidget);
|
||||
expect(find.text('Flutter'), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(Center),
|
||||
matching: find.byType(Text)
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(DefaultTextStyleTransition), findsOneWidget);
|
||||
expect(tester.widget(find.byType(DefaultTextStyleTransition)),
|
||||
isA<DefaultTextStyleTransition>()
|
||||
.having(
|
||||
(DefaultTextStyleTransition transition) => transition.style.value,
|
||||
'style',
|
||||
const TextStyle(fontSize: 50, color: Colors.blue, fontWeight: FontWeight.w900),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.widget(find.byType(DefaultTextStyleTransition)),
|
||||
isA<DefaultTextStyleTransition>()
|
||||
.having(
|
||||
(DefaultTextStyleTransition transition) => transition.style.value,
|
||||
'style',
|
||||
const TextStyle(fontSize: 50, color: Colors.red, fontWeight: FontWeight.w100),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.widget(find.byType(DefaultTextStyleTransition)),
|
||||
isA<DefaultTextStyleTransition>()
|
||||
.having(
|
||||
(DefaultTextStyleTransition transition) => transition.style.value,
|
||||
'style',
|
||||
const TextStyle(fontSize: 50, color: Colors.blue, fontWeight: FontWeight.w900),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/listenable_builder.2.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Increments counter', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.ListenableBuilderExample());
|
||||
expect(find.text('ListenableBuilder Example'), findsOneWidget);
|
||||
expect(find.text('Current counter value:'), findsOneWidget);
|
||||
expect(find.byIcon(Icons.add), findsOneWidget);
|
||||
expect(find.descendant(
|
||||
of: find.byType(FloatingActionButton),
|
||||
matching: find.byIcon(Icons.add)
|
||||
), findsOneWidget);
|
||||
|
||||
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
expect(find.text('1'), findsNothing);
|
||||
await tester.tap(find.byIcon(Icons.add));
|
||||
await tester.pump();
|
||||
expect(find.text('0'), findsNothing);
|
||||
expect(find.text('1'), findsOneWidget);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
await tester.tap(find.byIcon(Icons.add));
|
||||
}
|
||||
await tester.pump();
|
||||
expect(find.text('5'), findsOneWidget);
|
||||
});
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/positioned_transition.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Shows flutter logo in transition', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.PositionedTransitionExampleApp());
|
||||
expect(find.byType(FlutterLogo), findsOneWidget);
|
||||
expect(find.byType(Padding), findsAtLeast(1));
|
||||
expect(find.byType(PositionedTransition), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Animates repeatedly every 2 seconds', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.PositionedTransitionExampleApp());
|
||||
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0));
|
||||
expect(tester.getTopLeft(find.byType(FlutterLogo)), const Offset(8.0, 8.0));
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
final Size canvasSize = tester.getSize(find.byType(LayoutBuilder));
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0));
|
||||
expect(tester.getBottomRight(find.byType(FlutterLogo)), Offset(canvasSize.width - 8.0, canvasSize.height - 8.0));
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0));
|
||||
expect(tester.getTopLeft(find.byType(FlutterLogo)), const Offset(8.0, 8.0));
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0));
|
||||
expect(tester.getBottomRight(find.byType(FlutterLogo)), Offset(canvasSize.width - 8.0, canvasSize.height - 8.0));
|
||||
});
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/relative_positioned_transition.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Shows flutter logo in transition', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.RelativePositionedTransitionExampleApp());
|
||||
expect(find.byType(FlutterLogo), findsOneWidget);
|
||||
expect(find.byType(Padding), findsAtLeast(1));
|
||||
expect(find.byType(RelativePositionedTransition), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Animates repeatedly every 2 seconds', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.RelativePositionedTransitionExampleApp());
|
||||
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0));
|
||||
expect(tester.getTopLeft(find.byType(FlutterLogo)), const Offset(8.0, 8.0));
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
final Size canvasSize = tester.getSize(find.byType(LayoutBuilder));
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0));
|
||||
expect(tester.getBottomRight(find.byType(FlutterLogo)), Offset(canvasSize.width - 8.0, canvasSize.height - 8.0));
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0));
|
||||
expect(tester.getTopLeft(find.byType(FlutterLogo)), const Offset(8.0, 8.0));
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0));
|
||||
expect(tester.getBottomRight(find.byType(FlutterLogo)), Offset(canvasSize.width - 8.0, canvasSize.height - 8.0));
|
||||
});
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/rotation_transition.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Shows flutter logo in rotation transition', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.RotationTransitionExampleApp());
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) => widget is RotationTransition
|
||||
&& widget.turns is CurvedAnimation
|
||||
&& (widget.turns as CurvedAnimation).curve == Curves.elasticOut,
|
||||
), findsOneWidget);
|
||||
expect(find.byType(FlutterLogo), findsOneWidget);
|
||||
expect(find.byType(Padding), findsAtLeast(1));
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(Center),
|
||||
matching: find.byType(FlutterLogo)
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) => widget is RotationTransition
|
||||
&& widget.turns is CurvedAnimation
|
||||
&& widget.turns.value == 0.0
|
||||
&& widget.turns.status == AnimationStatus.forward
|
||||
), findsOneWidget);
|
||||
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 3));
|
||||
await tester.pump();
|
||||
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) => widget is RotationTransition
|
||||
&& widget.turns is CurvedAnimation
|
||||
&& (widget.turns as CurvedAnimation).parent is AnimationController
|
||||
&& ((widget.turns as CurvedAnimation).parent as AnimationController).value == 0.5
|
||||
&& widget.turns.status == AnimationStatus.reverse
|
||||
), findsOneWidget);
|
||||
});
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/scale_transition.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Shows flutter logo in transition', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.ScaleTransitionExampleApp());
|
||||
expect(find.byType(FlutterLogo), findsOneWidget);
|
||||
expect(find.byType(Center), findsOneWidget);
|
||||
expect(find.descendant(
|
||||
of: find.byType(Center),
|
||||
matching: find.byType(ScaleTransition)
|
||||
), findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) => widget is ScaleTransition
|
||||
&& widget.scale is CurvedAnimation
|
||||
&& (widget.scale as CurvedAnimation).curve == Curves.fastOutSlowIn,
|
||||
), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Scales every 2 seconds', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.ScaleTransitionExampleApp());
|
||||
final Finder transformFinder = find.descendant(
|
||||
of: find.byType(Center),
|
||||
matching: find.byType(Transform)
|
||||
);
|
||||
|
||||
Transform transform = tester.widget(transformFinder);
|
||||
expect(transform.transform[0], 0);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
transform = tester.widget(transformFinder);
|
||||
expect(transform.transform[0], 1.0);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
transform = tester.widget(transformFinder);
|
||||
expect(transform.transform[0], 0);
|
||||
});
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/size_transition.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Shows flutter logo in transition', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.SizeTransitionExampleApp());
|
||||
expect(find.byType(FlutterLogo), findsOneWidget);
|
||||
expect(find.byType(Center), findsOneWidget);
|
||||
expect(find.descendant(
|
||||
of: find.byType(Center),
|
||||
matching: find.byType(FlutterLogo)
|
||||
), findsOneWidget);
|
||||
expect(find.byType(SizeTransition), findsOneWidget);
|
||||
|
||||
expect(
|
||||
tester.widget(find.byType(SizeTransition)),
|
||||
isA<SizeTransition>()
|
||||
.having((SizeTransition transition) => transition.axis, 'axis', Axis.horizontal)
|
||||
.having((SizeTransition transition) => transition.axisAlignment, 'axis alignment', -1)
|
||||
.having((SizeTransition transition) => transition.sizeFactor, 'factor', isA<CurvedAnimation>()
|
||||
.having((CurvedAnimation animation) => animation.curve, 'curve', Curves.fastOutSlowIn)
|
||||
.having((CurvedAnimation animation) => animation.parent, 'paren', isA<AnimationController>()
|
||||
.having((AnimationController controller) => controller.duration, 'duration', const Duration(seconds: 3)))
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/slide_transition.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Shows flutter logo in transition', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.SlideTransitionExampleApp());
|
||||
expect(find.text('SlideTransition Sample'), findsOneWidget);
|
||||
expect(find.byType(Center), findsOneWidget);
|
||||
expect(find.byType(FlutterLogo), findsOneWidget);
|
||||
expect(find.byType(Padding), findsAtLeast(1));
|
||||
expect(find.byType(SlideTransition), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Animates repeatedly every 2 seconds', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.SlideTransitionExampleApp());
|
||||
|
||||
expect(
|
||||
tester.getCenter(find.byType(FlutterLogo)),
|
||||
tester.getCenter(find.byType(Center)),
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
final double width = tester.getSize(find.byType(FlutterLogo)).width + 2 * 8.0;
|
||||
expect(
|
||||
tester.getCenter(find.byType(FlutterLogo)).dx,
|
||||
tester.getCenter(find.byType(Center)).dx + 1.5 * width,
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(
|
||||
tester.getCenter(find.byType(FlutterLogo)),
|
||||
tester.getCenter(find.byType(Center)),
|
||||
);
|
||||
});
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/sliver_fade_transition.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Shows color list in transition', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.SliverFadeTransitionExampleApp());
|
||||
expect(find.text('SliverFadeTransition Sample'), findsOneWidget);
|
||||
expect(find.byType(SliverFadeTransition), findsOneWidget);
|
||||
expect(find.byType(CustomScrollView), findsOneWidget);
|
||||
expect(find.byWidgetPredicate(
|
||||
(Widget widget) => widget is Container &&
|
||||
widget.color == Colors.indigo[200]
|
||||
), findsNWidgets(3));
|
||||
expect(find.byWidgetPredicate(
|
||||
(Widget widget) => widget is Container &&
|
||||
widget.color == Colors.orange[200]
|
||||
), findsNWidgets(2));
|
||||
});
|
||||
|
||||
testWidgets('Animates repeatedly every second', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.SliverFadeTransitionExampleApp());
|
||||
|
||||
expect(
|
||||
tester.renderObject(find.byType(SliverFadeTransition)),
|
||||
isA<RenderSliverAnimatedOpacity>()
|
||||
.having((RenderSliverAnimatedOpacity obj) => obj.opacity.value, 'opacity', 0.0)
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
await tester.pump();
|
||||
|
||||
expect(
|
||||
tester.renderObject(find.byType(SliverFadeTransition)),
|
||||
isA<RenderSliverAnimatedOpacity>()
|
||||
.having((RenderSliverAnimatedOpacity obj) => obj.opacity.value, 'opacity', 1.0)
|
||||
);
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user