fix(app): Android Back and the back gesture go through the router: they step up a level, and ask before closing the app; an open pipeline is part of the route
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/app_route.dart';
|
||||
@@ -169,6 +170,65 @@ void main() {
|
||||
expect(find.text('Deep-linked run'), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('Android Back on a wide screen steps out of a run, not the app', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(1000, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final exits = <String>[];
|
||||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
SystemChannels.platform,
|
||||
(call) async {
|
||||
if (call.method == 'SystemNavigator.pop') exits.add(call.method);
|
||||
return null;
|
||||
},
|
||||
);
|
||||
addTearDown(
|
||||
() => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
SystemChannels.platform,
|
||||
null,
|
||||
),
|
||||
);
|
||||
final channel = FakeChannel()..readyCompleter.complete();
|
||||
final client = PipelinesClient(channelFactory: (_) => channel);
|
||||
final provider = PlatformRouteInformationProvider(
|
||||
initialRouteInformation: RouteInformation(uri: Uri.parse('/runs/1')),
|
||||
);
|
||||
addTearDown(provider.dispose);
|
||||
await pumpApp(tester, channel: channel, client: client, provider: provider);
|
||||
await replyList(
|
||||
tester,
|
||||
channel,
|
||||
runs: [
|
||||
{'id': 1, 'name': 'Deep-linked run', 'status': 'running'},
|
||||
],
|
||||
);
|
||||
await replyDetail(tester, channel, 1);
|
||||
expect(provider.value.uri.path, '/runs/1');
|
||||
|
||||
// The system Back button or gesture.
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/runs');
|
||||
expect(exits, isEmpty);
|
||||
|
||||
// From the list, Back asks before leaving the app.
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Close Pipelines?'), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('app-exit-stay')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(exits, isEmpty);
|
||||
expect(provider.value.uri.path, '/runs');
|
||||
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('app-exit-close')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(exits, ['SystemNavigator.pop']);
|
||||
});
|
||||
|
||||
testWidgets('tabs and run selection update the route; browser Back pops it', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user