I have a mobile application for Android with multiple pages and currently try to write simple integration tests for it...
The issue is that my app only uses internal Android back gestures, I have no back button or something like this.
Is it somehow possible to tell the FlutterDriver to go one page back? (Simulate a android internal back button?) Something like this:
driver.goPageBack()
Thank you so much. :)
Try this in your Activity code.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.YOUR_ACTIVITY);
assert getSupportActionBar() != null; //null check
getSupportActionBar().setDisplayHomeAsUpEnabled(true); //show back button
}
@Override
public boolean onSupportNavigateUp() {
finish();
return true;
}
In the Flutter repo there is a test that simulates the hardware back button by sending a message over the platform channel like this:
final ByteData message = const JSONMethodCodec().encodeMethodCall(const MethodCall('popRoute'));
await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/navigation', message, (_) { });
https://github.com/flutter/flutter/blob/6688e63f68ebba0919a5fe3c8f8432bd8a65f81b/packages/flutter/test/widgets/router_test.dart#L725-L726
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With