9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
297 lines
10 KiB
Dart
297 lines
10 KiB
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/list_detail.dart';
|
|
import 'package:pipelines_app/shell/list_pane_widths.dart';
|
|
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
|
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
|
|
|
/// While a tab shows its list beside an open item, the shell's destination
|
|
/// bar moves to the leading edge at the bottom of the list pane, including
|
|
/// after the list's width is dragged. The list clears the bar; the item keeps its whole height, its own
|
|
/// bottom control (its tabs, or a composer) at its bottom edge.
|
|
void main() {
|
|
Future<void> setSize(WidgetTester tester, Size size) async {
|
|
tester.view.physicalSize = size;
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
}
|
|
|
|
/// A detail whose composer sits at the bottom, padded by the media inset
|
|
/// the way the chat composer is.
|
|
Widget composerDetail() => Builder(
|
|
builder: (context) => Align(
|
|
alignment: Alignment.bottomCenter,
|
|
child: Padding(
|
|
padding: EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom),
|
|
child: const SizedBox(
|
|
key: Key('composer'),
|
|
height: 56,
|
|
width: double.infinity,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
Widget listBody() => Builder(
|
|
builder: (context) => ListView(
|
|
key: const Key('list'),
|
|
children: [
|
|
for (var index = 0; index < 40; index++)
|
|
SizedBox(height: 40, child: Text('row $index')),
|
|
],
|
|
),
|
|
);
|
|
|
|
/// A detail with its own floating tabs over a list, like run detail.
|
|
Widget tabsDetail() => FloatingBarOverlay(
|
|
bar: KeyedSubtree(
|
|
key: const Key('detail-tabs'),
|
|
child: FloatingDestinationBar(
|
|
currentIndex: 0,
|
|
onTap: (_) {},
|
|
items: const [
|
|
FloatingDestinationItem(icon: Icon(Icons.summarize), label: 'One'),
|
|
FloatingDestinationItem(icon: Icon(Icons.timeline), label: 'Two'),
|
|
FloatingDestinationItem(icon: Icon(Icons.inventory), label: 'Three'),
|
|
],
|
|
),
|
|
),
|
|
child: Builder(
|
|
builder: (context) => ListView(
|
|
key: const Key('detail-list'),
|
|
children: [
|
|
for (var index = 0; index < 40; index++)
|
|
SizedBox(height: 40, child: Text('item $index')),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
|
|
Widget shell({
|
|
bool split = true,
|
|
bool tabs = false,
|
|
double textScale = 1,
|
|
ListPaneWidthStore? store,
|
|
AppDestination destination = AppDestination.chat,
|
|
}) {
|
|
final app = AdaptiveShell(
|
|
listPaneWidthStore: store ?? MemoryListPaneWidthStore(),
|
|
destination: destination,
|
|
destinationBodies: {
|
|
AppDestination.settings: (_) => const SizedBox.expand(),
|
|
AppDestination.chat: (_) => split
|
|
? ListDetailPanes(
|
|
list: listBody(),
|
|
detail: tabs ? tabsDetail() : composerDetail(),
|
|
)
|
|
: listBody(),
|
|
},
|
|
);
|
|
return MediaQuery(
|
|
data: MediaQueryData.fromView(
|
|
WidgetsBinding.instance.platformDispatcher.views.first,
|
|
).copyWith(textScaler: TextScaler.linear(textScale)),
|
|
child: MaterialApp(home: app),
|
|
);
|
|
}
|
|
|
|
Rect destinationPill(WidgetTester tester) => tester.getRect(
|
|
find
|
|
.ancestor(
|
|
of: find.byKey(const ValueKey('shell.destination.chat')).first,
|
|
matching: find.byKey(FloatingDestinationBar.rowKey),
|
|
)
|
|
.first,
|
|
);
|
|
|
|
for (final width in [1200.0, 1600.0]) {
|
|
testWidgets('$width split: the destination bar sits under the '
|
|
'list and the composer at the detail\'s bottom edge', (tester) async {
|
|
await setSize(tester, Size(width, 800));
|
|
await tester.pumpWidget(shell());
|
|
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 pill = destinationPill(tester);
|
|
// Leading at the bottom of the list pane, never over the detail.
|
|
expect(pill.left, closeTo(list.left + kFloatingBarMargin, 0.5));
|
|
expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
|
expect(pill.right, lessThanOrEqualTo(list.right));
|
|
expect(pill.overlaps(body), isFalse, reason: 'never over the detail');
|
|
expect(
|
|
pill.width,
|
|
lessThanOrEqualTo(list.width - 2 * kFloatingBarMargin),
|
|
);
|
|
for (final destination in shellTabDestinations) {
|
|
final caption = find.byKey(
|
|
ValueKey(
|
|
'destination-label-${destinationDetails(destination).label}',
|
|
),
|
|
);
|
|
expect(caption, findsOneWidget);
|
|
expect(pill.contains(tester.getRect(caption).center), isTrue);
|
|
}
|
|
|
|
// The composer reaches the detail's bottom edge: nothing is reserved
|
|
// there for the shell's bar any more.
|
|
final composer = tester.getRect(find.byKey(const Key('composer')));
|
|
expect(composer.left, body.left);
|
|
expect(composer.bottom, closeTo(800, 0.5));
|
|
expect(composer.overlaps(pill), isFalse);
|
|
|
|
// The list clears the bar, so its last rows scroll out from under it.
|
|
final listContext = tester.element(find.byKey(const Key('list')));
|
|
expect(
|
|
MediaQuery.paddingOf(listContext).bottom,
|
|
greaterThanOrEqualTo(800 - pill.top),
|
|
);
|
|
await tester.drag(find.byKey(const Key('list')), const Offset(0, -4000));
|
|
await tester.pumpAndSettle();
|
|
final last = tester.getRect(find.text('row 39'));
|
|
expect(last.bottom, lessThanOrEqualTo(pill.top));
|
|
});
|
|
|
|
testWidgets('$width split: the item tabs sit at the bottom right '
|
|
'of the detail, and its content clears only them', (tester) async {
|
|
await setSize(tester, Size(width, 800));
|
|
await tester.pumpWidget(shell(tabs: true));
|
|
await tester.pump();
|
|
await tester.pump();
|
|
|
|
final body = tester.getRect(
|
|
find.byKey(const ValueKey('list-detail-body')),
|
|
);
|
|
final pill = destinationPill(tester);
|
|
final tabs = tester.getRect(
|
|
find
|
|
.descendant(
|
|
of: find.byKey(const Key('detail-tabs')),
|
|
matching: find.byKey(FloatingDestinationBar.rowKey),
|
|
)
|
|
.first,
|
|
);
|
|
expect(tabs.right, closeTo(width - kFloatingBarMargin, 0.5));
|
|
expect(tabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
|
expect(tabs.left, greaterThan(body.left));
|
|
expect(tabs.overlaps(pill), isFalse);
|
|
// Page tabs retain their dense icon-only presentation; only app
|
|
// destinations gain visible captions.
|
|
final detailBar = tester.widget<FloatingDestinationBar>(
|
|
find.descendant(
|
|
of: find.byKey(const Key('detail-tabs')),
|
|
matching: find.byType(FloatingDestinationBar),
|
|
),
|
|
);
|
|
expect(detailBar.showLabels, isFalse);
|
|
for (final label in ['One', 'Two', 'Three']) {
|
|
expect(
|
|
find.descendant(
|
|
of: find.byKey(const Key('detail-tabs')),
|
|
matching: find.text(label),
|
|
),
|
|
findsNothing,
|
|
);
|
|
}
|
|
expect(pill.right, lessThan(body.left));
|
|
|
|
// The item's list pads its end clear of its own tabs.
|
|
final listContext = tester.element(find.byKey(const Key('detail-list')));
|
|
expect(
|
|
MediaQuery.paddingOf(listContext).bottom,
|
|
closeTo(800 - tabs.top, 0.5),
|
|
);
|
|
});
|
|
}
|
|
|
|
testWidgets('1200 split: the bar follows a dragged list width', (
|
|
tester,
|
|
) async {
|
|
await setSize(tester, const Size(1200, 800));
|
|
for (final width in [300.0, 520.0]) {
|
|
final store = MemoryListPaneWidthStore({'chat': width});
|
|
await tester.pumpWidget(
|
|
KeyedSubtree(
|
|
key: ValueKey(width),
|
|
child: shell(store: store),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
final list = tester.getRect(
|
|
find.byKey(const ValueKey('list-detail-list')),
|
|
);
|
|
expect(list.width, closeTo(width, 0.5));
|
|
final pill = destinationPill(tester);
|
|
expect(pill.left, closeTo(list.left + kFloatingBarMargin, 0.5));
|
|
expect(pill.left, greaterThanOrEqualTo(kFloatingBarMargin - 0.5));
|
|
expect(pill.right, lessThanOrEqualTo(list.right - kFloatingBarMargin));
|
|
}
|
|
});
|
|
|
|
testWidgets('1200 Settings: a page without a list keeps the bar '
|
|
'at the right edge', (tester) async {
|
|
await setSize(tester, const Size(1200, 800));
|
|
await tester.pumpWidget(shell(destination: AppDestination.settings));
|
|
await tester.pump();
|
|
final pill = destinationPill(tester);
|
|
expect(pill.right, closeTo(1200 - kFloatingBarMargin, 0.5));
|
|
});
|
|
|
|
testWidgets('1200 unsplit: the bar stays under the list column', (
|
|
tester,
|
|
) async {
|
|
await setSize(tester, const Size(1200, 800));
|
|
await tester.pumpWidget(shell(split: false));
|
|
await tester.pump();
|
|
final pill = destinationPill(tester);
|
|
// Same place as beside an open item (Search has no split), so opening
|
|
// or closing an item never moves the bar across the window.
|
|
expect(pill.left, closeTo(kFloatingBarMargin, 0.5));
|
|
expect(pill.width, lessThan(1200 * 0.6));
|
|
});
|
|
|
|
testWidgets('390: the bar hugs its tabs at the phone\'s bottom '
|
|
'right', (tester) async {
|
|
await setSize(tester, const Size(390, 844));
|
|
await tester.pumpWidget(shell(split: false));
|
|
await tester.pump();
|
|
final pill = destinationPill(tester);
|
|
expect(pill.width, lessThanOrEqualTo(390 - 2 * kFloatingBarMargin));
|
|
for (final destination in shellTabDestinations) {
|
|
expect(
|
|
find.byKey(
|
|
ValueKey(
|
|
'destination-label-${destinationDetails(destination).label}',
|
|
),
|
|
),
|
|
findsOneWidget,
|
|
);
|
|
}
|
|
expect(pill.right, closeTo(390 - kFloatingBarMargin, 0.5));
|
|
});
|
|
|
|
for (final width in [600.0, 840.0]) {
|
|
testWidgets('$width split at 2x: the bar fits the list pane and '
|
|
'the item tabs the detail, without overflow', (tester) async {
|
|
await setSize(tester, Size(width, 800));
|
|
await tester.pumpWidget(shell(tabs: true, textScale: 2));
|
|
await tester.pump();
|
|
await tester.pump();
|
|
expect(tester.takeException(), isNull);
|
|
final list = tester.getRect(
|
|
find.byKey(const ValueKey('list-detail-list')),
|
|
);
|
|
final pill = destinationPill(tester);
|
|
expect(pill.left, greaterThanOrEqualTo(list.left));
|
|
expect(pill.right, lessThanOrEqualTo(list.right));
|
|
});
|
|
}
|
|
}
|