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';
|
||||
@@ -28,7 +27,7 @@ void main() {
|
||||
|
||||
/// An open item: its title published to the pane's bar, its own tabs
|
||||
/// floating where the pane says, and a list padded clear of both bars.
|
||||
Widget item({bool cupertino = false}) => ShellBar(
|
||||
Widget item() => ShellBar(
|
||||
title: 'Open item',
|
||||
subtitle: 'Its context',
|
||||
actions: const [Icon(Icons.more_vert, semanticLabel: 'More')],
|
||||
@@ -40,7 +39,7 @@ void main() {
|
||||
bar: KeyedSubtree(
|
||||
key: const Key('item-tabs'),
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
edge: edge,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
@@ -68,9 +67,8 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
Widget shell({bool cupertino = false, int attention = 0}) {
|
||||
Widget shell({int attention = 0}) {
|
||||
final app = AdaptiveShell(
|
||||
cupertino: cupertino,
|
||||
attentionCount: attention,
|
||||
destinationBodies: {
|
||||
AppDestination.runs: (_) => ShellBadge(
|
||||
@@ -89,14 +87,14 @@ void main() {
|
||||
detail: DetailPane(
|
||||
destination: AppDestination.runs,
|
||||
implyBack: false,
|
||||
builder: (_) => item(cupertino: cupertino),
|
||||
builder: (_) => item(),
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
destination: AppDestination.runs,
|
||||
);
|
||||
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
|
||||
return MaterialApp(home: app);
|
||||
}
|
||||
|
||||
Finder shellBar() => find.byWidgetPredicate(
|
||||
@@ -107,100 +105,88 @@ void main() {
|
||||
matching: find.byType(SegmentedBar),
|
||||
);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
testWidgets('1200: the shell bar covers the list pane and the '
|
||||
'item\'s bar shares its row', (tester) async {
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell());
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
testWidgets('$host 1200: the shell bar covers the list pane and the '
|
||||
'item\'s bar shares its row', (tester) async {
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
final list = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-list')),
|
||||
);
|
||||
final body = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
final shellPills = find.descendant(
|
||||
of: shellBar(),
|
||||
matching: find.byType(GlassPill),
|
||||
);
|
||||
for (final element in shellPills.evaluate()) {
|
||||
expect(
|
||||
rectOf(element).right,
|
||||
lessThanOrEqualTo(list.right),
|
||||
reason: 'no shell piece sits over the open item',
|
||||
);
|
||||
}
|
||||
// Both titles on the same top row.
|
||||
final shellTitle = tester.getRect(
|
||||
find.descendant(of: shellBar(), matching: find.text('Runs')),
|
||||
);
|
||||
final paneTitle = tester.getRect(find.text('Open item'));
|
||||
expect(paneTitle.left, greaterThanOrEqualTo(body.left));
|
||||
final paneTop = tester.getRect(
|
||||
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
|
||||
);
|
||||
final shellTop = tester.getRect(shellPills.first);
|
||||
expect(paneTop.top, shellTop.top);
|
||||
expect(paneTitle.top, lessThan(shellTitle.bottom));
|
||||
// The title pill carries the item's context too.
|
||||
expect(find.text('Its context'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('$host 1200: the item\'s tabs float at the bottom of its '
|
||||
'pane, the shell\'s tab bar under the list', (tester) async {
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
final shellTabs = tester.getRect(
|
||||
find
|
||||
.ancestor(
|
||||
of: find.byKey(const ValueKey('shell.destination.runs')).first,
|
||||
matching: find.byKey(FloatingDestinationBar.rowKey),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
final itemTabs = tester.getRect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('item-tabs')),
|
||||
matching: find.byKey(FloatingDestinationBar.rowKey),
|
||||
),
|
||||
);
|
||||
final body = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
// The shell's tabs sit at the bottom of the list pane; the item's at
|
||||
// the bottom right of the detail pane, never on them.
|
||||
final list = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-list')),
|
||||
);
|
||||
expect(shellTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
expect(shellTabs.right, lessThanOrEqualTo(list.right));
|
||||
expect(itemTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
expect(itemTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
|
||||
expect(itemTabs.left, greaterThanOrEqualTo(body.left));
|
||||
expect(itemTabs.overlaps(shellTabs), isFalse);
|
||||
// The item's list starts below its bar and clears its tabs at rest.
|
||||
final paneBarPill = tester.getRect(
|
||||
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
|
||||
);
|
||||
final list = tester.getRect(find.byKey(const ValueKey('list-detail-list')));
|
||||
final body = tester.getRect(find.byKey(const ValueKey('list-detail-body')));
|
||||
final shellPills = find.descendant(
|
||||
of: shellBar(),
|
||||
matching: find.byType(GlassPill),
|
||||
);
|
||||
for (final element in shellPills.evaluate()) {
|
||||
expect(
|
||||
tester.getTopLeft(find.text('item row 0')).dy,
|
||||
greaterThanOrEqualTo(paneBarPill.bottom),
|
||||
rectOf(element).right,
|
||||
lessThanOrEqualTo(list.right),
|
||||
reason: 'no shell piece sits over the open item',
|
||||
);
|
||||
expect(
|
||||
MediaQuery.paddingOf(
|
||||
tester.element(find.byKey(const Key('item-list'))),
|
||||
).bottom,
|
||||
greaterThanOrEqualTo(800 - itemTabs.top),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
// Both titles on the same top row.
|
||||
final shellTitle = tester.getRect(
|
||||
find.descendant(of: shellBar(), matching: find.text('Runs')),
|
||||
);
|
||||
final paneTitle = tester.getRect(find.text('Open item'));
|
||||
expect(paneTitle.left, greaterThanOrEqualTo(body.left));
|
||||
final paneTop = tester.getRect(
|
||||
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
|
||||
);
|
||||
final shellTop = tester.getRect(shellPills.first);
|
||||
expect(paneTop.top, shellTop.top);
|
||||
expect(paneTitle.top, lessThan(shellTitle.bottom));
|
||||
// The title pill carries the item's context too.
|
||||
expect(find.text('Its context'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('1200: the item\'s tabs float at the bottom of its '
|
||||
'pane, the shell\'s tab bar under the list', (tester) async {
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell());
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
final shellTabs = tester.getRect(
|
||||
find
|
||||
.ancestor(
|
||||
of: find.byKey(const ValueKey('shell.destination.runs')).first,
|
||||
matching: find.byKey(FloatingDestinationBar.rowKey),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
final itemTabs = tester.getRect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('item-tabs')),
|
||||
matching: find.byKey(FloatingDestinationBar.rowKey),
|
||||
),
|
||||
);
|
||||
final body = tester.getRect(find.byKey(const ValueKey('list-detail-body')));
|
||||
// The shell's tabs sit at the bottom of the list pane; the item's at
|
||||
// the bottom right of the detail pane, never on them.
|
||||
final list = tester.getRect(find.byKey(const ValueKey('list-detail-list')));
|
||||
expect(shellTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
expect(shellTabs.right, lessThanOrEqualTo(list.right));
|
||||
expect(itemTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
expect(itemTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
|
||||
expect(itemTabs.left, greaterThanOrEqualTo(body.left));
|
||||
expect(itemTabs.overlaps(shellTabs), isFalse);
|
||||
// The item's list starts below its bar and clears its tabs at rest.
|
||||
final paneBarPill = tester.getRect(
|
||||
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
|
||||
);
|
||||
expect(
|
||||
tester.getTopLeft(find.text('item row 0')).dy,
|
||||
greaterThanOrEqualTo(paneBarPill.bottom),
|
||||
);
|
||||
expect(
|
||||
MediaQuery.paddingOf(
|
||||
tester.element(find.byKey(const Key('item-list'))),
|
||||
).bottom,
|
||||
greaterThanOrEqualTo(800 - itemTabs.top),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('390: an open item is its own page with its tabs at the bottom', (
|
||||
tester,
|
||||
|
||||
Reference in New Issue
Block a user