mirror of
https://github.com/flutter/samples.git
synced 2026-06-03 21:09:46 +00:00
Flutter 3.29 beta (#2571)
This commit is contained in:
@@ -6,9 +6,8 @@ import 'package:animations/src/misc/animated_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
Widget createAnimatedListDemoScreen() => const MaterialApp(
|
||||
home: AnimatedListDemo(),
|
||||
);
|
||||
Widget createAnimatedListDemoScreen() =>
|
||||
const MaterialApp(home: AnimatedListDemo());
|
||||
|
||||
void main() {
|
||||
group('Animated List Tests', () {
|
||||
@@ -19,14 +18,12 @@ void main() {
|
||||
var initialLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
|
||||
// Initial length of list should be equal to 5.
|
||||
expect(
|
||||
initialLength,
|
||||
equals(5),
|
||||
);
|
||||
expect(initialLength, equals(5));
|
||||
});
|
||||
|
||||
testWidgets('Length of list increases on Add Icon Button tap',
|
||||
(tester) async {
|
||||
testWidgets('Length of list increases on Add Icon Button tap', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(createAnimatedListDemoScreen());
|
||||
|
||||
// Get the initial length of list.
|
||||
@@ -40,77 +37,68 @@ void main() {
|
||||
var newLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
|
||||
// New length should be greater than initial length by one.
|
||||
expect(
|
||||
newLength,
|
||||
equals(initialLength + 1),
|
||||
);
|
||||
expect(newLength, equals(initialLength + 1));
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Length of list decreases on Delete Icon Button tap at middle index',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(createAnimatedListDemoScreen());
|
||||
'Length of list decreases on Delete Icon Button tap at middle index',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(createAnimatedListDemoScreen());
|
||||
|
||||
// Get the initial length of list.
|
||||
var initialLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
// Get the initial length of list.
|
||||
var initialLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
|
||||
// Tap on the Delete Icon Button at middle index.
|
||||
await tester.tap(find.byIcon(Icons.delete).at(initialLength ~/ 2));
|
||||
await tester.pumpAndSettle();
|
||||
// Tap on the Delete Icon Button at middle index.
|
||||
await tester.tap(find.byIcon(Icons.delete).at(initialLength ~/ 2));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Get the new length of list.
|
||||
var newLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
// Get the new length of list.
|
||||
var newLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
|
||||
// New length should be less than initial length by one.
|
||||
expect(
|
||||
newLength,
|
||||
equals(initialLength - 1),
|
||||
);
|
||||
});
|
||||
// New length should be less than initial length by one.
|
||||
expect(newLength, equals(initialLength - 1));
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Length of list decreases on Delete Icon Button tap at start index',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(createAnimatedListDemoScreen());
|
||||
'Length of list decreases on Delete Icon Button tap at start index',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(createAnimatedListDemoScreen());
|
||||
|
||||
// Get the initial length of list.
|
||||
var initialLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
// Get the initial length of list.
|
||||
var initialLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
|
||||
// Tap on the Delete Icon Button at start index.
|
||||
await tester.tap(find.byIcon(Icons.delete).at(0));
|
||||
await tester.pumpAndSettle();
|
||||
// Tap on the Delete Icon Button at start index.
|
||||
await tester.tap(find.byIcon(Icons.delete).at(0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Get the new length of list.
|
||||
var newLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
// Get the new length of list.
|
||||
var newLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
|
||||
// New length should be less than initial length by one.
|
||||
expect(
|
||||
newLength,
|
||||
equals(initialLength - 1),
|
||||
);
|
||||
});
|
||||
// New length should be less than initial length by one.
|
||||
expect(newLength, equals(initialLength - 1));
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Length of list decreases on Delete Icon Button tap at end index',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(createAnimatedListDemoScreen());
|
||||
'Length of list decreases on Delete Icon Button tap at end index',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(createAnimatedListDemoScreen());
|
||||
|
||||
// Get the initial length of list.
|
||||
var initialLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
// Get the initial length of list.
|
||||
var initialLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
|
||||
// Tap on the Delete Icon Button at end index.
|
||||
await tester.tap(find.byIcon(Icons.delete).at(initialLength - 1));
|
||||
await tester.pumpAndSettle();
|
||||
// Tap on the Delete Icon Button at end index.
|
||||
await tester.tap(find.byIcon(Icons.delete).at(initialLength - 1));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Get the new length of list.
|
||||
var newLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
// Get the new length of list.
|
||||
var newLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
|
||||
// New Length should be less than initial length by one.
|
||||
expect(
|
||||
newLength,
|
||||
equals(initialLength - 1),
|
||||
);
|
||||
});
|
||||
// New Length should be less than initial length by one.
|
||||
expect(newLength, equals(initialLength - 1));
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('All ListTiles deleted', (tester) async {
|
||||
await tester.pumpWidget(createAnimatedListDemoScreen());
|
||||
@@ -129,10 +117,7 @@ void main() {
|
||||
var finalLength = tester.widgetList(find.byType(ListTile)).length;
|
||||
|
||||
// New length should be zero.
|
||||
expect(
|
||||
finalLength,
|
||||
equals(0),
|
||||
);
|
||||
expect(finalLength, equals(0));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user