Files
upstream-flutter-samples/animations/test/misc/expand_card_test.dart
upstream-mirror 9ed6a80afa
Some checks failed
Main Branch CI / Test Flutter beta on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter stable on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter beta on macos-latest (push) Has been cancelled
Main Branch CI / Test Flutter stable on macos-latest (push) Has been cancelled
snapshot of https://github.com/flutter/samples.git (main, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:43:26 +05:00

48 lines
1.5 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/expand_card.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
Widget createExpandCardScreen() => const MaterialApp(home: ExpandCardDemo());
void main() {
group('ExpandCard Tests', () {
testWidgets('ExpandCard changes size on tap', (tester) async {
await tester.pumpWidget(createExpandCardScreen());
// Get the initial size of ExpandCard.
var initialSize = tester.getSize(find.byType(ExpandCard));
// Tap on the ExpandCard.
await tester.tap(find.byType(ExpandCard));
await tester.pumpAndSettle();
// 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))),
);
});
testWidgets('ExpandCard changes image on tap', (tester) async {
await tester.pumpWidget(createExpandCardScreen());
var initialImage = tester.widget(find.byType(Image).last);
// Tap on ExpandCard.
await tester.tap(find.byType(ExpandCard));
await tester.pumpAndSettle();
// Once tapped, the image should change.
expect(
initialImage,
isNot(equals(tester.widget(find.byType(Image).last))),
);
});
});
}