mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +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));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,9 +6,8 @@ import 'package:animations/src/misc/animated_positioned.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
Widget createAnimatedPositionedDemoScreen() => const MaterialApp(
|
||||
home: AnimatedPositionedDemo(),
|
||||
);
|
||||
Widget createAnimatedPositionedDemoScreen() =>
|
||||
const MaterialApp(home: AnimatedPositionedDemo());
|
||||
|
||||
void main() {
|
||||
group('AnimatedPositioned Tests', () {
|
||||
|
||||
@@ -6,9 +6,7 @@ import 'package:animations/src/misc/card_swipe.dart';
|
||||
import 'package:flutter/material.dart' hide Card;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
Widget createCardSwipeScreen() => const MaterialApp(
|
||||
home: CardSwipeDemo(),
|
||||
);
|
||||
Widget createCardSwipeScreen() => const MaterialApp(home: CardSwipeDemo());
|
||||
|
||||
void main() {
|
||||
group('Card Swipe Tests', () {
|
||||
|
||||
@@ -6,9 +6,7 @@ import 'package:animations/src/misc/carousel.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
Widget createCarouselDemoScreen() => MaterialApp(
|
||||
home: CarouselDemo(),
|
||||
);
|
||||
Widget createCarouselDemoScreen() => MaterialApp(home: CarouselDemo());
|
||||
|
||||
void main() {
|
||||
group('CarouselDemo tests', () {
|
||||
|
||||
@@ -6,9 +6,7 @@ import 'package:animations/src/misc/expand_card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
Widget createExpandCardScreen() => const MaterialApp(
|
||||
home: ExpandCardDemo(),
|
||||
);
|
||||
Widget createExpandCardScreen() => const MaterialApp(home: ExpandCardDemo());
|
||||
|
||||
void main() {
|
||||
group('ExpandCard Tests', () {
|
||||
@@ -24,10 +22,7 @@ void main() {
|
||||
|
||||
// The size of ExpandCard must change once tapped.
|
||||
// The initialSize should be less than current ExpandCard size.
|
||||
expect(
|
||||
initialSize,
|
||||
lessThan(tester.getSize(find.byType(ExpandCard))),
|
||||
);
|
||||
expect(initialSize, lessThan(tester.getSize(find.byType(ExpandCard))));
|
||||
});
|
||||
|
||||
testWidgets('ExpandCard changes image on tap', (tester) async {
|
||||
|
||||
@@ -6,9 +6,7 @@ import 'package:animations/src/misc/focus_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
Widget createFocusImageScreen() => const MaterialApp(
|
||||
home: FocusImageDemo(),
|
||||
);
|
||||
Widget createFocusImageScreen() => const MaterialApp(home: FocusImageDemo());
|
||||
|
||||
void main() {
|
||||
group('FocusImage Tests', () {
|
||||
@@ -32,10 +30,7 @@ void main() {
|
||||
var finalSize = tester.getSize(find.byWidget(finalInkwell));
|
||||
|
||||
// Final size should be greater than initial size.
|
||||
expect(
|
||||
finalSize,
|
||||
greaterThan(initialSize),
|
||||
);
|
||||
expect(finalSize, greaterThan(initialSize));
|
||||
});
|
||||
|
||||
testWidgets('Final inkwell on tap goes back to the grid', (tester) async {
|
||||
|
||||
@@ -6,9 +6,8 @@ import 'package:animations/src/misc/hero_animation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
Widget createHeroAnimationDemoScreen() => const MaterialApp(
|
||||
home: HeroAnimationDemo(),
|
||||
);
|
||||
Widget createHeroAnimationDemoScreen() =>
|
||||
const MaterialApp(home: HeroAnimationDemo());
|
||||
|
||||
void main() {
|
||||
group('Hero Animation Tests', () {
|
||||
@@ -32,10 +31,7 @@ void main() {
|
||||
var finalSize = tester.getSize(find.byWidget(finalContainer));
|
||||
|
||||
// initialSize should be less than finalSize.
|
||||
expect(
|
||||
initialSize,
|
||||
lessThan(finalSize),
|
||||
);
|
||||
expect(initialSize, lessThan(finalSize));
|
||||
});
|
||||
|
||||
testWidgets('Color of Container changes on Tap', (tester) async {
|
||||
@@ -62,9 +58,7 @@ void main() {
|
||||
// Final color should not be same as initial color.
|
||||
expect(
|
||||
(finalContainer.decoration as BoxDecoration).color,
|
||||
isNot(
|
||||
equals((initialContainer.decoration as BoxDecoration).color),
|
||||
),
|
||||
isNot(equals((initialContainer.decoration as BoxDecoration).color)),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -82,10 +76,7 @@ void main() {
|
||||
final finalScreen = tester.firstWidget(find.byType(HeroPage));
|
||||
|
||||
// initialScreen should not be same as finalScreen.
|
||||
expect(
|
||||
initialScreen,
|
||||
isNot(equals(finalScreen)),
|
||||
);
|
||||
expect(initialScreen, isNot(equals(finalScreen)));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user