mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add test for animated list example (#156452)
Contributes to https://github.com/flutter/flutter/issues/130459 It adds a test for - `examples/api/lib/widgets/animated_list/animated_list.0.dart`
This commit is contained in:
parent
c78c166e3e
commit
96c761c1a6
@ -334,7 +334,6 @@ final Set<String> _knownMissingTests = <String>{
|
||||
'examples/api/test/widgets/nested_scroll_view/nested_scroll_view_state.0_test.dart',
|
||||
'examples/api/test/widgets/scroll_position/scroll_metrics_notification.0_test.dart',
|
||||
'examples/api/test/widgets/media_query/media_query_data.system_gesture_insets.0_test.dart',
|
||||
'examples/api/test/widgets/animated_list/animated_list.0_test.dart',
|
||||
'examples/api/test/widgets/image/image.frame_builder.0_test.dart',
|
||||
'examples/api/test/widgets/image/image.loading_builder.0_test.dart',
|
||||
'examples/api/test/widgets/page_storage/page_storage.0_test.dart',
|
||||
|
@ -0,0 +1,45 @@
|
||||
// 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/animated_list/animated_list.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'Items can be selected, added, and removed from AnimatedList',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.AnimatedListSample());
|
||||
|
||||
expect(find.text('Item 0'), findsOne);
|
||||
expect(find.text('Item 1'), findsOne);
|
||||
expect(find.text('Item 2'), findsOne);
|
||||
|
||||
// Add an item at the end of the list.
|
||||
await tester.tap(find.byIcon(Icons.add_circle));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Item 3'), findsOne);
|
||||
|
||||
// Select Item 1.
|
||||
await tester.tap(find.text('Item 1'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Add item at the top of the list.
|
||||
await tester.tap(find.byIcon(Icons.add_circle));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Item 4'), findsOne);
|
||||
|
||||
// Remove selected item.
|
||||
await tester.tap(find.byIcon(Icons.remove_circle));
|
||||
|
||||
// Item animation is not completed.
|
||||
await tester.pump();
|
||||
expect(find.text('Item 1'), findsOne);
|
||||
|
||||
// When the animation completes, Item 1 disappears.
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Item 1'), findsNothing);
|
||||
},
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user