1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00
Files
samples/animations/test/misc/card_swipe_test.dart
Eric Windmill 2999d738b8 Dart 3.9 / Flutter 3.35 [first LLM release] (#2714)
I got carried away with Gemini and basically rewrote CI and the release
process for the new LLM reality. This work was largely completed by
Gemini.

- Bump all SDK versions to the current beta (3.9.0-0)
- Run `flutter channel beta`
- Wrote `ci_script.dart` to replace the bash scripts
- Converted repository to pub workspace #2499 
- Added llm.md and release.md
- Added redirect for deprecated Samples Index

## Pre-launch Checklist

- [x] I read the [Flutter Style Guide] _recently_, and have followed its
advice.
- [x] I signed the [CLA].
- [x] I read the [Contributors Guide].
- [x] I have added sample code updates to the [changelog].
- [x] I updated/added relevant documentation (doc comments with `///`).
2025-08-14 12:26:24 -07:00

72 lines
2.2 KiB
Dart

// Copyright 2020 The Flutter team. 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: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());
void main() {
group('Card Swipe Tests', () {
testWidgets('One card swiped out', (tester) async {
await tester.pumpWidget(createCardSwipeScreen());
// Get the total number of cards available.
var totalCards = tester.widgetList(find.byType(Card)).length;
// Ensure card is visible.
await tester.ensureVisible(find.byType(Card).last);
// Swipe out one card.
await tester.drag(find.byType(Card).last, const Offset(100.0, 0.0));
await tester.pumpAndSettle();
// Check if removed properly.
expect(
tester.widgetList(find.byType(Card)).length,
lessThan(totalCards),
);
});
testWidgets('All cards swiped out', (tester) async {
await tester.pumpWidget(createCardSwipeScreen());
// Get the total number of cards availabe.
var totalCards = tester.widgetList(find.byType(Card)).length;
// Swipe out all cards.
for (var i = 0; i < totalCards; i++) {
// Swipe out one by one.
await tester.drag(
find.byType(Card).last,
const Offset(100.0, 0.0),
);
await tester.pumpAndSettle();
}
// Check if any card is remaining.
expect(find.byType(Card), findsNothing);
});
testWidgets('Stack refilled with cards', (tester) async {
await tester.pumpWidget(createCardSwipeScreen());
// Get the total number of cards availabe.
var totalCards = tester.widgetList(find.byType(Card)).length;
// Swipe out one card.
await tester.drag(find.byType(Card).last, const Offset(100.0, 0.0));
await tester.pumpAndSettle();
// Tap the Refill button.
await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle();
// Check if the entire stack is refilled.
expect(find.byType(Card), findsNWidgets(totalCards));
});
});
}