mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

(These are changes cherry-picked from in-flight branches since they are more independent and could be helpful even without those changes.) - Change RouteBuilder's signature to take a single argument in which the other fields are placed, so that we can keep iterating on those arguments without having to break compatibility each time. Also, this makes defining route builders much simpler (only one argument to ignore rather than a variable number). - Expose the next performance to RouteBuilders, since sometimes the route itself might not be where it's used. - Allow BuildContext to be used to walk children, just like it can for ancestors - Allow BuildContext to be used to get the Widget of the current BuildContext - Allow StatefulComponentElement to be referenced with a type specialisation so that you don't have to cast when you know what the type you're dealing with actually is.
72 lines
2.2 KiB
Dart
72 lines
2.2 KiB
Dart
import 'package:sky/widgets.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import '../engine/mock_events.dart';
|
|
import 'widget_tester.dart';
|
|
|
|
void main() {
|
|
test('Drag and drop - control test', () {
|
|
testWidgets((WidgetTester tester) {
|
|
TestPointer pointer = new TestPointer(7);
|
|
|
|
List accepted = [];
|
|
|
|
tester.pumpWidget(new Navigator(
|
|
routes: {
|
|
'/': (RouteArguments args) { return new Column([
|
|
new Draggable(
|
|
navigator: args.navigator,
|
|
data: 1,
|
|
child: new Text('Source'),
|
|
feedback: new Text('Dragging')
|
|
),
|
|
new DragTarget(
|
|
builder: (context, data, rejects) {
|
|
return new Container(
|
|
height: 100.0,
|
|
child: new Text('Target')
|
|
);
|
|
},
|
|
onAccept: (data) {
|
|
accepted.add(data);
|
|
}
|
|
),
|
|
]);
|
|
},
|
|
}
|
|
));
|
|
|
|
expect(accepted, isEmpty);
|
|
expect(tester.findText('Source'), isNotNull);
|
|
expect(tester.findText('Dragging'), isNull);
|
|
expect(tester.findText('Target'), isNotNull);
|
|
|
|
Point firstLocation = tester.getCenter(tester.findText('Source'));
|
|
tester.dispatchEvent(pointer.down(firstLocation), firstLocation);
|
|
tester.pump();
|
|
|
|
expect(accepted, isEmpty);
|
|
expect(tester.findText('Source'), isNotNull);
|
|
expect(tester.findText('Dragging'), isNotNull);
|
|
expect(tester.findText('Target'), isNotNull);
|
|
|
|
Point secondLocation = tester.getCenter(tester.findText('Target'));
|
|
tester.dispatchEvent(pointer.move(secondLocation), firstLocation);
|
|
tester.pump();
|
|
|
|
expect(accepted, isEmpty);
|
|
expect(tester.findText('Source'), isNotNull);
|
|
expect(tester.findText('Dragging'), isNotNull);
|
|
expect(tester.findText('Target'), isNotNull);
|
|
|
|
tester.dispatchEvent(pointer.up(), firstLocation);
|
|
tester.pump();
|
|
|
|
expect(accepted, equals([1]));
|
|
expect(tester.findText('Source'), isNotNull);
|
|
expect(tester.findText('Dragging'), isNull);
|
|
expect(tester.findText('Target'), isNotNull);
|
|
});
|
|
});
|
|
}
|