Dispatch a Flutter.Navigation event each time navigation occurs. (#23126)

Dispatch a Flutter.Navigation event each time navigation occurs.
This commit is contained in:
Jacob Richman
2018-10-17 07:40:08 -07:00
committed by GitHub
parent f86bdf1aa2
commit e4c2c978a6
3 changed files with 65 additions and 9 deletions

View File

@@ -59,6 +59,8 @@ void main() {
final VMIsolateRef isolate = vm.isolates.first;
final Stream<VMExtensionEvent> frameEvents = isolate.onExtensionEvent.where(
(VMExtensionEvent e) => e.kind == 'Flutter.Frame');
final Stream<VMExtensionEvent> navigationEvents = isolate.onExtensionEvent.where(
(VMExtensionEvent e) => e.kind == 'Flutter.Navigation');
print('reassembling app...');
final Future<VMExtensionEvent> frameFuture = frameEvents.first;
@@ -77,6 +79,13 @@ void main() {
expect(event.data['elapsed'] is int);
expect(event.data['elapsed'] >= 0);
final Future<VMExtensionEvent> navigationFuture = navigationEvents.first;
// This tap triggers a navigation event.
device.tap(100, 100);
final VMExtensionEvent navigationEvent = await navigationFuture;
// Validate that there are not any fields.
expect(navigationEvent.data.isEmpty);
run.stdin.write('q');
final int result = await run.exitCode;
if (result != 0)

View File

@@ -3,8 +3,41 @@
// found in the LICENSE file.
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_driver/driver_extension.dart';
void main() => runApp(const Center(child: Text(
'flutter drive lib/xxx.dart',
textDirection: TextDirection.ltr,
)));
void main() {
enableFlutterDriverExtension();
runApp(MaterialApp(
home: Material(
child: Builder(
builder: (BuildContext context) {
return FlatButton(
child: const Text(
'flutter drive lib/xxx.dart',
textDirection: TextDirection.ltr,
),
onPressed: () {
Navigator.push<Object>(
context,
MaterialPageRoute<dynamic>(
builder: (BuildContext context) {
return const Material(
child: Center(
child: Text(
'navigated here',
textDirection: TextDirection.ltr,
),
),
);
},
),
);
},
);
},
),
),
));
}