|
| 1 | +// This is a basic Flutter widget test. |
| 2 | +// To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter |
| 3 | +// provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to |
| 4 | +// find child widgets in the widget tree, read text, and verify that the values of widget properties |
| 5 | +// are correct. |
| 6 | + |
| 7 | +import 'package:flutter/material.dart'; |
| 8 | +import 'package:flutter_test/flutter_test.dart'; |
| 9 | + |
| 10 | +import 'package:example/main.dart'; |
| 11 | + |
| 12 | +void main() { |
| 13 | + testWidgets('Skip Pressed smoke test', (WidgetTester tester) async { |
| 14 | + // Build our app and trigger a frame. |
| 15 | + await tester.pumpWidget(new App()); |
| 16 | + |
| 17 | + // Verify that our counter starts at 0. |
| 18 | + expect(find.text('SKIP'), findsOneWidget); |
| 19 | + expect(find.text('DONE'), findsNothing); |
| 20 | + |
| 21 | + // Tap the '+' icon and trigger a frame. |
| 22 | + await tester.tap(find.text('SKIP')); |
| 23 | + await tester.pump(); |
| 24 | + |
| 25 | + // Verify that our counter has incremented. |
| 26 | + expect(find.text('SKIP'), findsNothing); |
| 27 | + expect(find.text('DONE'), findsOneWidget); |
| 28 | + }); |
| 29 | + |
| 30 | + // Drag from first page to second and back to first |
| 31 | + testWidgets('drag Reveal smoke test', (WidgetTester tester) async { |
| 32 | + // Build our app and trigger a frame. |
| 33 | + await tester.pumpWidget(new App()); |
| 34 | + |
| 35 | + // should find First page by its title Text |
| 36 | + expect(find.text('Flights'), findsWidgets); |
| 37 | + // second page title Text should not be found |
| 38 | + expect(find.text('Hotels'), findsNothing); |
| 39 | + |
| 40 | + // Drag Screen To Reveal next Page |
| 41 | + await tester.drag(find.byType(App) , Offset(-400.0, 0.0)); |
| 42 | + |
| 43 | + await tester.pumpAndSettle(); |
| 44 | + |
| 45 | + // first page should have been removed by second page |
| 46 | + expect(find.text('Flights'), findsNothing); |
| 47 | + expect(find.text('Hotels'), findsWidgets); |
| 48 | + |
| 49 | + // Drag Screen To Reveal next Prev page |
| 50 | + await tester.drag(find.byType(App) , Offset(400.0, 0.0)); |
| 51 | + |
| 52 | + await tester.pumpAndSettle(); |
| 53 | + // first page should have been removed by second page |
| 54 | + expect(find.text('Flights'), findsWidgets); |
| 55 | + // second page title Text should not be found |
| 56 | + expect(find.text('Hotels'), findsNothing); |
| 57 | + }); |
| 58 | +} |
0 commit comments