64 lines
2.3 KiB
Dart
64 lines
2.3 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
|
import 'package:pipelines_app/shell/destination.dart';
|
|
import 'package:pipelines_app/shell/shell_bar.dart';
|
|
|
|
Widget _app({required bool cupertino, required bool open, VoidCallback? back}) {
|
|
final shell = AdaptiveShell(
|
|
cupertino: cupertino,
|
|
destination: AppDestination.runs,
|
|
destinationBodies: {
|
|
AppDestination.runs: (_) => open
|
|
? ShellBar(
|
|
title: 'Run 7',
|
|
onBack: back,
|
|
actions: const [Icon(Icons.more_vert, key: Key('run-more'))],
|
|
child: const Text('detail'),
|
|
)
|
|
: const Text('list'),
|
|
},
|
|
);
|
|
return cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell);
|
|
}
|
|
|
|
void main() {
|
|
for (final cupertino in [false, true]) {
|
|
final host = cupertino ? 'cupertino' : 'material';
|
|
testWidgets('$host: an open screen takes over the bar and gives it back', (
|
|
tester,
|
|
) async {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
var backs = 0;
|
|
await tester.pumpWidget(
|
|
_app(cupertino: cupertino, open: true, back: () => backs++),
|
|
);
|
|
await tester.pump();
|
|
|
|
expect(find.text('Run 7'), findsOneWidget);
|
|
expect(find.byKey(const Key('run-more')), findsOneWidget);
|
|
await tester.tap(find.byKey(const ValueKey('shell.back')));
|
|
expect(backs, 1);
|
|
|
|
await tester.pumpWidget(_app(cupertino: cupertino, open: false));
|
|
await tester.pump();
|
|
expect(find.text('Run 7'), findsNothing);
|
|
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
|
|
expect(find.byKey(const Key('run-more')), findsNothing);
|
|
});
|
|
|
|
testWidgets('$host: Search is the fifth tab', (tester) async {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
await tester.pumpWidget(_app(cupertino: cupertino, open: false));
|
|
expect(AppDestination.values, hasLength(5));
|
|
expect(find.text('Search'), findsOneWidget);
|
|
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
|
|
});
|
|
}
|
|
}
|