From 9b968cf85e118bdabd62bb56f2e01ff9a45ac559 Mon Sep 17 00:00:00 2001 From: Tushar Ojha Date: Tue, 3 Nov 2020 02:36:28 +0530 Subject: [PATCH] [animations] adds test for AnimatedPositioned (#576) --- .../test/misc/animated_positioned_test.dart | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 animations/test/misc/animated_positioned_test.dart diff --git a/animations/test/misc/animated_positioned_test.dart b/animations/test/misc/animated_positioned_test.dart new file mode 100644 index 000000000..39d3e6d5a --- /dev/null +++ b/animations/test/misc/animated_positioned_test.dart @@ -0,0 +1,33 @@ +// 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/animated_positioned.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +Widget createAnimatedPositionedDemoScreen() => MaterialApp( + home: AnimatedPositionedDemo(), + ); + +void main() { + group('AnimatedPositioned Tests', () { + testWidgets('Position of Button Changes on Tap', (tester) async { + await tester.pumpWidget(createAnimatedPositionedDemoScreen()); + + var button = find.byType(InkWell); + + // Get initial position of the widget. + var initialPosition = tester.getTopLeft(button); + expect(initialPosition, isNotNull); + + // Tap on the widget. + await tester.tap(button); + await tester.pumpAndSettle(); + + // The new position should not be equal to initial position. + var newPosition = tester.getTopLeft(button); + expect(newPosition, isNot(offsetMoreOrLessEquals(initialPosition))); + }); + }); +}