Remove Cupertino shell branches
Keep the Material-only shell path while preserving public cupertino parameters for callers. Narrow matching tests to Material hosts and behavior because the app always runs under MaterialApp.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
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';
|
||||
@@ -9,66 +8,62 @@ import 'package:pipelines_app/shell/list_detail.dart';
|
||||
/// page) closes when another item is selected, so the pane shows the newly
|
||||
/// selected item instead of the old item's page.
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('selecting another item closes the previous item\'s page '
|
||||
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
|
||||
tester.view.physicalSize = const Size(1200, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final selected = ValueNotifier<int>(1);
|
||||
addTearDown(selected.dispose);
|
||||
testWidgets("selecting another item closes the previous item's page", (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(1200, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final selected = ValueNotifier<int>(1);
|
||||
addTearDown(selected.dispose);
|
||||
|
||||
Widget detail(int id) => Builder(
|
||||
builder: (context) => Center(
|
||||
child: GestureDetector(
|
||||
key: const Key('open-page'),
|
||||
onTap: () => Navigator.of(context).push(
|
||||
PageRouteBuilder<void>(
|
||||
pageBuilder: (_, _, _) => Text('page of item $id'),
|
||||
),
|
||||
Widget detail(int id) => Builder(
|
||||
builder: (context) => Center(
|
||||
child: GestureDetector(
|
||||
key: const Key('open-page'),
|
||||
onTap: () => Navigator.of(context).push(
|
||||
PageRouteBuilder<void>(
|
||||
pageBuilder: (_, _, _) => Text('page of item $id'),
|
||||
),
|
||||
child: Text('item $id'),
|
||||
),
|
||||
child: Text('item $id'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final shell = AdaptiveShell(
|
||||
destination: AppDestination.runs,
|
||||
destinationBodies: {
|
||||
AppDestination.runs: (_) => ValueListenableBuilder<int>(
|
||||
valueListenable: selected,
|
||||
builder: (_, id, _) => ListDetailPanes(
|
||||
list: const Text('list'),
|
||||
detailIdentity: id,
|
||||
detail: detail(id),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
home: shell,
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final shell = AdaptiveShell(
|
||||
cupertino: cupertino,
|
||||
destination: AppDestination.runs,
|
||||
destinationBodies: {
|
||||
AppDestination.runs: (_) => ValueListenableBuilder<int>(
|
||||
valueListenable: selected,
|
||||
builder: (_, id, _) => ListDetailPanes(
|
||||
list: const Text('list'),
|
||||
detailIdentity: id,
|
||||
detail: detail(id),
|
||||
),
|
||||
),
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: shell)
|
||||
: MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
home: shell,
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('open-page')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('page of item 1'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('open-page')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('page of item 1'), findsOneWidget);
|
||||
// The same item rebuilt keeps its page open.
|
||||
selected.value = 1;
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('page of item 1'), findsOneWidget);
|
||||
|
||||
// The same item rebuilt keeps its page open.
|
||||
selected.value = 1;
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('page of item 1'), findsOneWidget);
|
||||
|
||||
selected.value = 2;
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('page of item 1'), findsNothing);
|
||||
expect(find.text('item 2'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
selected.value = 2;
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('page of item 1'), findsNothing);
|
||||
expect(find.text('item 2'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user