Created
May 10, 2021 15:30
-
-
Save abserari/c2aec8eda2332a4fbcd97a362d8f6cc1 to your computer and use it in GitHub Desktop.
Drag to Generate Flutter UI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a basic Flutter widget test. | |
// | |
// To perform an interaction with a widget in your test, use the WidgetTester | |
// utility that Flutter provides. For example, you can send tap and scroll | |
// gestures. You can also use WidgetTester to find child widgets in the widget | |
// tree, read text, and verify that the values of widget properties are correct. | |
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/gestures.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:widget_maker_2_0/main.dart'; | |
void main() { | |
testWidgets('Drag and drop circular progress indicator from widget dialog in empty canvas', (WidgetTester tester) async { | |
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; | |
// Build our app and trigger a frame. | |
var app = MyApp(); | |
await tester.pumpWidget(app, const Duration(milliseconds: 300)); | |
await tester.pumpAndSettle(); | |
// Tap away welcome dialog | |
await tester.tapAt(Offset(0, 0)); | |
await tester.pumpAndSettle(); | |
await tester.tap(find.text("New Widget (or ctrl+space)")); | |
await tester.pump(Duration(seconds: 1)); | |
final gesture = await tester.createGesture( | |
kind: PointerDeviceKind.mouse, | |
); | |
//await gesture.addPointer(); | |
//await gesture.moveTo(Offset.zero,); | |
await tester.tap(find.text(("Text"))); | |
await tester.pump(Duration(seconds: 1)); | |
/*// TODO hovering with the mouse doesnt work right now | |
await tester.dragFrom(tester.getCenter(find.byWidget(app)), tester.getCenter(find.byWidget(app))); | |
await tester.tapAt(tester.getCenter(find.byWidget(app))); | |
await tester.pump(); | |
*/ | |
await gesture.moveTo(Offset.zero); | |
await gesture.moveBy(Offset(250, 250)); | |
await tester.pump(const Duration(milliseconds: 1000)); | |
expect(find.text('Not accepted'), findsOneWidget); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a basic Flutter widget test. | |
// | |
// To perform an interaction with a widget in your test, use the WidgetTester | |
// utility that Flutter provides. For example, you can send tap and scroll | |
// gestures. You can also use WidgetTester to find child widgets in the widget | |
// tree, read text, and verify that the values of widget properties are correct. | |
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:widget_maker_2_0/main.dart'; | |
void main() { | |
setUp(() { | |
// Add this when running the test | |
//debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; | |
}); | |
testWidgets('Pop up project dialog', (WidgetTester tester) async { | |
// Build our app and trigger a frame. | |
await tester.pumpWidget(MyApp(), const Duration(milliseconds: 300)); | |
await tester.pumpAndSettle(); | |
// Find the title | |
expect(find.text("Widget Maker"), findsOneWidget); | |
expect(find.text("Pixel 2"), findsOneWidget); | |
await tester.tap(find.text("Pixel 2")); | |
await tester.pumpAndSettle(); | |
expect(find.text("Widget Maker"), findsNothing); | |
}); | |
testWidgets('Dialog dissapears when tapped on the background', (WidgetTester tester) async { | |
await tester.pumpWidget(MyApp(), const Duration(milliseconds: 300)); | |
await tester.pumpAndSettle(); | |
expect(find.text("Widget Maker"), findsOneWidget); | |
expect(find.text("Pixel 2"), findsOneWidget); | |
await tester.tapAt(Offset(0, 0)); | |
await tester.pumpAndSettle(); | |
expect(find.text("Widget Maker"), findsNothing); | |
}); | |
testWidgets('Dialog screensize selection works', (WidgetTester tester) async { | |
await tester.pumpWidget(MyApp(), const Duration(milliseconds: 300)); | |
await tester.pumpAndSettle(); | |
await tester.tap(find.text("Pixel 2")); | |
await tester.pumpAndSettle(); | |
expect(find.text("Canvas"), findsOneWidget); | |
await tester.tap(find.text("Canvas")); | |
await tester.pump(); | |
// Find the size which the Pixel 2 has in the Canvas Property Editor | |
expect(find.text("411.00"), findsOneWidget); | |
expect(find.text("731.00"), findsOneWidget); | |
// Finds the drop down Pixel 2 | |
expect(find.text("Pixel 2"), findsOneWidget); | |
await tester.pumpAndSettle(Duration(seconds: 5)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment