Merge commit 'd365959bf1bb7921e728f8ad152548b21a44f9b5' into pipelines/run-20261111-0353-cupertino-out-runs-actions-7b6c

This commit is contained in:
2026-11-11 04:19:56 +00:00
40 changed files with 1566 additions and 2247 deletions
+9 -20
View File
@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../chat/shell/chat_shell_terminal_keys.dart';
@@ -78,13 +77,10 @@ class TerminalBody extends StatelessWidget {
);
}
TextStyle? _noteStyle(BuildContext context) => cupertino
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
color: CupertinoColors.secondaryLabel.resolveFrom(context),
)
: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
);
TextStyle? _noteStyle(BuildContext context) =>
Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
);
Widget _closeEnded(TerminalTab tab) {
void close() => unawaited(hub.close(tab));
@@ -92,9 +88,7 @@ class TerminalBody extends StatelessWidget {
padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
child: Align(
alignment: AlignmentDirectional.centerStart,
child: cupertino
? CupertinoButton(onPressed: close, child: const Text('Close tab'))
: TextButton(onPressed: close, child: const Text('Close tab')),
child: TextButton(onPressed: close, child: const Text('Close tab')),
),
);
}
@@ -116,15 +110,10 @@ class TerminalBody extends StatelessWidget {
child: Text(error, style: _noteStyle(context)),
),
if (machines.isNotEmpty)
cupertino
? CupertinoButton(
onPressed: open,
child: const Text('New terminal'),
)
: FilledButton.tonal(
onPressed: open,
child: const Text('New terminal'),
),
FilledButton.tonal(
onPressed: open,
child: const Text('New terminal'),
),
],
),
);
+27 -62
View File
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// One choice of a [TerminalMenuButton].
@@ -12,8 +11,7 @@ class TerminalChoice<T> {
final Key? key;
}
/// An icon button opening the host's menu: a Material popup menu, or a
/// Cupertino action sheet with Cancel.
/// An icon button opening the host's menu.
class TerminalMenuButton<T> extends StatelessWidget {
const TerminalMenuButton({
super.key,
@@ -38,66 +36,33 @@ class TerminalMenuButton<T> extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (!cupertino) {
return PopupMenuButton<T>(
tooltip: label,
icon: Icon(icon),
onSelected: onSelected,
itemBuilder: (_) => [
for (final choice in choices)
choice.checked == null
? PopupMenuItem<T>(
key: choice.key,
value: choice.value,
child: Text(choice.label),
)
: CheckedPopupMenuItem<T>(
key: choice.key,
value: choice.value,
checked: choice.checked!,
child: Text(choice.label),
),
if (info case final info?) ...[
const PopupMenuDivider(),
PopupMenuItem<T>(
key: const ValueKey('terminal-menu-info'),
enabled: false,
child: Text(info),
),
],
return PopupMenuButton<T>(
tooltip: label,
icon: Icon(icon),
onSelected: onSelected,
itemBuilder: (_) => [
for (final choice in choices)
choice.checked == null
? PopupMenuItem<T>(
key: choice.key,
value: choice.value,
child: Text(choice.label),
)
: CheckedPopupMenuItem<T>(
key: choice.key,
value: choice.value,
checked: choice.checked!,
child: Text(choice.label),
),
if (info case final info?) ...[
const PopupMenuDivider(),
PopupMenuItem<T>(
key: const ValueKey('terminal-menu-info'),
enabled: false,
child: Text(info),
),
],
);
}
return CupertinoButton(
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: () => _sheet(context),
child: Icon(cupertinoIcon, semanticLabel: label),
],
);
}
Future<void> _sheet(BuildContext context) async {
final picked = await showCupertinoModalPopup<T>(
context: context,
builder: (sheet) => CupertinoActionSheet(
title: Text(label),
message: info == null ? null : Text(info!),
actions: [
for (final choice in choices)
CupertinoActionSheetAction(
key: choice.key,
isDefaultAction: choice.checked ?? false,
onPressed: () => Navigator.of(sheet).pop(choice.value),
child: Text(
choice.checked ?? false ? '${choice.label} ✓' : choice.label,
),
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.of(sheet).pop(),
child: const Text('Cancel'),
),
),
);
if (picked != null) onSelected(picked);
}
}
+1 -10
View File
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'terminal_body.dart';
@@ -17,9 +16,7 @@ PageRoute<void> terminalPageRoute({
}) {
Widget page(BuildContext _) =>
TerminalPage(hub: hub, layout: layout, cupertino: cupertino);
return cupertino
? CupertinoPageRoute<void>(builder: page)
: MaterialPageRoute<void>(builder: page);
return MaterialPageRoute<void>(builder: page);
}
/// The full-screen terminal page of a narrow window, opened and closed by
@@ -94,12 +91,6 @@ class TerminalPage extends StatelessWidget {
),
),
);
if (cupertino) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(middle: Text('Terminal')),
child: Material(type: MaterialType.transparency, child: body),
);
}
return Scaffold(
appBar: AppBar(title: const Text('Terminal')),
body: body,
@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -123,12 +122,8 @@ class _TerminalPanelState extends State<TerminalPanel> {
),
),
);
final surface = widget.cupertino
? CupertinoColors.systemBackground.resolveFrom(context)
: Theme.of(context).colorScheme.surfaceContainerLow;
final divider = widget.cupertino
? CupertinoColors.separator.resolveFrom(context)
: Theme.of(context).colorScheme.outlineVariant;
final surface = Theme.of(context).colorScheme.surfaceContainerLow;
final divider = Theme.of(context).colorScheme.outlineVariant;
return Semantics(
container: true,
label: 'Terminal panel',
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../ui/adaptive/segmented_bar_pieces.dart';
@@ -31,31 +30,17 @@ class TerminalShortcutBubble extends StatelessWidget {
final label = running > 1
? 'Open terminal, $running running'
: 'Open terminal';
final icon = Icon(
cupertino
? CupertinoIcons.chevron_left_slash_chevron_right
: Icons.terminal,
size: 20,
);
final icon = Icon(Icons.terminal, size: 20);
final content = running > 1
? Badge.count(count: running, child: icon)
: icon;
final button = cupertino
? CupertinoButton.tinted(
key: const Key('terminal-shortcut-bubble'),
sizeStyle: CupertinoButtonSize.small,
padding: const EdgeInsets.all(10),
borderRadius: BorderRadius.circular(22),
onPressed: onOpen,
child: content,
)
: FloatingActionButton.small(
key: const Key('terminal-shortcut-bubble'),
heroTag: null,
tooltip: label,
onPressed: onOpen,
child: content,
);
final button = FloatingActionButton.small(
key: const Key('terminal-shortcut-bubble'),
heroTag: null,
tooltip: label,
onPressed: onOpen,
child: content,
);
return Semantics(
button: true,
label: label,
@@ -47,14 +47,14 @@ class TerminalTabStrip extends StatelessWidget {
padding: const EdgeInsetsDirectional.only(end: 4),
child: Semantics(
identifier: 'terminal-tab-$index',
child: _tab(context, tab, tab == selected),
child: _tab(tab, tab == selected),
),
),
],
),
),
),
_newTerminal(context),
_newTerminal(),
if (showModes)
TerminalMenuButton<_Option>(
cupertino: cupertino,
@@ -88,7 +88,7 @@ class TerminalTabStrip extends StatelessWidget {
String _label(TerminalTab tab) =>
hub.multiMachine ? '${tab.title} · ${tab.machineName}' : tab.title;
Widget _tab(BuildContext context, TerminalTab tab, bool selected) {
Widget _tab(TerminalTab tab, bool selected) {
final label = Text(
_label(tab),
maxLines: 1,
@@ -98,35 +98,6 @@ class TerminalTabStrip extends StatelessWidget {
: const TextStyle(fontStyle: FontStyle.italic),
);
void close() => unawaited(hub.close(tab));
if (cupertino) {
final color = selected
? CupertinoTheme.of(context).primaryColor
: CupertinoColors.label.resolveFrom(context);
return Row(
mainAxisSize: MainAxisSize.min,
children: [
CupertinoButton(
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: () => hub.select(tab),
child: DefaultTextStyle.merge(
style: TextStyle(
color: color,
fontWeight: selected ? FontWeight.w600 : null,
),
child: label,
),
),
CupertinoButton(
padding: EdgeInsets.zero,
onPressed: close,
child: const Icon(
CupertinoIcons.xmark_circle_fill,
semanticLabel: 'Close terminal',
),
),
],
);
}
return InputChip(
label: label,
selected: selected,
@@ -138,7 +109,7 @@ class TerminalTabStrip extends StatelessWidget {
);
}
Widget _newTerminal(BuildContext context) {
Widget _newTerminal() {
final machines = hub.connected;
if (machines.length > 1) {
return TerminalMenuButton<String>(
@@ -159,20 +130,11 @@ class TerminalTabStrip extends StatelessWidget {
}
final enabled = machines.isNotEmpty;
void open() => unawaited(hub.open());
return cupertino
? CupertinoButton(
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: enabled ? open : null,
child: const Icon(
CupertinoIcons.add,
semanticLabel: 'New terminal',
),
)
: IconButton(
tooltip: 'New terminal',
onPressed: enabled ? open : null,
icon: const Icon(Icons.add),
);
return IconButton(
tooltip: 'New terminal',
onPressed: enabled ? open : null,
icon: const Icon(Icons.add),
);
}
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'terminal_layout.dart';
@@ -28,17 +27,6 @@ class TerminalToggleButton extends StatelessWidget {
listenable: layout,
builder: (context, _) {
final shown = layout.visible;
if (cupertino) {
return CupertinoButton(
key: const ValueKey('shell.terminal'),
padding: EdgeInsets.zero,
onPressed: actions.toggle,
child: Icon(
CupertinoIcons.chevron_left_slash_chevron_right,
semanticLabel: label,
),
);
}
return IconButton(
key: const ValueKey('shell.terminal'),
tooltip: label,
+19 -55
View File
@@ -1,10 +1,8 @@
import '../ui/motion/fade_through_stack.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../ui/adaptive/segmented_bar.dart';
import '../ui/adaptive/floating_bar_layout.dart';
import '../ui/adaptive/floating_destination_bar.dart';
import 'attention_badge.dart';
import 'destination.dart';
@@ -37,6 +35,9 @@ class AdaptiveShell extends StatefulWidget {
final ListPaneWidthStore listPaneWidthStore;
final Map<AppDestination, WidgetBuilder> destinationBodies;
/// Retained for callers that still pass it; the shell always draws the
/// Material controls and scaffold whether this is set or not.
final bool cupertino;
/// The destination a route owner selected. When null the shell keeps its own
@@ -120,7 +121,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
key: const ValueKey('shell.badge.chat.unread'),
count: _bar.badge(destination, ShellBadgeKind.unread),
label: 'unread chats',
cupertino: widget.cupertino,
cupertino: false,
child: icon,
);
}
@@ -130,12 +131,12 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
final attention = widget.attentionCount > 0;
return AttentionDestinationIcon(
count: widget.attentionCount,
cupertino: widget.cupertino,
cupertino: false,
child: ActivityBadge(
key: const ValueKey('shell.badge.runs.running'),
count: attention ? 0 : _bar.badge(destination, ShellBadgeKind.running),
label: 'runs in progress',
cupertino: widget.cupertino,
cupertino: false,
child: icon,
),
);
@@ -202,7 +203,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
alignment: AlignmentDirectional.bottomStart,
child: FloatingDestinationBar(
showLabels: true,
cupertino: widget.cupertino,
cupertino: false,
currentIndex: index,
onTap: (value) => _select(shellTabDestinations[value]),
items: _destinationItems(),
@@ -240,24 +241,6 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
},
child: child,
);
if (widget.cupertino) {
return backable(
ShellSystemInsets(
padding: system,
child: CupertinoPageScaffold(
navigationBar: topBar,
child: SafeArea(
top: false,
bottom: false,
child: FloatingBarOverlay(
bar: bar,
child: _destinationStack(contents),
),
),
),
),
);
}
return backable(
ShellSystemInsets(
padding: system,
@@ -352,10 +335,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
final item = destinationDetails(destination);
return FloatingDestinationItem(
key: ValueKey('shell.destination.${destination.name}'),
icon: _icon(
destination,
widget.cupertino ? item.cupertinoIcon : item.icon,
),
icon: _icon(destination, item.icon),
label: item.label,
);
}).toList();
@@ -367,18 +347,17 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
String label, {
required bool page,
}) {
final cupertino = widget.cupertino;
final onBack = spec?.onBack ?? (page ? _closePage : null);
final published = spec?.actions ?? const <Widget>[];
final onSearch = widget.onSearch;
return SegmentedBar(
cupertino: cupertino,
cupertino: false,
automaticallyImplyLeading: false,
leading: onBack == null
? null
: SegmentedBackButton(
key: const ValueKey('shell.back'),
cupertino: cupertino,
cupertino: false,
onPressed: onBack,
),
title: spec?.title ?? label,
@@ -401,22 +380,12 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
// A screen whose main pill is its own field (Search) needs no
// separate Search action.
else if (onSearch != null && spec?.titleWidget == null && !page)
cupertino
? CupertinoButton(
key: const ValueKey('shell.search'),
padding: EdgeInsets.zero,
onPressed: onSearch,
child: const Icon(
CupertinoIcons.search,
semanticLabel: 'Search',
),
)
: IconButton(
key: const ValueKey('shell.search'),
onPressed: onSearch,
tooltip: 'Search',
icon: const Icon(Icons.search),
),
IconButton(
key: const ValueKey('shell.search'),
onPressed: onSearch,
tooltip: 'Search',
icon: const Icon(Icons.search),
),
...widget.barActions,
],
);
@@ -438,10 +407,9 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
/// split never remounts it.
///
/// It rebuilds itself when [listenable] (the focused destination's published
/// bar) changes; [initial] supplies the size and obstruction, which do not
/// depend on the published contents.
class _ListPaneBar extends StatelessWidget
implements ObstructingPreferredSizeWidget {
/// bar) changes; [initial] supplies the size, which does not depend on the
/// published contents.
class _ListPaneBar extends StatelessWidget implements PreferredSizeWidget {
const _ListPaneBar({
required this.listenable,
required this.initial,
@@ -461,10 +429,6 @@ class _ListPaneBar extends StatelessWidget
@override
Size get preferredSize => initial.preferredSize;
@override
bool shouldFullyObstruct(BuildContext context) =>
initial.shouldFullyObstruct(context);
@override
Widget build(BuildContext context) => ListenableBuilder(
listenable: listenable,
+20 -67
View File
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../features/attention/domain/attention_models.dart';
@@ -8,9 +7,8 @@ import '../ui/motion/motion.dart';
///
/// The bell itself lives in the Runs heading, so without this the count would
/// be visible only on that destination; the web mirrors it on the rail and
/// dock tab. Material hosts use the framework [Badge]; Cupertino has no badge
/// control, so its tab bar and sidebar get the host's red count overlay. Zero
/// draws the bare icon, and a count labels the item exactly like the bell:
/// dock tab. Material hosts use the framework [Badge]. Zero draws the bare
/// icon, and a count labels the item exactly like the bell:
/// `Notifications, {n} needing attention`.
class AttentionDestinationIcon extends StatelessWidget {
const AttentionDestinationIcon({
@@ -21,24 +19,25 @@ class AttentionDestinationIcon extends StatelessWidget {
});
final int count;
/// Retained for callers that still pass it; the icon is always the Material
/// [Badge] whether this is set or not.
final bool cupertino;
final Widget child;
@override
Widget build(BuildContext context) {
final visible = count > 0;
final Widget icon = cupertino
? _CupertinoCountOverlay(count: count, visible: visible, child: child)
: Badge(
label: visible
? MotionSwitcher(
scale: true,
child: Text('$count', key: ValueKey(count)),
)
: null,
isLabelVisible: visible,
child: child,
);
final Widget icon = Badge(
label: visible
? MotionSwitcher(
scale: true,
child: Text('$count', key: ValueKey(count)),
)
: null,
isLabelVisible: visible,
child: child,
);
if (!visible) return icon;
// The number alone would read as a stray "3"; the item carries the bell's
// full label instead.
@@ -49,51 +48,6 @@ class AttentionDestinationIcon extends StatelessWidget {
}
}
/// The iOS tab-badge idiom: a red stadium with the count over the icon's
/// trailing corner. Content-driven size; only the overlap offset is fixed.
class _CupertinoCountOverlay extends StatelessWidget {
const _CupertinoCountOverlay({
required this.count,
required this.visible,
required this.child,
});
final int count;
final bool visible;
final Widget child;
@override
Widget build(BuildContext context) {
if (!visible) return child;
final style = CupertinoTheme.of(
context,
).textTheme.tabLabelTextStyle.copyWith(color: CupertinoColors.white);
return Stack(
clipBehavior: Clip.none,
children: [
child,
PositionedDirectional(
top: -6,
end: -10,
child: DecoratedBox(
decoration: ShapeDecoration(
color: CupertinoColors.systemRed.resolveFrom(context),
shape: const StadiumBorder(),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1),
child: MotionSwitcher(
scale: true,
child: Text('$count', key: ValueKey(count), style: style),
),
),
),
),
],
);
}
}
/// A small count on a tab icon: blue for activity (runs in progress, unread
/// chats), so it reads apart from the red needs-you count.
class ActivityBadge extends StatelessWidget {
@@ -108,6 +62,9 @@ class ActivityBadge extends StatelessWidget {
final int count;
final String label;
/// Retained for callers that still pass it; the badge uses the Material
/// theme colours whether this is set or not.
final bool cupertino;
final bool bottom;
final Widget child;
@@ -115,12 +72,8 @@ class ActivityBadge extends StatelessWidget {
@override
Widget build(BuildContext context) {
final visible = count > 0;
final color = cupertino
? CupertinoColors.systemBlue.resolveFrom(context)
: Theme.of(context).colorScheme.primary;
final text = cupertino
? CupertinoColors.white
: Theme.of(context).colorScheme.onPrimary;
final color = Theme.of(context).colorScheme.primary;
final text = Theme.of(context).colorScheme.onPrimary;
final stack = Stack(
clipBehavior: Clip.none,
children: [
+5 -1
View File
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
enum AppDestination { pipelines, runs, chat, search, settings }
@@ -20,6 +20,10 @@ AppDestination shellTabFor(AppDestination destination) =>
? destination
: AppDestination.pipelines;
/// The label and icons for [value].
///
/// [cupertinoIcon] is retained in the record for callers that still read it;
/// the shell itself draws [icon] on its Material path.
({String label, IconData icon, IconData cupertinoIcon}) destinationDetails(
AppDestination value,
) => switch (value) {
+3 -12
View File
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/adaptive/host.dart';
import '../ui/adaptive/segmented_bar.dart';
import '../ui/motion/container_transform_route.dart';
import '../ui/motion/container_transform_source.dart';
@@ -93,17 +91,14 @@ PageRoute<void> detailPageRoute(
ContainerTransformLink? growFrom,
}) {
final page = DetailPane(destination: destination, builder: builder);
final cupertino = usesCupertinoHost(context);
if (growFrom != null) {
return ContainerTransformPageRoute<void>(
link: growFrom,
cupertino: cupertino,
cupertino: false,
builder: (_) => page,
);
}
return cupertino
? CupertinoPageRoute<void>(builder: (_) => page)
: MaterialPageRoute<void>(builder: (_) => page);
return MaterialPageRoute<void>(builder: (_) => page);
}
/// An open item's own bar over its content: what the content publishes
@@ -151,11 +146,10 @@ class _DetailPaneState extends State<DetailPane> {
// status-bar inset itself. The scaffold and the body's place in it stay
// the same either way, so switching never remounts the content.
final barless = spec?.barless ?? false;
final cupertino = usesCupertinoHost(context);
final bar = barless
? null
: SegmentedBar(
cupertino: cupertino,
cupertino: false,
automaticallyImplyLeading: widget.implyBack,
title: title,
subtitle: spec?.subtitle,
@@ -171,9 +165,6 @@ class _DetailPaneState extends State<DetailPane> {
// pads its lists by the bar's height (top) and by the system's or a
// floating tab bar's (bottom), floating its own tabs clear of them.
final content = SafeArea(top: false, bottom: false, child: body);
if (cupertino) {
return CupertinoPageScaffold(navigationBar: bar, child: content);
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
+4 -5
View File
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/adaptive/host.dart';
import '../ui/motion/surface_visibility.dart';
/// The open item's own navigator beside a list on a wide window.
@@ -43,9 +41,10 @@ class _DetailPaneNavigatorState extends State<DetailPaneNavigator> {
@override
Widget build(BuildContext context) {
final Page<void> root = usesCupertinoHost(context)
? CupertinoPage<void>(key: _rootKey, child: widget.child)
: MaterialPage<void>(key: _rootKey, child: widget.child);
final Page<void> root = MaterialPage<void>(
key: _rootKey,
child: widget.child,
);
// Only the shown tab's pane answers the system Back: a page left open in
// another tab's pane stays there while Back acts on the current tab. The
// route asks every handler on it, so a hidden pane also ignores the call.
+2 -11
View File
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/adaptive/host.dart';
import 'destination.dart';
/// The detail pane beside a list before anything is chosen: the
@@ -19,22 +17,15 @@ class EmptyDetailPane extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final details = destinationDetails(destination);
final color = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
final color = Theme.of(context).colorScheme.onSurfaceVariant;
return Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
cupertino ? details.cupertinoIcon : details.icon,
size: 32,
color: color,
),
Icon(details.icon, size: 32, color: color),
const SizedBox(height: 12),
Text(
message,
+1 -8
View File
@@ -1,9 +1,7 @@
import 'package:flutter/gestures.dart' show DragStartBehavior;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../ui/adaptive/host.dart';
import '../ui/adaptive/resize_grip.dart';
/// How wide the divider's invisible grab area is, centred on its line.
@@ -17,12 +15,7 @@ class ListPaneDividerLine extends StatelessWidget {
const ListPaneDividerLine({super.key});
@override
Widget build(BuildContext context) => usesCupertinoHost(context)
? Container(
width: 1,
color: CupertinoColors.separator.resolveFrom(context),
)
: const VerticalDivider(width: 1);
Widget build(BuildContext context) => const VerticalDivider(width: 1);
}
/// The grab area over [ListPaneDividerLine]: dragging it (mouse or touch)
+4 -34
View File
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'destination.dart';
@@ -10,48 +9,19 @@ class ShellDestinationMenu extends StatelessWidget {
required this.current,
required this.onSelected,
});
/// Retained for callers that still pass it; the menu is always the Material
/// popup whether this is set or not.
final bool cupertino;
final AppDestination current;
final ValueChanged<AppDestination> onSelected;
Future<void> _choose(BuildContext context) async {
final value = await showCupertinoModalPopup<AppDestination>(
context: context,
builder: (context) => CupertinoActionSheet(
title: const Text('Main navigation'),
actions: [
for (final destination in AppDestination.values)
CupertinoActionSheetAction(
isDefaultAction: destination == current,
onPressed: () => Navigator.pop(context, destination),
child: Text(destinationDetails(destination).label),
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
),
);
if (value != null && context.mounted) onSelected(value);
}
@override
Widget build(BuildContext context) {
final child = Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(cupertino ? CupertinoIcons.square_grid_2x2 : Icons.apps),
const Text('Menu'),
],
children: const [Icon(Icons.apps), Text('Menu')],
);
if (cupertino) {
return Semantics(
button: true,
label: 'Main navigation',
child: CupertinoButton(onPressed: () => _choose(context), child: child),
);
}
return PopupMenuButton<AppDestination>(
tooltip: 'Main navigation',
onSelected: onSelected,
@@ -2,7 +2,6 @@ import 'dart:math' as math;
import 'dart:ui' show Tristate;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/list_detail.dart';
@@ -18,266 +17,247 @@ import 'package:pipelines_app/ui/theme/app_theme.dart';
import '../features/pipelines/fixtures.dart';
void main() {
for (final cupertino in [false, true]) {
for (final brightness in Brightness.values) {
for (final width in [640.0, 840.0, 1280.0]) {
for (final scale in [1.0, 2.0]) {
testWidgets('shared body-priority panes and selected rows: $cupertino '
'$brightness at $width @${scale}x', (tester) async {
SharedPreferences.setMockInitialValues({});
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
tester.platformDispatcher.textScaleFactorTestValue = scale;
addTearDown(
tester.platformDispatcher.clearTextScaleFactorTestValue,
);
final fixture = PipelineFixture();
final gateway = FakeGateway(
(type, fields) => switch (type) {
'list_pipelines' => pipelineListReply(fixture.summaries),
'get_pipeline' => pipelineDetailReply(
fixture.detailFor(
fields['pipeline_id'] as int,
fields['version'] as int,
)!,
),
'list_runs' => {
'runs': [
for (final id in [1, 2])
{
'id': id,
'title': 'Run item $id',
'status': 'succeeded',
},
],
for (final brightness in Brightness.values) {
for (final width in [640.0, 840.0, 1280.0]) {
for (final scale in [1.0, 2.0]) {
testWidgets('shared body-priority panes and selected rows: '
'$brightness at $width @${scale}x', (tester) async {
SharedPreferences.setMockInitialValues({});
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
tester.platformDispatcher.textScaleFactorTestValue = scale;
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
final fixture = PipelineFixture();
final gateway = FakeGateway(
(type, fields) => switch (type) {
'list_pipelines' => pipelineListReply(fixture.summaries),
'get_pipeline' => pipelineDetailReply(
fixture.detailFor(
fields['pipeline_id'] as int,
fields['version'] as int,
)!,
),
'list_runs' => {
'runs': [
for (final id in [1, 2])
{'id': id, 'title': 'Run item $id', 'status': 'succeeded'},
],
},
'get_run' => {
'run_detail': {
'id': fields['run_id'],
'title': 'Run item ${fields['run_id']}',
'status': 'succeeded',
'input': {'prompt': 'Recorded input'},
},
'get_run' => {
'run_detail': {
'id': fields['run_id'],
'title': 'Run item ${fields['run_id']}',
'status': 'succeeded',
'input': {'prompt': 'Recorded input'},
},
'chat_sessions' => {
'chat_sessions': [
{
'id': 'a',
'title': 'Chat item a',
'backend': 'claude',
'model': 'claude-opus',
'mode': 'auto',
'mode_name': 'Auto',
},
},
'chat_sessions' => {
'chat_sessions': [
{
'id': 'a',
'title': 'Chat item a',
'backend': 'claude',
'model': 'claude-opus',
'mode': 'auto',
'mode_name': 'Auto',
},
{
'id': 'b',
'title': 'Chat item b',
'backend': 'claude',
'model': 'claude-opus',
'mode': 'auto',
'mode_name': 'Auto',
},
],
},
'chat_messages' => {
'chat_history': {'messages': []},
},
_ => {},
{
'id': 'b',
'title': 'Chat item b',
'backend': 'claude',
'model': 'claude-opus',
'mode': 'auto',
'mode_name': 'Auto',
},
],
},
);
final shell = AdaptiveShell(
cupertino: cupertino,
destinationBodies: {
AppDestination.pipelines: (_) =>
PipelinesScreen(gateway: gateway, embedded: true),
AppDestination.runs: (_) => RunsScreen(gateway: gateway),
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
'chat_messages' => {
'chat_history': {'messages': []},
},
);
await tester.pumpWidget(
cupertino
? CupertinoApp(
theme: CupertinoThemeData(brightness: brightness),
home: shell,
)
: MaterialApp(
theme: brightness == Brightness.dark
? appDarkTheme()
: appLightTheme(),
home: shell,
),
);
await tester.pumpAndSettle();
final paneWidths = <double>[];
final bodyWidths = <double>[];
for (final destination in ['Pipelines', 'Runs', 'Chat']) {
if (destination != 'Pipelines') {
await tester.tap(
find.byKey(
ValueKey('shell.destination.${destination.toLowerCase()}'),
),
);
await tester.pumpAndSettle();
expect(
tester.takeException(),
isNull,
reason: '$destination list',
);
}
final list = find.byKey(const ValueKey('list-detail-list'));
final detail = find.byKey(const ValueKey('list-detail-body'));
expect(list, findsOneWidget);
expect(detail, findsOneWidget);
final before = tester.getSize(list).width;
final bodyBefore = tester.getSize(detail).width;
paneWidths.add(before);
bodyWidths.add(bodyBefore);
expect(bodyBefore, greaterThanOrEqualTo(width * 0.5));
// 60% of the window, or more once the list reaches its cap.
expect(
bodyBefore,
lessThanOrEqualTo(
math.max(width * 0.6, width - 1 - kListPaneMaxWidth) + 0.5,
_ => {},
},
);
final shell = AdaptiveShell(
destinationBodies: {
AppDestination.pipelines: (_) =>
PipelinesScreen(gateway: gateway, embedded: true),
AppDestination.runs: (_) => RunsScreen(gateway: gateway),
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
},
);
await tester.pumpWidget(
MaterialApp(
theme: brightness == Brightness.dark
? appDarkTheme()
: appLightTheme(),
home: shell,
),
);
await tester.pumpAndSettle();
final paneWidths = <double>[];
final bodyWidths = <double>[];
for (final destination in ['Pipelines', 'Runs', 'Chat']) {
if (destination != 'Pipelines') {
await tester.tap(
find.byKey(
ValueKey('shell.destination.${destination.toLowerCase()}'),
),
);
expect(bodyBefore, greaterThan(before));
final rowKeys = switch (destination) {
'Pipelines' => ['pipeline-row-1', 'pipeline-row-2'],
'Runs' => ['run-row-1', 'run-row-2'],
_ => ['chat-row-a', 'chat-row-b'],
};
for (final key in rowKeys) {
final target = find.byKey(ValueKey(key));
// In a narrow Cupertino list the row center can be a star/menu
// control. Open the chat through its title, not a trailing action.
final opener = destination == 'Chat'
? find.descendant(
of: target,
matching: find.text('Chat item ${key.split('-').last}'),
)
: target;
await tester.ensureVisible(opener);
await tester.tap(opener);
await tester.pumpAndSettle();
expect(
tester.takeException(),
isNull,
reason: '$destination after opening $key',
);
expect(tester.getSize(list).width, closeTo(before, 0.01));
expect(tester.getSize(detail).width, closeTo(bodyBefore, 0.01));
expect(
tester
.state<NavigatorState>(find.byType(Navigator).first)
.canPop(),
isFalse,
);
for (final rowKey in rowKeys) {
final row = find.byKey(ValueKey(rowKey));
expect(
row,
findsOneWidget,
reason: 'the list must remain visible',
);
final selected = rowKey == key;
expect(
tester.getSemantics(row).flagsCollection.isSelected ==
Tristate.isTrue,
selected,
reason: '$destination: $rowKey after opening $key',
);
// Every list retains shared row semantics; features may supply their own fill.
final context = tester.element(row);
expect(tester.widget<AppListRow>(row).selected, selected);
final surface = find.descendant(
of: row,
matching: find.byKey(appListRowSurfaceKey),
);
expect(
cupertino
? tester.widget<ColoredBox>(surface).color
: tester.widget<Material>(surface).color,
selected
? tester.widget<AppListRow>(row).selectedFill ??
AppListRow.selectedColor(
context,
cupertino: cupertino,
)
: const Color(0x00000000),
);
}
}
if (destination == 'Chat') {
// Starring lives in the row's actions menu.
final menu = find.byKey(const Key('chat-actions-b'));
await tester.ensureVisible(menu);
await tester.tap(menu);
await tester.pumpAndSettle();
await tester.tap(find.text('Star'));
await tester.pumpAndSettle();
expect(
gateway
.callsOf('chat_star')
.last
.fields['chat_query']['session_id'],
'b',
);
final actions = find.byKey(const Key('chat-actions-b'));
await tester.ensureVisible(actions);
await tester.tap(actions);
await tester.pumpAndSettle();
expect(find.text('Rename…'), findsOneWidget);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
}
// A phone still uses stock page navigation; returning to a wide
// window must keep the selected item without clearing its route.
tester.view.physicalSize = const Size(390, 900);
await tester.pumpAndSettle();
expect(
tester
.state<NavigatorState>(find.byType(Navigator).first)
.canPop(),
isTrue,
reason: '$destination should push its selected item on a phone',
tester.takeException(),
isNull,
reason: '$destination list',
);
expect(
find.byKey(const ValueKey('list-detail-list')),
findsNothing,
);
tester.view.physicalSize = Size(width, 900);
}
final list = find.byKey(const ValueKey('list-detail-list'));
final detail = find.byKey(const ValueKey('list-detail-body'));
expect(list, findsOneWidget);
expect(detail, findsOneWidget);
final before = tester.getSize(list).width;
final bodyBefore = tester.getSize(detail).width;
paneWidths.add(before);
bodyWidths.add(bodyBefore);
expect(bodyBefore, greaterThanOrEqualTo(width * 0.5));
// 60% of the window, or more once the list reaches its cap.
expect(
bodyBefore,
lessThanOrEqualTo(
math.max(width * 0.6, width - 1 - kListPaneMaxWidth) + 0.5,
),
);
expect(bodyBefore, greaterThan(before));
final rowKeys = switch (destination) {
'Pipelines' => ['pipeline-row-1', 'pipeline-row-2'],
'Runs' => ['run-row-1', 'run-row-2'],
_ => ['chat-row-a', 'chat-row-b'],
};
for (final key in rowKeys) {
final target = find.byKey(ValueKey(key));
// The row center can be a star/menu control. Open the chat
// through its title, not a trailing action.
final opener = destination == 'Chat'
? find.descendant(
of: target,
matching: find.text('Chat item ${key.split('-').last}'),
)
: target;
await tester.ensureVisible(opener);
await tester.tap(opener);
await tester.pumpAndSettle();
expect(
tester.takeException(),
isNull,
reason: '$destination after opening $key',
);
expect(tester.getSize(list).width, closeTo(before, 0.01));
expect(tester.getSize(detail).width, closeTo(bodyBefore, 0.01));
expect(
tester
.state<NavigatorState>(find.byType(Navigator).first)
.canPop(),
isFalse,
);
expect(tester.getSize(list).width, closeTo(before, 0.01));
expect(
tester
.getSemantics(find.byKey(ValueKey(rowKeys.last)))
.flagsCollection
.isSelected,
Tristate.isTrue,
);
for (final rowKey in rowKeys) {
final row = find.byKey(ValueKey(rowKey));
expect(
row,
findsOneWidget,
reason: 'the list must remain visible',
);
final selected = rowKey == key;
expect(
tester.getSemantics(row).flagsCollection.isSelected ==
Tristate.isTrue,
selected,
reason: '$destination: $rowKey after opening $key',
);
// Every list retains shared row semantics; features may supply their own fill.
final context = tester.element(row);
expect(tester.widget<AppListRow>(row).selected, selected);
final surface = find.descendant(
of: row,
matching: find.byKey(appListRowSurfaceKey),
);
expect(
tester.widget<Material>(surface).color,
selected
? tester.widget<AppListRow>(row).selectedFill ??
AppListRow.selectedColor(context, cupertino: false)
: const Color(0x00000000),
);
}
}
if (destination == 'Chat') {
// Starring lives in the row's actions menu.
final menu = find.byKey(const Key('chat-actions-b'));
await tester.ensureVisible(menu);
await tester.tap(menu);
await tester.pumpAndSettle();
await tester.tap(find.text('Star'));
await tester.pumpAndSettle();
expect(
gateway
.callsOf('chat_star')
.last
.fields['chat_query']['session_id'],
'b',
);
final actions = find.byKey(const Key('chat-actions-b'));
await tester.ensureVisible(actions);
await tester.tap(actions);
await tester.pumpAndSettle();
expect(find.text('Rename…'), findsOneWidget);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
}
// A phone still uses stock page navigation; returning to a wide
// window must keep the selected item without clearing its route.
tester.view.physicalSize = const Size(390, 900);
await tester.pumpAndSettle();
expect(
paneWidths,
everyElement(closeTo(paneWidths.first, 0.01)),
reason: 'Pipelines, Runs and Chat must use identical pane widths',
tester
.state<NavigatorState>(find.byType(Navigator).first)
.canPop(),
isTrue,
reason: '$destination should push its selected item on a phone',
);
expect(tester.takeException(), isNull);
expect(
bodyWidths,
everyElement(closeTo(bodyWidths.first, 0.01)),
reason:
'Every destination must share the body-priority sizing policy',
find.byKey(const ValueKey('list-detail-list')),
findsNothing,
);
await tester.pumpWidget(const SizedBox.shrink());
});
}
tester.view.physicalSize = Size(width, 900);
await tester.pumpAndSettle();
expect(
tester
.state<NavigatorState>(find.byType(Navigator).first)
.canPop(),
isFalse,
);
expect(tester.getSize(list).width, closeTo(before, 0.01));
expect(
tester
.getSemantics(find.byKey(ValueKey(rowKeys.last)))
.flagsCollection
.isSelected,
Tristate.isTrue,
);
}
expect(
paneWidths,
everyElement(closeTo(paneWidths.first, 0.01)),
reason: 'Pipelines, Runs and Chat must use identical pane widths',
);
expect(tester.takeException(), isNull);
expect(
bodyWidths,
everyElement(closeTo(bodyWidths.first, 0.01)),
reason:
'Every destination must share the body-priority sizing policy',
);
await tester.pumpWidget(const SizedBox.shrink());
});
}
}
}
@@ -41,7 +41,6 @@ void main() {
channel: channel,
client: PipelinesClient(channelFactory: (_) => channel),
provider: provider,
cupertino: false,
);
await replyRunList(tester, channel);
return provider;
@@ -45,7 +45,6 @@ void main() {
channel: channel,
client: PipelinesClient(channelFactory: (_) => channel),
provider: provider,
cupertino: false,
);
await replyRunList(tester, channel);
+5 -38
View File
@@ -332,14 +332,12 @@ Future<void> pumpApp(
required FakeChannel channel,
required PipelinesClient client,
required PlatformRouteInformationProvider provider,
required bool cupertino,
}) async {
await tester.pumpWidget(
PipelinesApp(
androidSupported: false,
server: webServer(),
client: client,
cupertino: cupertino,
routeInformationProvider: provider,
),
);
@@ -373,7 +371,6 @@ void main() {
channel: channel,
client: client,
provider: provider,
cupertino: false,
);
await replyRunList(tester, channel);
await replyRunDetail(tester, channel, 2);
@@ -439,13 +436,7 @@ void main() {
);
addTearDown(provider.dispose);
await pumpApp(
tester,
channel: channel,
client: client,
provider: provider,
cupertino: false,
);
await pumpApp(tester, channel: channel, client: client, provider: provider);
await replyRunList(tester, channel);
await replyRunDetail(tester, channel, 2);
@@ -519,13 +510,7 @@ void main() {
);
addTearDown(provider.dispose);
await pumpApp(
tester,
channel: channel,
client: client,
provider: provider,
cupertino: false,
);
await pumpApp(tester, channel: channel, client: client, provider: provider);
await replyRunList(tester, channel);
await replyRunDetailFor(tester, channel, searchSelectionDetail());
expect(find.text('Run 7'), findsWidgets);
@@ -631,13 +616,7 @@ void main() {
);
addTearDown(provider.dispose);
await pumpApp(
tester,
channel: channel,
client: client,
provider: provider,
cupertino: false,
);
await pumpApp(tester, channel: channel, client: client, provider: provider);
await replyRunList(tester, channel);
await tapTab(tester, 'Search');
@@ -706,13 +685,7 @@ void main() {
);
addTearDown(provider.dispose);
await pumpApp(
tester,
channel: channel,
client: client,
provider: provider,
cupertino: false,
);
await pumpApp(tester, channel: channel, client: client, provider: provider);
await replyRun7List(tester, channel);
// The hit navigates to run 7, but its detail is never loaded: the operator
@@ -763,13 +736,7 @@ void main() {
);
addTearDown(provider.dispose);
await pumpApp(
tester,
channel: channel,
client: client,
provider: provider,
cupertino: false,
);
await pumpApp(tester, channel: channel, client: client, provider: provider);
await replyRun7List(tester, channel);
await openArtifactHit(tester, channel);
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_list_cupertino.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_list_material.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
@@ -9,114 +7,88 @@ import 'package:pipelines_app/shell/list_detail.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
void main() {
for (final cupertino in [false, true]) {
for (final scale in [1.0, 2.0]) {
testWidgets(
'chat list stays above labeled navigation ($cupertino, $scale)',
(tester) async {
tester.view.physicalSize = const Size(1200, 900);
tester.view.devicePixelRatio = 1;
tester.platformDispatcher.textScaleFactorTestValue = scale;
addTearDown(tester.view.reset);
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
String? opened;
final sessions = [
for (var i = 0; i < 14; i++)
{
'id': 's$i',
'title': 'Chat item $i',
'model': 'model',
'directory': '/work/project-$i',
},
];
Widget list() => cupertino
? CupertinoSessionList(
sections: [(title: 'Chats', sessions: sessions)],
emptyMessage: null,
duplicateTitles: const {},
onOpen: (row) => opened = row['id'] as String,
onRename: (_) {},
onClose: (_) {},
onReopen: (_) {},
onStar: (_) {},
onHide: (_) {},
onClearSearch: null,
isUnseen: (_) => false,
errorFor: (_) => null,
)
: MaterialSessionList(
sections: [(title: 'Chats', sessions: sessions)],
emptyMessage: null,
duplicateTitles: const {},
onOpen: (row) => opened = row['id'] as String,
onRename: (_) {},
onClose: (_) {},
onReopen: (_) {},
onStar: (_) {},
onHide: (_) {},
onClearSearch: null,
isUnseen: (_) => false,
errorFor: (_) => null,
);
final shell = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.chat,
destinationBodies: {
AppDestination.chat: (_) => ListDetailPanes(
list: list(),
detail: const SizedBox.expand(),
),
},
);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell),
);
await tester.pumpAndSettle();
final navigation = tester.getRect(
find.byKey(FloatingDestinationBar.rowKey),
);
final scrollView = find.byType(CustomScrollView);
final viewport = tester.getRect(scrollView);
expect(viewport.bottom, lessThanOrEqualTo(navigation.top + .5));
expect(viewport.width, greaterThan(0));
final scrollable = tester.state<ScrollableState>(
find.descendant(of: scrollView, matching: find.byType(Scrollable)),
);
scrollable.position.jumpTo(scrollable.position.maxScrollExtent);
await tester.pumpAndSettle();
final last = find.byKey(const Key('chat-row-s13'));
expect(
tester.getRect(last).bottom,
lessThanOrEqualTo(navigation.top + .5),
);
final metadata = find.descendant(
of: last,
matching: find.text('model · /work/project-13'),
);
expect(metadata, findsOneWidget);
expect(
tester.getRect(metadata).bottom,
lessThanOrEqualTo(navigation.top + .5),
);
await tester.tap(find.text('Chat item 13'));
await tester.pump();
expect(opened, 's13');
final retainedOffset = scrollable.position.pixels;
tester.view.physicalSize = const Size(1440, 900);
await tester.pumpAndSettle();
expect(
tester.state<ScrollableState>(
find.descendant(
of: scrollView,
matching: find.byType(Scrollable),
),
),
same(scrollable),
);
expect(scrollable.position.pixels, closeTo(retainedOffset, .5));
expect(tester.takeException(), isNull);
for (final scale in [1.0, 2.0]) {
testWidgets('chat list stays above labeled navigation ($scale)', (
tester,
) async {
tester.view.physicalSize = const Size(1200, 900);
tester.view.devicePixelRatio = 1;
tester.platformDispatcher.textScaleFactorTestValue = scale;
addTearDown(tester.view.reset);
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
String? opened;
final sessions = [
for (var i = 0; i < 14; i++)
{
'id': 's$i',
'title': 'Chat item $i',
'model': 'model',
'directory': '/work/project-$i',
},
];
Widget list() => MaterialSessionList(
sections: [(title: 'Chats', sessions: sessions)],
emptyMessage: null,
duplicateTitles: const {},
onOpen: (row) => opened = row['id'] as String,
onRename: (_) {},
onClose: (_) {},
onReopen: (_) {},
onStar: (_) {},
onHide: (_) {},
onClearSearch: null,
isUnseen: (_) => false,
errorFor: (_) => null,
);
final shell = AdaptiveShell(
destination: AppDestination.chat,
destinationBodies: {
AppDestination.chat: (_) =>
ListDetailPanes(list: list(), detail: const SizedBox.expand()),
},
);
}
await tester.pumpWidget(MaterialApp(home: shell));
await tester.pumpAndSettle();
final navigation = tester.getRect(
find.byKey(FloatingDestinationBar.rowKey),
);
final scrollView = find.byType(CustomScrollView);
final viewport = tester.getRect(scrollView);
expect(viewport.bottom, lessThanOrEqualTo(navigation.top + .5));
expect(viewport.width, greaterThan(0));
final scrollable = tester.state<ScrollableState>(
find.descendant(of: scrollView, matching: find.byType(Scrollable)),
);
scrollable.position.jumpTo(scrollable.position.maxScrollExtent);
await tester.pumpAndSettle();
final last = find.byKey(const Key('chat-row-s13'));
expect(
tester.getRect(last).bottom,
lessThanOrEqualTo(navigation.top + .5),
);
final metadata = find.descendant(
of: last,
matching: find.text('model · /work/project-13'),
);
expect(metadata, findsOneWidget);
expect(
tester.getRect(metadata).bottom,
lessThanOrEqualTo(navigation.top + .5),
);
await tester.tap(find.text('Chat item 13'));
await tester.pump();
expect(opened, 's13');
final retainedOffset = scrollable.position.pixels;
tester.view.physicalSize = const Size(1440, 900);
await tester.pumpAndSettle();
expect(
tester.state<ScrollableState>(
find.descendant(of: scrollView, matching: find.byType(Scrollable)),
),
same(scrollable),
);
expect(scrollable.position.pixels, closeTo(retainedOffset, .5));
expect(tester.takeException(), isNull);
});
}
}
@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../../native_back.dart';
@@ -9,7 +8,6 @@ import 'package:pipelines_app/features/runs/screen.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'run_detail_finders.dart';
import 'package:pipelines_app/shell/empty_detail_pane.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
class _Gateway implements ApiGateway {
final framesController = StreamController<JsonMap>.broadcast();
@@ -345,32 +343,6 @@ void main() {
});
}
testWidgets(
'wide Cupertino host keeps list and detail bars while pending',
(tester) async {
await tester.pumpWidget(
CupertinoApp(
home: CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(middle: Text('Runs')),
child: SafeArea(
child: RunsScreen(gateway: gateway, initialRunId: 1),
),
),
),
);
await _mountList(tester, gateway);
expect(find.byType(CupertinoPageScaffold), findsNWidgets(2));
// The host's own bar and the detail pane's segmented bar.
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
expect(find.byType(SegmentedBar), findsOneWidget);
expect(find.text('Loading run details…'), findsOneWidget);
expect(find.byType(CupertinoActivityIndicator), findsOneWidget);
expect(find.text('Back to list'), findsOneWidget);
},
variant: TargetPlatformVariant.only(TargetPlatform.iOS),
);
testWidgets('on a phone an open run is its own page and Back returns', (
tester,
) async {
@@ -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/core/transport/pipelines_client.dart'
@@ -9,22 +8,18 @@ import 'package:pipelines_app/features/settings/settings_store.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'package:pipelines_app/ui/theme/app_theme.dart';
import 'fake_channel.dart';
/// Settings as the shell's tab: the page runs behind the shell's bar, and on
/// Cupertino the grouped background reaches the top edge with the bar's
/// scrim in the same colour, so no white band or seam shows under the bar.
/// Settings as the shell's tab: the page runs behind the shell's bar.
void main() {
Future<void> pump(WidgetTester tester, {required bool cupertino}) async {
Future<void> pump(WidgetTester tester) async {
await tester.binding.setSurfaceSize(const Size(560, 1000));
addTearDown(() => tester.binding.setSurfaceSize(null));
final factory = FakeChannelFactory();
final client = transport.PipelinesClient(channelFactory: factory.call);
addTearDown(client.dispose);
final shell = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.settings,
destinationBodies: {
AppDestination.settings: (_) => SettingsScreen(
@@ -34,9 +29,7 @@ void main() {
),
},
);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell),
);
await tester.pumpWidget(MaterialApp(home: shell));
await tester.pump();
await tester.pump();
}
@@ -52,34 +45,8 @@ void main() {
)
.color;
testWidgets('Cupertino: the grouped background runs under the bar', (
tester,
) async {
await pump(tester, cupertino: true);
final grouped = AppColors.groupedBackground.color.toARGB32();
expect(scrimOf(tester).toARGB32(), grouped);
// The page's background starts at the top edge, behind the bar.
final page = find.ancestor(
of: find.byKey(const ValueKey<String>('settings.scroll')),
matching: find.byWidgetPredicate(
(widget) => widget is ColoredBox && widget.color.toARGB32() == grouped,
),
);
expect(page, findsWidgets);
expect(tester.getTopLeft(page.last).dy, 0);
// The groups start below the bar and persistent category selector.
final bar = tester.getRect(find.byType(SegmentedBar));
expect(
tester.getTopLeft(find.byType(SettingsGroup).first).dy,
greaterThanOrEqualTo(bar.bottom - 8),
);
});
testWidgets('Material: the bar keeps the shell page background', (
tester,
) async {
await pump(tester, cupertino: false);
testWidgets('the bar keeps the shell page background', (tester) async {
await pump(tester);
final context = tester.element(find.byType(SettingsGroup).first);
expect(
+10 -41
View File
@@ -1,13 +1,11 @@
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/ui/adaptive/floating_destination_bar.dart';
/// The Runs tab mirrors the attention count in every mount of both hosts:
/// the floating tab bar at full width on a phone and right-aligned on a wide
/// window. Zero draws the
/// bare icon with no count and no attention semantics.
/// The Runs tab mirrors the attention count in every mount: the floating tab
/// bar at full width on a phone and right-aligned on a wide window. Zero draws
/// the bare icon with no count and no attention semantics.
void main() {
final needingAttention = RegExp('Notifications, 3 needing attention');
final anyAttention = RegExp('needing attention');
@@ -15,27 +13,22 @@ void main() {
Future<void> pumpShell(
WidgetTester tester, {
required double width,
required bool cupertino,
required int count,
}) async {
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final shell = AdaptiveShell(cupertino: cupertino, attentionCount: count);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell),
);
final shell = AdaptiveShell(attentionCount: count);
await tester.pumpWidget(MaterialApp(home: shell));
}
for (final width in [390.0, 1000.0]) {
final mount = width < 600 ? 'bottom bar' : 'wide bar';
testWidgets('Material $mount shows the count on the Runs tab', (
tester,
) async {
testWidgets('$mount shows the count on the Runs tab', (tester) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: width, cupertino: false, count: 3);
await pumpShell(tester, width: width, count: 3);
expect(find.byType(FloatingDestinationBar), findsOneWidget);
expect(find.byType(NavigationRail), findsNothing);
final badge = find.byType(Badge);
@@ -49,9 +42,9 @@ void main() {
semantics.dispose();
});
testWidgets('Material $mount hides the badge at zero', (tester) async {
testWidgets('$mount hides the badge at zero', (tester) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: width, cupertino: false, count: 0);
await pumpShell(tester, width: width, count: 0);
final badge = find.byType(Badge);
expect(badge, findsOneWidget);
expect(tester.widget<Badge>(badge).isLabelVisible, isFalse);
@@ -67,32 +60,8 @@ void main() {
});
}
for (final width in [390.0, 1280.0]) {
final mount = width < 600 ? 'tab bar' : 'wide tab bar';
testWidgets('Cupertino $mount shows the count on the Runs item', (
tester,
) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: width, cupertino: true, count: 3);
expect(find.byType(FloatingDestinationBar), findsOneWidget);
expect(find.byType(Badge), findsNothing, reason: 'no Material badge');
expect(find.text('3'), findsOneWidget);
expect(find.bySemanticsLabel(needingAttention), findsOneWidget);
semantics.dispose();
});
testWidgets('Cupertino $mount hides the count at zero', (tester) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: width, cupertino: true, count: 0);
expect(find.text('0'), findsNothing);
expect(find.bySemanticsLabel(anyAttention), findsNothing);
semantics.dispose();
});
}
testWidgets('the badge stays visible from every destination', (tester) async {
await pumpShell(tester, width: 1000, cupertino: false, count: 2);
await pumpShell(tester, width: 1000, count: 2);
for (final name in ['runs', 'chat', 'search']) {
await tester.tap(find.byKey(ValueKey('shell.destination.$name')));
await tester.pumpAndSettle();
+62 -79
View File
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -6,89 +5,73 @@ import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets(
'$host Ctrl+Tab and Ctrl+Shift+Tab leave destinations unchanged',
(tester) async {
final app = AdaptiveShell(
cupertino: cupertino,
destinationBodies: {
for (final destination in shellTabDestinations)
destination: (_) => Focus(
autofocus: destination == AppDestination.pipelines,
child: Text(destination.name),
),
},
);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: app) : MaterialApp(home: app),
);
Future<void> press({required bool shift}) async {
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
if (shift) {
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
}
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
if (shift) {
await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
}
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pump();
}
expect(find.text('pipelines'), findsOneWidget);
await press(shift: true);
expect(find.text('pipelines'), findsOneWidget);
await press(shift: false);
expect(find.text('pipelines'), findsOneWidget);
testWidgets('Ctrl+Tab and Ctrl+Shift+Tab leave destinations unchanged', (
tester,
) async {
final app = AdaptiveShell(
destinationBodies: {
for (final destination in shellTabDestinations)
destination: (_) => Focus(
autofocus: destination == AppDestination.pipelines,
child: Text(destination.name),
),
},
);
await tester.pumpWidget(MaterialApp(home: app));
testWidgets(
'$host plain Tab traverses and Ctrl+Tab does not change destinations',
(tester) async {
final first = FocusNode();
final second = FocusNode();
addTearDown(first.dispose);
addTearDown(second.dispose);
final app = AdaptiveShell(
cupertino: cupertino,
destinationBodies: {
AppDestination.pipelines: (_) => Column(
children: [
cupertino
? CupertinoTextField(focusNode: first)
: TextField(focusNode: first),
cupertino
? CupertinoTextField(focusNode: second)
: TextField(focusNode: second),
],
),
AppDestination.runs: (_) => const Text('runs'),
},
);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: app) : MaterialApp(home: app),
);
first.requestFocus();
await tester.pump();
Future<void> press({required bool shift}) async {
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
if (shift) {
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
}
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
if (shift) {
await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
}
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pump();
}
// Plain Tab retains normal traversal semantics and does not select a tab.
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.pump();
expect(second.hasFocus, isTrue);
expect(find.text('pipelines'), findsOneWidget);
await press(shift: true);
expect(find.text('pipelines'), findsOneWidget);
await press(shift: false);
expect(find.text('pipelines'), findsOneWidget);
});
first.requestFocus();
await tester.pump();
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pump();
expect(find.text('runs'), findsNothing);
testWidgets('plain Tab traverses and Ctrl+Tab does not change destinations', (
tester,
) async {
final first = FocusNode();
final second = FocusNode();
addTearDown(first.dispose);
addTearDown(second.dispose);
final app = AdaptiveShell(
destinationBodies: {
AppDestination.pipelines: (_) => Column(
children: [
TextField(focusNode: first),
TextField(focusNode: second),
],
),
AppDestination.runs: (_) => const Text('runs'),
},
);
}
await tester.pumpWidget(MaterialApp(home: app));
first.requestFocus();
await tester.pump();
// Plain Tab retains normal traversal semantics and does not select a tab.
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.pump();
expect(second.hasFocus, isTrue);
first.requestFocus();
await tester.pump();
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pump();
expect(find.text('runs'), findsNothing);
});
}
+51 -56
View File
@@ -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);
});
}
+28 -43
View File
@@ -1,52 +1,37 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/empty_detail_pane.dart';
/// One placeholder for an empty detail pane: the destination's icon above a
/// short muted line, centred, on both hosts.
/// short muted line, centred.
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
for (final destination in [
AppDestination.runs,
AppDestination.chat,
AppDestination.pipelines,
]) {
testWidgets('$host ${destination.name}: icon over a muted line', (
tester,
) async {
final content = EmptyDetailPane(
destination: destination,
message: 'Select one to open it here.',
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: content))
: MaterialApp(home: Scaffold(body: content)),
);
final details = destinationDetails(destination);
final icon = find.byIcon(
cupertino ? details.cupertinoIcon : details.icon,
);
expect(icon, findsOneWidget);
final text = find.text('Select one to open it here.');
expect(
tester.getTopLeft(text).dy,
greaterThan(tester.getRect(icon).bottom),
);
// Centred in the pane.
final size = tester.view.physicalSize / tester.view.devicePixelRatio;
expect(tester.getCenter(text).dx, closeTo(size.width / 2, 1));
// Muted: the same secondary colour on the icon and the line.
final context = tester.element(text);
final muted = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
expect(tester.widget<Icon>(icon).color, muted);
expect(tester.widget<Text>(text).style?.color, muted);
});
}
for (final destination in [
AppDestination.runs,
AppDestination.chat,
AppDestination.pipelines,
]) {
testWidgets('${destination.name}: icon over a muted line', (tester) async {
final content = EmptyDetailPane(
destination: destination,
message: 'Select one to open it here.',
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: content)));
final icon = find.byIcon(destinationDetails(destination).icon);
expect(icon, findsOneWidget);
final text = find.text('Select one to open it here.');
expect(
tester.getTopLeft(text).dy,
greaterThan(tester.getRect(icon).bottom),
);
// Centred in the pane.
final size = tester.view.physicalSize / tester.view.devicePixelRatio;
expect(tester.getCenter(text).dx, closeTo(size.width / 2, 1));
// Muted: the same secondary colour on the icon and the line.
final context = tester.element(text);
final muted = Theme.of(context).colorScheme.onSurfaceVariant;
expect(tester.widget<Icon>(icon).color, muted);
expect(tester.widget<Text>(text).style?.color, muted);
});
}
}
+141 -171
View File
@@ -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/list_detail_policy.dart';
@@ -67,9 +66,8 @@ void main() {
var taps = 0;
double? contentBottomPadding;
Widget shell({required bool cupertino}) {
Widget shell() {
final app = AdaptiveShell(
cupertino: cupertino,
destinationBodies: {
AppDestination.pipelines: (_) => Builder(
builder: (context) {
@@ -86,184 +84,156 @@ void main() {
),
},
);
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
return MaterialApp(home: app);
}
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('phone bar hugs its tabs at the bottom right too, and '
'taps beside it reach the content', (tester) async {
taps = 0;
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(shell());
final rect = tester.getRect(pill());
await expectLabeledTargets(tester, rect);
await expectNoSharedBackdrop(tester);
expect(rect.width, lessThanOrEqualTo(390 - 2 * 16));
expect(rect.right, 390 - 16);
expect(rect.bottom, 844 - 16);
expect(find.byType(NavigationRail), findsNothing);
await tester.tapAt(Offset(rect.left - 40, rect.center.dy));
await tester.pump();
expect(taps, 1);
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pumpAndSettle();
expect(find.text('Chat — Not implemented'), findsOneWidget);
});
testWidgets('$host: phone bar hugs its tabs at the bottom right too, and '
'taps beside it reach the content', (tester) async {
taps = 0;
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(shell(cupertino: cupertino));
final rect = tester.getRect(pill());
await expectLabeledTargets(tester, rect);
await expectNoSharedBackdrop(tester);
expect(rect.width, lessThanOrEqualTo(390 - 2 * 16));
expect(rect.right, 390 - 16);
expect(rect.bottom, 844 - 16);
expect(find.byType(NavigationRail), findsNothing);
await tester.tapAt(Offset(rect.left - 40, rect.center.dy));
await tester.pump();
expect(taps, 1);
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pumpAndSettle();
expect(find.text('Chat — Not implemented'), findsOneWidget);
});
testWidgets('$host: wide leading bar under the list, content '
'keeps the width and taps beside the bar reach it', (tester) async {
taps = 0;
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: cupertino));
final rect = tester.getRect(pill());
// With no item open the bar still sits under the list column, where it
// sits beside an open item, so it never jumps sides.
expect(rect.left, moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5));
expect(rect.bottom, 800 - 16);
expect(rect.width, lessThan(1200 * 0.6));
// Captions participate in the bar's content-driven width.
await expectLabeledTargets(tester, rect);
await expectNoSharedBackdrop(tester);
expect(
rect.width,
lessThanOrEqualTo(listDetailListWidth(1200, 1200, null) - 2 * 16),
);
// No rail or sidebar: the content starts at the left edge.
expect(find.byType(NavigationRail), findsNothing);
expect(find.byType(CupertinoListTile), findsNothing);
expect(tester.getRect(find.byKey(const Key('content'))).left, 0);
// Beside the bar, at the bar's height, the content takes the tap.
await tester.tapAt(Offset(rect.right + 40, rect.center.dy));
await tester.pump();
expect(taps, 1);
// On the bar, the tab takes it.
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pumpAndSettle();
expect(find.text('Chat — Not implemented'), findsOneWidget);
});
testWidgets('$host: content learns the bar height as bottom padding', (
tester,
) async {
for (final size in const [Size(390, 844), Size(1200, 800)]) {
await setSize(tester, size);
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pump();
final rect = tester.getRect(pill());
// The content's bottom padding clears the whole bar and its margin.
expect(
contentBottomPadding,
moreOrLessEquals(size.height - rect.top, epsilon: 0.5),
reason: '$size',
);
}
});
testWidgets('$host: resizing moves the bar without remounting content', (
tester,
) async {
taps = 0;
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.tap(find.byKey(const Key('content')));
await tester.pump();
expect(find.text('taps 1'), findsOneWidget);
final state = tester.state(find.byType(StatefulBuilder));
tester.view.physicalSize = const Size(1200, 800);
await tester.pump();
expect(
tester.getRect(pill()).left,
moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5),
);
expect(tester.getRect(pill()).width, lessThan(1200 * 0.6));
expect(tester.state(find.byType(StatefulBuilder)), same(state));
tester.view.physicalSize = const Size(390, 844);
await tester.pump();
await expectLabeledTargets(tester, tester.getRect(pill()));
expect(tester.getRect(pill()).width, lessThanOrEqualTo(390 - 2 * 16));
expect(tester.getRect(pill()).right, 390 - 16);
expect(tester.state(find.byType(StatefulBuilder)), same(state));
});
testWidgets('$host: the bar respects the bottom safe area', (tester) async {
await setSize(tester, const Size(390, 844));
tester.view.padding = const FakeViewPadding(bottom: 34);
await tester.pumpWidget(shell(cupertino: cupertino));
expect(tester.getRect(pill()).bottom, 844 - 34);
});
testWidgets('$host: the selected tab is marked selected for assistive '
'technology', (tester) async {
final semantics = tester.ensureSemantics();
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle();
final runs = tester.getSemantics(
find.byKey(const ValueKey('shell.destination.runs')),
);
expect(runs, isSemantics(isSelected: true));
// Captions do not duplicate the tab name for assistive technology.
expect(runs.label, startsWith('Runs'));
expect(
tester.getSemantics(
find.byKey(const ValueKey('shell.destination.chat')),
),
isNot(isSemantics(isSelected: true)),
);
semantics.dispose();
});
}
testWidgets('Cupertino bar builds no Material widget', (tester) async {
testWidgets('wide leading bar under the list, content '
'keeps the width and taps beside the bar reach it', (tester) async {
taps = 0;
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: true));
await tester.pumpWidget(shell());
final rect = tester.getRect(pill());
// With no item open the bar still sits under the list column, where it
// sits beside an open item, so it never jumps sides.
expect(rect.left, moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5));
expect(rect.bottom, 800 - 16);
expect(rect.width, lessThan(1200 * 0.6));
// Captions participate in the bar's content-driven width.
await expectLabeledTargets(tester, rect);
await expectNoSharedBackdrop(tester);
expect(
find.descendant(
of: find.byType(FloatingDestinationBar),
matching: find.byWidgetPredicate(
(widget) =>
widget is Material ||
widget is NavigationBar ||
widget is InkWell,
),
),
findsNothing,
rect.width,
lessThanOrEqualTo(listDetailListWidth(1200, 1200, null) - 2 * 16),
);
// No rail or sidebar: the content starts at the left edge.
expect(find.byType(NavigationRail), findsNothing);
expect(tester.getRect(find.byKey(const Key('content'))).left, 0);
// Beside the bar, at the bar's height, the content takes the tap.
await tester.tapAt(Offset(rect.right + 40, rect.center.dy));
await tester.pump();
expect(taps, 1);
// On the bar, the tab takes it.
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pumpAndSettle();
expect(find.text('Chat — Not implemented'), findsOneWidget);
});
testWidgets('content learns the bar height as bottom padding', (
tester,
) async {
for (final size in const [Size(390, 844), Size(1200, 800)]) {
await setSize(tester, size);
await tester.pumpWidget(shell());
await tester.pump();
final rect = tester.getRect(pill());
// The content's bottom padding clears the whole bar and its margin.
expect(
contentBottomPadding,
moreOrLessEquals(size.height - rect.top, epsilon: 0.5),
reason: '$size',
);
}
});
testWidgets('resizing moves the bar without remounting content', (
tester,
) async {
taps = 0;
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(shell());
await tester.tap(find.byKey(const Key('content')));
await tester.pump();
expect(find.text('taps 1'), findsOneWidget);
final state = tester.state(find.byType(StatefulBuilder));
tester.view.physicalSize = const Size(1200, 800);
await tester.pump();
expect(
tester.getRect(pill()).left,
moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5),
);
expect(tester.getRect(pill()).width, lessThan(1200 * 0.6));
expect(tester.state(find.byType(StatefulBuilder)), same(state));
tester.view.physicalSize = const Size(390, 844);
await tester.pump();
await expectLabeledTargets(tester, tester.getRect(pill()));
expect(tester.getRect(pill()).width, lessThanOrEqualTo(390 - 2 * 16));
expect(tester.getRect(pill()).right, 390 - 16);
expect(tester.state(find.byType(StatefulBuilder)), same(state));
});
testWidgets('the bar respects the bottom safe area', (tester) async {
await setSize(tester, const Size(390, 844));
tester.view.padding = const FakeViewPadding(bottom: 34);
await tester.pumpWidget(shell());
expect(tester.getRect(pill()).bottom, 844 - 34);
});
testWidgets('the selected tab is marked selected for assistive '
'technology', (tester) async {
final semantics = tester.ensureSemantics();
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell());
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle();
final runs = tester.getSemantics(
find.byKey(const ValueKey('shell.destination.runs')),
);
expect(runs, isSemantics(isSelected: true));
// Captions do not duplicate the tab name for assistive technology.
expect(runs.label, startsWith('Runs'));
expect(
tester.getSemantics(find.byKey(const ValueKey('shell.destination.chat'))),
isNot(isSemantics(isSelected: true)),
);
semantics.dispose();
});
testWidgets('phone at 320 with 2x text does not overflow', (tester) async {
for (final cupertino in [false, true]) {
await setSize(tester, const Size(320, 568));
tester.platformDispatcher.textScaleFactorTestValue = 2;
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
// Large captions wrap rather than shrinking the tap targets.
final bounds = tester.getRect(pill());
await expectLabeledTargets(tester, bounds);
expect(bounds.width, lessThanOrEqualTo(320 - 2 * 16));
for (final destination in shellTabDestinations) {
final caption = find.descendant(
of: find.byType(FloatingDestinationBar),
matching: find.text(destinationDetails(destination).label),
);
final text = tester.widget<Text>(caption);
final size = text.style!.fontSize!;
expect(tester.getSize(caption).height, greaterThanOrEqualTo(size * 2));
}
expect(
bounds.height,
greaterThan(
FloatingDestinationBar.selectedButtonSize(cupertino: cupertino),
),
await setSize(tester, const Size(320, 568));
tester.platformDispatcher.textScaleFactorTestValue = 2;
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
await tester.pumpWidget(shell());
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
// Large captions wrap rather than shrinking the tap targets.
final bounds = tester.getRect(pill());
await expectLabeledTargets(tester, bounds);
expect(bounds.width, lessThanOrEqualTo(320 - 2 * 16));
for (final destination in shellTabDestinations) {
final caption = find.descendant(
of: find.byType(FloatingDestinationBar),
matching: find.text(destinationDetails(destination).label),
);
expect(tester.getRect(pill()).right, 320 - 16);
final text = tester.widget<Text>(caption);
final size = text.style!.fontSize!;
expect(tester.getSize(caption).height, greaterThanOrEqualTo(size * 2));
}
expect(
bounds.height,
greaterThan(FloatingDestinationBar.selectedButtonSize(cupertino: false)),
);
expect(tester.getRect(pill()).right, 320 - 16);
});
}
+138 -155
View File
@@ -1,6 +1,5 @@
import 'dart:ui' show SemanticsAction;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -27,12 +26,10 @@ void main() {
);
Widget shell({
required bool cupertino,
required ListPaneWidthStore store,
AppDestination destination = AppDestination.runs,
}) {
final app = AdaptiveShell(
cupertino: cupertino,
destination: destination,
listPaneWidthStore: store,
destinationBodies: {
@@ -40,7 +37,7 @@ void main() {
AppDestination.chat: (_) => panes('chat'),
},
);
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
return MaterialApp(home: app);
}
Future<void> settle(WidgetTester tester) async {
@@ -66,172 +63,158 @@ void main() {
.width;
final divider = find.byKey(const ValueKey('list-detail-divider'));
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('dragging resizes the list live, the shell bar '
'follows, and the width clamps', (tester) async {
await setSize(tester, const Size(1200, 800));
final store = MemoryListPaneWidthStore();
await tester.pumpWidget(shell(store: store));
await settle(tester);
expect(listWidth(tester), kListPaneMaxWidth);
expect(shellBarWidth(tester), kListPaneMaxWidth);
testWidgets('$host: dragging resizes the list live, the shell bar '
'follows, and the width clamps', (tester) async {
await setSize(tester, const Size(1200, 800));
final store = MemoryListPaneWidthStore();
await tester.pumpWidget(shell(cupertino: cupertino, store: store));
await settle(tester);
expect(listWidth(tester), kListPaneMaxWidth);
expect(shellBarWidth(tester), kListPaneMaxWidth);
final gesture = await tester.startGesture(tester.getCenter(divider));
await gesture.moveBy(const Offset(-50, 0));
await gesture.moveBy(const Offset(-50, 0));
await tester.pump();
// Live, before the drag ends; nothing saved yet.
expect(listWidth(tester), closeTo(340, 0.5));
expect(shellBarWidth(tester), closeTo(340, 0.5));
expect(bodyWidth(tester), closeTo(1200 - 1 - 340, 0.5));
expect(store.values, isEmpty);
await gesture.up();
await tester.pump();
expect(store.values['runs'], closeTo(340, 0.5));
final gesture = await tester.startGesture(tester.getCenter(divider));
await gesture.moveBy(const Offset(-50, 0));
await gesture.moveBy(const Offset(-50, 0));
await tester.pump();
// Live, before the drag ends; nothing saved yet.
expect(listWidth(tester), closeTo(340, 0.5));
expect(shellBarWidth(tester), closeTo(340, 0.5));
expect(bodyWidth(tester), closeTo(1200 - 1 - 340, 0.5));
expect(store.values, isEmpty);
await gesture.up();
await tester.pump();
expect(store.values['runs'], closeTo(340, 0.5));
// Never narrower than the minimum...
await tester.drag(divider, const Offset(-400, 0));
await settle(tester);
expect(listWidth(tester), kListPaneMinWidth);
// ...nor wider than leaves the open item half the window.
await tester.drag(divider, const Offset(900, 0));
await settle(tester);
expect(listWidth(tester), closeTo(1200 - 1 - 600, 0.5));
expect(shellBarWidth(tester), closeTo(599, 0.5));
expect(store.values['runs'], closeTo(599, 0.5));
});
// Never narrower than the minimum...
await tester.drag(divider, const Offset(-400, 0));
await settle(tester);
expect(listWidth(tester), kListPaneMinWidth);
// ...nor wider than leaves the open item half the window.
await tester.drag(divider, const Offset(900, 0));
await settle(tester);
expect(listWidth(tester), closeTo(1200 - 1 - 600, 0.5));
expect(shellBarWidth(tester), closeTo(599, 0.5));
expect(store.values['runs'], closeTo(599, 0.5));
});
testWidgets('a double tap returns to the default policy', (tester) async {
await setSize(tester, const Size(1200, 800));
final store = MemoryListPaneWidthStore({'runs': 300});
await tester.pumpWidget(shell(store: store));
await settle(tester);
expect(listWidth(tester), 300);
testWidgets('$host: a double tap returns to the default policy', (
tester,
) async {
await setSize(tester, const Size(1200, 800));
final store = MemoryListPaneWidthStore({'runs': 300});
await tester.pumpWidget(shell(cupertino: cupertino, store: store));
await settle(tester);
expect(listWidth(tester), 300);
await tester.tap(divider);
await tester.pump(const Duration(milliseconds: 50));
await tester.tap(divider);
await settle(tester);
expect(listWidth(tester), kListPaneMaxWidth);
expect(shellBarWidth(tester), kListPaneMaxWidth);
expect(store.values, isEmpty);
});
await tester.tap(divider);
await tester.pump(const Duration(milliseconds: 50));
await tester.tap(divider);
await settle(tester);
expect(listWidth(tester), kListPaneMaxWidth);
expect(shellBarWidth(tester), kListPaneMaxWidth);
expect(store.values, isEmpty);
});
testWidgets('widths are kept per destination and restored', (tester) async {
await setSize(tester, const Size(1200, 800));
final store = MemoryListPaneWidthStore({'runs': 300, 'chat': 500});
await tester.pumpWidget(shell(store: store));
await settle(tester);
expect(listWidth(tester), 300);
expect(shellBarWidth(tester), 300);
testWidgets('$host: widths are kept per destination and restored', (
tester,
) async {
await setSize(tester, const Size(1200, 800));
final store = MemoryListPaneWidthStore({'runs': 300, 'chat': 500});
await tester.pumpWidget(shell(cupertino: cupertino, store: store));
await settle(tester);
expect(listWidth(tester), 300);
expect(shellBarWidth(tester), 300);
await tester.pumpWidget(
shell(store: store, destination: AppDestination.chat),
);
await settle(tester);
final chatList = find.byKey(const ValueKey('list-detail-list')).last;
expect(tester.getSize(chatList).width, 500);
expect(shellBarWidth(tester), 500);
await tester.pumpWidget(
shell(
cupertino: cupertino,
store: store,
destination: AppDestination.chat,
),
);
await settle(tester);
final chatList = find.byKey(const ValueKey('list-detail-list')).last;
expect(tester.getSize(chatList).width, 500);
expect(shellBarWidth(tester), 500);
// A destination nobody resized keeps the default policy.
final fresh = MemoryListPaneWidthStore({'chat': 500});
await tester.pumpWidget(const SizedBox());
await tester.pumpWidget(shell(store: fresh));
await settle(tester);
expect(listWidth(tester), kListPaneMaxWidth);
});
// A destination nobody resized keeps the default policy.
final fresh = MemoryListPaneWidthStore({'chat': 500});
await tester.pumpWidget(const SizedBox());
await tester.pumpWidget(shell(cupertino: cupertino, store: fresh));
await settle(tester);
expect(listWidth(tester), kListPaneMaxWidth);
});
testWidgets('a small window clamps the saved width without '
'overwriting it', (tester) async {
await setSize(tester, const Size(1000, 800));
final store = MemoryListPaneWidthStore({'runs': 600});
await tester.pumpWidget(shell(store: store));
await settle(tester);
expect(listWidth(tester), closeTo(1000 - 1 - 500, 0.5));
expect(shellBarWidth(tester), closeTo(499, 0.5));
expect(store.values['runs'], 600);
testWidgets('$host: a small window clamps the saved width without '
'overwriting it', (tester) async {
await setSize(tester, const Size(1000, 800));
final store = MemoryListPaneWidthStore({'runs': 600});
await tester.pumpWidget(shell(cupertino: cupertino, store: store));
await settle(tester);
expect(listWidth(tester), closeTo(1000 - 1 - 500, 0.5));
expect(shellBarWidth(tester), closeTo(499, 0.5));
expect(store.values['runs'], 600);
await setSize(tester, const Size(1600, 800));
await settle(tester);
expect(listWidth(tester), 600);
expect(shellBarWidth(tester), 600);
});
await setSize(tester, const Size(1600, 800));
await settle(tester);
expect(listWidth(tester), 600);
expect(shellBarWidth(tester), 600);
});
testWidgets('arrow keys move the divider and it reads as a '
'slider', (tester) async {
await setSize(tester, const Size(1200, 800));
final store = MemoryListPaneWidthStore();
final semantics = tester.ensureSemantics();
await tester.pumpWidget(shell(store: store));
await settle(tester);
Focus.of(tester.element(divider)).requestFocus();
await tester.pump();
testWidgets('$host: arrow keys move the divider and it reads as a '
'slider', (tester) async {
await setSize(tester, const Size(1200, 800));
final store = MemoryListPaneWidthStore();
final semantics = tester.ensureSemantics();
await tester.pumpWidget(shell(cupertino: cupertino, store: store));
await settle(tester);
Focus.of(tester.element(divider)).requestFocus();
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
await settle(tester);
expect(listWidth(tester), kListPaneMaxWidth - kListPaneDividerKeyStep);
expect(store.values['runs'], kListPaneMaxWidth - kListPaneDividerKeyStep);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
await settle(tester);
expect(listWidth(tester), kListPaneMaxWidth + kListPaneDividerKeyStep);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
await settle(tester);
expect(listWidth(tester), kListPaneMaxWidth - kListPaneDividerKeyStep);
expect(store.values['runs'], kListPaneMaxWidth - kListPaneDividerKeyStep);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
await settle(tester);
expect(listWidth(tester), kListPaneMaxWidth + kListPaneDividerKeyStep);
expect(
tester.getSemantics(divider),
matchesSemantics(
label: 'List width',
hint: 'Drag, or use the arrow keys, to resize the list',
value: '456 pixels',
increasedValue: '472 pixels',
decreasedValue: '440 pixels',
isSlider: true,
isFocusable: true,
isFocused: true,
hasIncreaseAction: true,
hasDecreaseAction: true,
hasFocusAction: true,
),
);
tester.semantics.performAction(
find.semantics.byLabel('List width'),
SemanticsAction.decrease,
);
await settle(tester);
expect(listWidth(tester), kListPaneMaxWidth);
semantics.dispose();
});
expect(
tester.getSemantics(divider),
matchesSemantics(
label: 'List width',
hint: 'Drag, or use the arrow keys, to resize the list',
value: '456 pixels',
increasedValue: '472 pixels',
decreasedValue: '440 pixels',
isSlider: true,
isFocusable: true,
isFocused: true,
hasIncreaseAction: true,
hasDecreaseAction: true,
hasFocusAction: true,
),
);
tester.semantics.performAction(
find.semantics.byLabel('List width'),
SemanticsAction.decrease,
);
await settle(tester);
expect(listWidth(tester), kListPaneMaxWidth);
semantics.dispose();
});
testWidgets('the native resize grip is visible at rest and gains '
'emphasis on focus', (tester) async {
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(store: MemoryListPaneWidthStore()));
await settle(tester);
testWidgets('$host: the native resize grip is visible at rest and gains '
'emphasis on focus', (tester) async {
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(
shell(cupertino: cupertino, store: MemoryListPaneWidthStore()),
);
await settle(tester);
AdaptiveResizeGrip grip() => tester.widget<AdaptiveResizeGrip>(
find.descendant(
of: find.byType(ListPaneDivider),
matching: find.byType(AdaptiveResizeGrip),
),
);
expect(grip().emphasized, isFalse);
AdaptiveResizeGrip grip() => tester.widget<AdaptiveResizeGrip>(
find.descendant(
of: find.byType(ListPaneDivider),
matching: find.byType(AdaptiveResizeGrip),
),
);
expect(grip().emphasized, isFalse);
Focus.of(tester.element(divider)).requestFocus();
await tester.pump();
expect(grip().emphasized, isTrue);
});
}
Focus.of(tester.element(divider)).requestFocus();
await tester.pump();
expect(grip().emphasized, isTrue);
});
test('bounds: list at least 240, open item at least half the window', () {
expect(listPaneWidthBounds(1200, 1200), (min: 240.0, max: 599.0));
+84 -98
View File
@@ -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,
+81 -88
View File
@@ -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';
@@ -6,9 +5,8 @@ import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/shell_bar.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
Widget _app({required bool cupertino, required bool open, VoidCallback? back}) {
Widget _app({required bool open, VoidCallback? back}) {
final shell = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.runs,
destinationBodies: {
AppDestination.runs: (_) => open
@@ -21,102 +19,97 @@ Widget _app({required bool cupertino, required bool open, VoidCallback? back}) {
: const Text('list'),
},
);
return cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell);
return 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();
testWidgets('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(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);
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);
});
await tester.pumpWidget(_app(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 fourth tab; Settings is not a 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(shellTabDestinations, [
AppDestination.pipelines,
AppDestination.runs,
AppDestination.chat,
AppDestination.search,
]);
expect(
find.byKey(const ValueKey('shell.destination.search')),
findsOneWidget,
);
expect(
find.byKey(const ValueKey('shell.destination.settings')),
findsNothing,
);
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
expect(find.byType(FloatingDestinationBar), findsOneWidget);
});
testWidgets('Search is the fourth tab; Settings is not a tab', (
tester,
) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(_app(open: false));
expect(AppDestination.values, hasLength(5));
expect(shellTabDestinations, [
AppDestination.pipelines,
AppDestination.runs,
AppDestination.chat,
AppDestination.search,
]);
expect(
find.byKey(const ValueKey('shell.destination.search')),
findsOneWidget,
);
expect(
find.byKey(const ValueKey('shell.destination.settings')),
findsNothing,
);
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
expect(find.byType(FloatingDestinationBar), findsOneWidget);
});
testWidgets('$host: floating tabs stay inset and select destinations', (
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));
testWidgets('floating tabs stay inset and select destinations', (
tester,
) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(_app(open: false));
final destinationPill = find.descendant(
final destinationPill = find.descendant(
of: find.byType(FloatingDestinationBar),
matching: find.byKey(FloatingDestinationBar.rowKey),
);
// Visible captions determine the width while full-size targets stay inset.
final rect = tester.getRect(destinationPill);
expect(rect.width, lessThanOrEqualTo(390 - 2 * 16));
expect(
tester
.widget<FloatingDestinationBar>(find.byType(FloatingDestinationBar))
.showLabels,
isTrue,
);
for (final destination in shellTabDestinations) {
final caption = find.descendant(
of: find.byType(FloatingDestinationBar),
matching: find.byKey(FloatingDestinationBar.rowKey),
matching: find.text(destinationDetails(destination).label),
);
// Visible captions determine the width while full-size targets stay inset.
final rect = tester.getRect(destinationPill);
expect(rect.width, lessThanOrEqualTo(390 - 2 * 16));
expect(
tester
.widget<FloatingDestinationBar>(find.byType(FloatingDestinationBar))
.showLabels,
isTrue,
expect(caption, findsOneWidget);
expect(rect.contains(tester.getRect(caption).center), isTrue);
final target = tester.getSize(
find.byKey(ValueKey('shell.destination.${destination.name}')),
);
for (final destination in shellTabDestinations) {
final caption = find.descendant(
of: find.byType(FloatingDestinationBar),
matching: find.text(destinationDetails(destination).label),
);
expect(caption, findsOneWidget);
expect(rect.contains(tester.getRect(caption).center), isTrue);
final target = tester.getSize(
find.byKey(ValueKey('shell.destination.${destination.name}')),
);
expect(target.width, greaterThanOrEqualTo(44));
expect(target.height, greaterThanOrEqualTo(44));
}
expect(tester.getRect(destinationPill).right, 390 - 16);
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pump();
expect(find.text('Chat — Not implemented'), findsOneWidget);
});
}
expect(target.width, greaterThanOrEqualTo(44));
expect(target.height, greaterThanOrEqualTo(44));
}
expect(tester.getRect(destinationPill).right, 390 - 16);
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pump();
expect(find.text('Chat — Not implemented'), findsOneWidget);
});
testWidgets('tabs show the running and unread counts their screens publish', (
tester,
+18 -27
View File
@@ -1,34 +1,25 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/shell_destination_menu.dart';
import 'package:pipelines_app/shell/destination.dart';
void main() {
for (final cupertino in [false, true]) {
testWidgets('compact menu exposes all named destinations ($cupertino)', (
tester,
) async {
AppDestination? selected;
final menu = ShellDestinationMenu(
cupertino: cupertino,
current: AppDestination.chat,
onSelected: (value) => selected = value,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: menu))
: MaterialApp(home: Scaffold(body: menu)),
);
await tester.tap(find.text('Menu'));
await tester.pumpAndSettle();
for (final name in ['Pipelines', 'Runs', 'Chat', 'Search', 'Settings']) {
expect(find.text(name), findsOneWidget);
}
await tester.tap(find.text('Runs'));
await tester.pumpAndSettle();
expect(selected, AppDestination.runs);
expect(tester.takeException(), isNull);
});
}
testWidgets('compact menu exposes all named destinations', (tester) async {
AppDestination? selected;
final menu = ShellDestinationMenu(
cupertino: false,
current: AppDestination.chat,
onSelected: (value) => selected = value,
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: menu)));
await tester.tap(find.text('Menu'));
await tester.pumpAndSettle();
for (final name in ['Pipelines', 'Runs', 'Chat', 'Search', 'Settings']) {
expect(find.text(name), findsOneWidget);
}
await tester.tap(find.text('Runs'));
await tester.pumpAndSettle();
expect(selected, AppDestination.runs);
expect(tester.takeException(), isNull);
});
}
+176 -192
View File
@@ -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';
@@ -46,11 +45,11 @@ void main() {
);
/// A detail with its own floating tabs over a list, like run detail.
Widget tabsDetail(bool cupertino) => FloatingBarOverlay(
Widget tabsDetail() => FloatingBarOverlay(
bar: KeyedSubtree(
key: const Key('detail-tabs'),
child: FloatingDestinationBar(
cupertino: cupertino,
cupertino: false,
currentIndex: 0,
onTap: (_) {},
items: const [
@@ -72,7 +71,6 @@ void main() {
);
Widget shell({
required bool cupertino,
bool split = true,
bool tabs = false,
double textScale = 1,
@@ -80,7 +78,6 @@ void main() {
AppDestination destination = AppDestination.chat,
}) {
final app = AdaptiveShell(
cupertino: cupertino,
listPaneWidthStore: store ?? MemoryListPaneWidthStore(),
destination: destination,
destinationBodies: {
@@ -88,7 +85,7 @@ void main() {
AppDestination.chat: (_) => split
? ListDetailPanes(
list: listBody(),
detail: tabs ? tabsDetail(cupertino) : composerDetail(),
detail: tabs ? tabsDetail() : composerDetail(),
)
: listBody(),
},
@@ -97,7 +94,7 @@ void main() {
data: MediaQueryData.fromView(
WidgetsBinding.instance.platformDispatcher.views.first,
).copyWith(textScaler: TextScaler.linear(textScale)),
child: cupertino ? CupertinoApp(home: app) : MaterialApp(home: app),
child: MaterialApp(home: app),
);
}
@@ -110,204 +107,191 @@ void main() {
.first,
);
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
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();
for (final width in [1200.0, 1600.0]) {
testWidgets('$host $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(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 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);
}
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');
// 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(
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('$host $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(cupertino: cupertino, 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),
matching: find.text(label),
),
findsNothing,
);
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('$host 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(cupertino: cupertino, 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));
}
});
expect(pill.right, lessThan(body.left));
testWidgets('$host 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(cupertino: cupertino, destination: AppDestination.settings),
// 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),
);
await tester.pump();
final pill = destinationPill(tester);
expect(pill.right, closeTo(1200 - kFloatingBarMargin, 0.5));
});
}
testWidgets('$host 1200 unsplit: the bar stays under the list column', (
tester,
) async {
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: cupertino, split: false));
await tester.pump();
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);
// 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('$host 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(cupertino: cupertino, 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('$host $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(cupertino: cupertino, 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));
});
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));
});
}
}
+57 -69
View File
@@ -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/features/runs/data/runs_repository.dart';
@@ -36,7 +35,7 @@ void main() {
.first,
);
Future<void> pumpSplitRun(WidgetTester tester, bool cupertino) async {
Future<void> pumpSplitRun(WidgetTester tester) async {
tester.view.physicalSize = const Size(1200, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
@@ -45,7 +44,6 @@ void main() {
addTearDown(controller.dispose);
await controller.select(77);
final shell = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.runs,
destinationBodies: {
AppDestination.runs: (_) => ListDetailPanes(
@@ -65,78 +63,68 @@ void main() {
},
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: shell)
: MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: shell,
),
MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: shell,
),
);
await tester.pumpAndSettle();
}
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('1200: run tabs float at the pane\'s bottom beside the '
'shell bar under the list, and the stage page opens in the pane', (
tester,
) async {
await pumpSplitRun(tester);
final body = tester.getRect(find.byKey(const ValueKey('list-detail-body')));
final list = tester.getRect(find.byKey(const ValueKey('list-detail-list')));
var main = shellPill(tester);
expect(main.left, closeTo(list.left + kFloatingBarMargin, 0.5));
expect(main.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
testWidgets('$host 1200: run tabs float at the pane\'s bottom beside the '
'shell bar under the list, and the stage page opens in the pane', (
final runTabs = pillOf(tester, find.byKey(const Key('run-detail-tabs')));
expect(runTabs.left, greaterThanOrEqualTo(body.left));
expect(runTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(runTabs.overlaps(main), isFalse);
expect(runTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
// Open the stage page from the timeline.
await openRunDetailTab(tester, RunDetailTab.timeline);
final row = find.byKey(const ValueKey('run-timeline-visit-1'));
await tester.ensureVisible(row);
await tester.pumpAndSettle();
await tester.tap(row);
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-back')), findsOneWidget);
// The page covers only the detail pane: the root navigator has nothing
// pushed, and the list and the shell's tab bar stay in place.
expect(
tester.state<NavigatorState>(find.byType(Navigator).first).canPop(),
isFalse,
);
expect(find.text('run row 0'), findsOneWidget);
final back = tester.getRect(find.byKey(const Key('run-visit-back')));
expect(back.left, greaterThanOrEqualTo(body.left));
main = shellPill(tester);
expect(main.left, closeTo(list.left + kFloatingBarMargin, 0.5));
final visitTabs = pillOf(
tester,
) async {
await pumpSplitRun(tester, cupertino);
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
final list = tester.getRect(
find.byKey(const ValueKey('list-detail-list')),
);
var main = shellPill(tester);
expect(main.left, closeTo(list.left + kFloatingBarMargin, 0.5));
expect(main.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
find.byKey(const Key('run-visit-tabs')).last,
);
expect(visitTabs.left, greaterThanOrEqualTo(body.left));
expect(visitTabs.overlaps(main), isFalse);
expect(visitTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
expect(tester.takeException(), isNull);
final runTabs = pillOf(tester, find.byKey(const Key('run-detail-tabs')));
expect(runTabs.left, greaterThanOrEqualTo(body.left));
expect(runTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(runTabs.overlaps(main), isFalse);
expect(runTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
// The shell's tabs still work over the open stage page.
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle();
// Open the stage page from the timeline.
await openRunDetailTab(tester, RunDetailTab.timeline);
final row = find.byKey(const ValueKey('run-timeline-visit-1'));
await tester.ensureVisible(row);
await tester.pumpAndSettle();
await tester.tap(row);
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-back')), findsOneWidget);
// The page covers only the detail pane: the root navigator has nothing
// pushed, and the list and the shell's tab bar stay in place.
expect(
tester.state<NavigatorState>(find.byType(Navigator).first).canPop(),
isFalse,
);
expect(find.text('run row 0'), findsOneWidget);
final back = tester.getRect(find.byKey(const Key('run-visit-back')));
expect(back.left, greaterThanOrEqualTo(body.left));
main = shellPill(tester);
expect(main.left, closeTo(list.left + kFloatingBarMargin, 0.5));
final visitTabs = pillOf(
tester,
find.byKey(const Key('run-visit-tabs')).last,
);
expect(visitTabs.left, greaterThanOrEqualTo(body.left));
expect(visitTabs.overlaps(main), isFalse);
expect(visitTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
expect(tester.takeException(), isNull);
// The shell's tabs still work over the open stage page.
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle();
// Back closes the page inside the pane, back to the run.
await tester.tap(find.byKey(const Key('run-visit-back')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-back')), findsNothing);
expect(find.byKey(const Key('run-detail-tabs')), findsOneWidget);
});
}
// Back closes the page inside the pane, back to the run.
await tester.tap(find.byKey(const Key('run-visit-back')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-back')), findsNothing);
expect(find.byKey(const Key('run-detail-tabs')), findsOneWidget);
});
}
+45 -56
View File
@@ -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/features/runs/data/runs_repository.dart';
@@ -18,11 +17,7 @@ import '../features/runs/ui/run_detail_visit_support.dart';
/// edge at an unfolded foldable's width and on a wide window: its content
/// spans the pane minus the page's own padding, with no reading-width cap.
void main() {
Future<void> openStagePage(
WidgetTester tester, {
required bool cupertino,
required Size size,
}) async {
Future<void> openStagePage(WidgetTester tester, {required Size size}) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
@@ -31,7 +26,6 @@ void main() {
addTearDown(controller.dispose);
await controller.select(77);
final shell = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.runs,
destinationBodies: {
AppDestination.runs: (_) => ListDetailPanes(
@@ -49,12 +43,10 @@ void main() {
},
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: shell)
: MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: shell,
),
MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: shell,
),
);
await tester.pumpAndSettle();
await openRunDetailTab(tester, RunDetailTab.timeline);
@@ -65,48 +57,45 @@ void main() {
await tester.pumpAndSettle();
}
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
for (final size in const [Size(880, 1000), Size(1400, 900)]) {
testWidgets('$host ${size.width.toInt()}: the stage page spans the '
'detail pane edge to edge', (tester) async {
await openStagePage(tester, cupertino: cupertino, size: size);
expect(find.byKey(const Key('run-visit-back')), findsOneWidget);
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
// The pane is the detail's whole share of the window, up to its
// right edge.
expect(body.right, size.width);
final pane = tester.getRect(find.byKey(const Key('run-visit-pane')));
expect(pane.left, body.left);
expect(pane.right, body.right);
// The facts block and the Input and Output sections span the whole
// pane; only the page's own padding insets their content.
final facts = tester.getRect(find.byKey(const Key('run-visit-facts')));
expect(facts.left, body.left);
expect(facts.right, body.right);
final titles = find.descendant(
of: find.byKey(const Key('run-visit-pane')),
matching: find.byType(StickySectionTitle),
);
expect(titles, findsNWidgets(2));
for (final title in tester.widgetList(titles)) {
final rect = tester.getRect(find.byWidget(title));
expect(rect.left, body.left);
expect(rect.right, body.right);
}
// The heading starts at the page padding and the chevron ends at it.
final input = tester.getRect(
find.descendant(of: titles.first, matching: find.text('Input')),
);
expect(input.left, body.left + 16);
final chevron = tester.getRect(
find.descendant(of: titles.first, matching: find.byType(Icon)).last,
);
expect(chevron.right, closeTo(body.right - 8, 0.5));
expect(tester.takeException(), isNull);
});
}
for (final size in const [Size(880, 1000), Size(1400, 900)]) {
testWidgets('${size.width.toInt()}: the stage page spans the '
'detail pane edge to edge', (tester) async {
await openStagePage(tester, size: size);
expect(find.byKey(const Key('run-visit-back')), findsOneWidget);
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
// The pane is the detail's whole share of the window, up to its
// right edge.
expect(body.right, size.width);
final pane = tester.getRect(find.byKey(const Key('run-visit-pane')));
expect(pane.left, body.left);
expect(pane.right, body.right);
// The facts block and the Input and Output sections span the whole
// pane; only the page's own padding insets their content.
final facts = tester.getRect(find.byKey(const Key('run-visit-facts')));
expect(facts.left, body.left);
expect(facts.right, body.right);
final titles = find.descendant(
of: find.byKey(const Key('run-visit-pane')),
matching: find.byType(StickySectionTitle),
);
expect(titles, findsNWidgets(2));
for (final title in tester.widgetList(titles)) {
final rect = tester.getRect(find.byWidget(title));
expect(rect.left, body.left);
expect(rect.right, body.right);
}
// The heading starts at the page padding and the chevron ends at it.
final input = tester.getRect(
find.descendant(of: titles.first, matching: find.text('Input')),
);
expect(input.left, body.left + 16);
final chevron = tester.getRect(
find.descendant(of: titles.first, matching: find.byType(Icon)).last,
);
expect(chevron.right, closeTo(body.right - 8, 0.5));
expect(tester.takeException(), isNull);
});
}
}
+89 -97
View File
@@ -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';
@@ -38,7 +37,7 @@ void main() {
/// An item publishing its bar to the pane, with its own floating tabs
/// placed where the pane says (like run and pipeline detail).
Widget tabbedItem(bool cupertino) => ShellBar(
Widget tabbedItem() => ShellBar(
title: 'Open item',
child: Builder(
builder: (context) {
@@ -48,7 +47,7 @@ void main() {
bar: KeyedSubtree(
key: const Key('item-tabs'),
child: FloatingDestinationBar(
cupertino: cupertino,
cupertino: false,
edge: edge,
currentIndex: 0,
onTap: (_) {},
@@ -71,12 +70,12 @@ void main() {
);
/// An item drawing its own header over itself (like the chat thread).
Widget overlayItem(bool cupertino) => ShellBar(
Widget overlayItem() => ShellBar(
barless: true,
child: SegmentedBarOverlay(
bar: SegmentedBar(
key: const Key('own-header'),
cupertino: cupertino,
cupertino: false,
automaticallyImplyLeading: false,
title: 'Own header',
),
@@ -84,9 +83,8 @@ void main() {
),
);
Widget shell(bool cupertino, Widget Function(bool) item) {
Widget shell(Widget item) {
final app = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.runs,
destinationBodies: {
AppDestination.runs: (_) => ListDetailPanes(
@@ -96,12 +94,12 @@ void main() {
detail: DetailPane(
destination: AppDestination.runs,
implyBack: false,
builder: (_) => item(cupertino),
builder: (_) => item,
),
),
},
);
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
return MaterialApp(home: app);
}
Iterable<Rect> pillsOf(WidgetTester tester, Finder bar) => find
@@ -112,99 +110,93 @@ void main() {
return box.localToGlobal(Offset.zero) & box.size;
});
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('split under a status bar: list and pane bars sit '
'below it, content reaches the top edge', (tester) async {
await setUp(tester, const Size(1200, 800));
await tester.pumpWidget(shell(tabbedItem()));
await tester.pump();
await tester.pump();
testWidgets('$host split under a status bar: list and pane bars sit '
'below it, content reaches the top edge', (tester) async {
await setUp(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino, tabbedItem));
await tester.pump();
await tester.pump();
final listBar = find.byWidgetPredicate(
(widget) => widget is SegmentedBar && widget.title == 'Runs',
);
final paneBar = find.byWidgetPredicate(
(widget) => widget is SegmentedBar && widget.title == 'Open item',
);
for (final bar in [listBar, paneBar]) {
final pills = pillsOf(tester, bar);
expect(pills, isNotEmpty);
for (final pill in pills) {
expect(pill.top, greaterThanOrEqualTo(statusBar));
}
}
// Content may still extend under the bars and the status bar.
expect(tester.getTopLeft(find.byKey(const Key('list'))).dy, 0);
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
// At rest (the bars' pieces have popped in) the first rows start
// below the bars.
await tester.pump(const Duration(seconds: 1));
final paneBottom = pillsOf(tester, paneBar).first.bottom;
expect(
tester.getTopLeft(find.text('item 0')).dy,
greaterThanOrEqualTo(paneBottom),
);
});
testWidgets('$host split under a status bar: a self-drawn header (chat) '
'sits below it', (tester) async {
await setUp(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino, overlayItem));
await tester.pump();
await tester.pump();
final pills = pillsOf(tester, find.byKey(const Key('own-header')));
final listBar = find.byWidgetPredicate(
(widget) => widget is SegmentedBar && widget.title == 'Runs',
);
final paneBar = find.byWidgetPredicate(
(widget) => widget is SegmentedBar && widget.title == 'Open item',
);
for (final bar in [listBar, paneBar]) {
final pills = pillsOf(tester, bar);
expect(pills, isNotEmpty);
for (final pill in pills) {
expect(pill.top, greaterThanOrEqualTo(statusBar));
}
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
});
}
// Content may still extend under the bars and the status bar.
expect(tester.getTopLeft(find.byKey(const Key('list'))).dy, 0);
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
// At rest (the bars' pieces have popped in) the first rows start
// below the bars.
await tester.pump(const Duration(seconds: 1));
final paneBottom = pillsOf(tester, paneBar).first.bottom;
expect(
tester.getTopLeft(find.text('item 0')).dy,
greaterThanOrEqualTo(paneBottom),
);
});
testWidgets('$host split: the item tabs sit at the bottom right of the '
'detail pane, the shell tab bar under the list', (tester) async {
// A gesture-navigation inset as on the unfolded foldable.
await setUp(tester, const Size(1200, 800), bottom: 24);
await tester.pumpWidget(shell(cupertino, tabbedItem));
await tester.pump();
await tester.pump();
testWidgets('split under a status bar: a self-drawn header (chat) '
'sits below it', (tester) async {
await setUp(tester, const Size(1200, 800));
await tester.pumpWidget(shell(overlayItem()));
await tester.pump();
await tester.pump();
final pills = pillsOf(tester, find.byKey(const Key('own-header')));
expect(pills, isNotEmpty);
for (final pill in pills) {
expect(pill.top, greaterThanOrEqualTo(statusBar));
}
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
});
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
final tabs = tester.getRect(
find.descendant(
of: find.byKey(const Key('item-tabs')),
matching: find.byKey(FloatingDestinationBar.rowKey),
),
);
expect(tabs.left, greaterThanOrEqualTo(body.left));
expect(tabs.right, lessThanOrEqualTo(body.right));
final shellTabs = tester.getRect(
find
.ancestor(
of: find.byKey(const ValueKey('shell.destination.runs')).first,
matching: find.byKey(FloatingDestinationBar.rowKey),
)
.first,
);
// Both bars sit above the system inset: the shell's under the list
// pane, the item's at the detail pane's trailing edge.
final listPane = tester.getRect(
find.byKey(const ValueKey('list-detail-list')),
);
expect(shellTabs.bottom, closeTo(800 - 24, 0.5));
expect(shellTabs.right, lessThanOrEqualTo(listPane.right));
expect(tabs.bottom, closeTo(800 - 24, 0.5));
expect(tabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(shellTabs.overlaps(tabs), isFalse);
// The item's list clears its tabs at rest.
final list = tester.element(find.byKey(const Key('item-list')));
expect(
MediaQuery.paddingOf(list).bottom,
greaterThanOrEqualTo(800 - tabs.top),
);
});
}
testWidgets('split: the item tabs sit at the bottom right of the '
'detail pane, the shell tab bar under the list', (tester) async {
// A gesture-navigation inset as on the unfolded foldable.
await setUp(tester, const Size(1200, 800), bottom: 24);
await tester.pumpWidget(shell(tabbedItem()));
await tester.pump();
await tester.pump();
final body = tester.getRect(find.byKey(const ValueKey('list-detail-body')));
final tabs = tester.getRect(
find.descendant(
of: find.byKey(const Key('item-tabs')),
matching: find.byKey(FloatingDestinationBar.rowKey),
),
);
expect(tabs.left, greaterThanOrEqualTo(body.left));
expect(tabs.right, lessThanOrEqualTo(body.right));
final shellTabs = tester.getRect(
find
.ancestor(
of: find.byKey(const ValueKey('shell.destination.runs')).first,
matching: find.byKey(FloatingDestinationBar.rowKey),
)
.first,
);
// Both bars sit above the system inset: the shell's under the list
// pane, the item's at the detail pane's trailing edge.
final listPane = tester.getRect(
find.byKey(const ValueKey('list-detail-list')),
);
expect(shellTabs.bottom, closeTo(800 - 24, 0.5));
expect(shellTabs.right, lessThanOrEqualTo(listPane.right));
expect(tabs.bottom, closeTo(800 - 24, 0.5));
expect(tabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(shellTabs.overlaps(tabs), isFalse);
// The item's list clears its tabs at rest.
final list = tester.element(find.byKey(const Key('item-list')));
expect(
MediaQuery.paddingOf(list).bottom,
greaterThanOrEqualTo(800 - tabs.top),
);
});
}
+84 -103
View File
@@ -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';
@@ -50,9 +49,8 @@ void main() {
),
);
Widget app({required bool cupertino, required bool split}) {
Widget app({required bool split}) {
final shell = AdaptiveShell(
cupertino: cupertino,
destinationBodies: {
AppDestination.runs: (_) => split
? ListDetailPanes(
@@ -69,9 +67,7 @@ void main() {
);
Widget margins(BuildContext context, Widget? child) =>
WindowMargins(child: child!);
return cupertino
? CupertinoApp(builder: margins, home: shell)
: MaterialApp(builder: margins, home: shell);
return MaterialApp(builder: margins, home: shell);
}
Finder pills(Finder bar) =>
@@ -94,107 +90,92 @@ void main() {
return rects.reduce((a, b) => a.expandToInclude(b));
}
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('1280: list and detail bars keep 16 px from the top '
'and every side', (tester) async {
await setSize(tester, const Size(1280, 800));
await tester.pumpWidget(app(split: true));
await tester.pump();
// The pieces pop in; measure them at rest.
await tester.pump(const Duration(seconds: 2));
testWidgets('$host 1280: list and detail bars keep 16 px from the top '
'and every side', (tester) async {
await setSize(tester, const Size(1280, 800));
await tester.pumpWidget(app(cupertino: cupertino, split: true));
await tester.pump();
// The pieces pop in; measure them at rest.
await tester.pump(const Duration(seconds: 2));
final listPane = tester.getRect(
find.byKey(const ValueKey('list-detail-list')),
);
final body = tester.getRect(find.byKey(const ValueKey('list-detail-body')));
final listBar = span(tester, shellBar);
final itemBar = span(tester, paneBar);
expect(listBar.top, closeTo(16, 0.5));
expect(listBar.left, closeTo(listPane.left + 16, 0.5));
expect(listBar.right, closeTo(listPane.right - 16, 0.5));
expect(itemBar.top, closeTo(16, 0.5));
expect(itemBar.left, closeTo(body.left + 16, 0.5));
expect(itemBar.right, closeTo(body.right - 16, 0.5));
final listPane = tester.getRect(
find.byKey(const ValueKey('list-detail-list')),
);
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
final listBar = span(tester, shellBar);
final itemBar = span(tester, paneBar);
expect(listBar.top, closeTo(16, 0.5));
expect(listBar.left, closeTo(listPane.left + 16, 0.5));
expect(listBar.right, closeTo(listPane.right - 16, 0.5));
expect(itemBar.top, closeTo(16, 0.5));
expect(itemBar.left, closeTo(body.left + 16, 0.5));
expect(itemBar.right, closeTo(body.right - 16, 0.5));
// Each pane's content still starts below its bar (and its 8 px gap)
// at rest, so nothing hides behind the taller margin.
expect(
tester.getTopLeft(find.text('list row 0')).dy,
greaterThanOrEqualTo(listBar.bottom + 8 - 0.5),
);
expect(
tester.getTopLeft(find.text('item row 0')).dy,
greaterThanOrEqualTo(itemBar.bottom + 8 - 0.5),
);
expect(tester.takeException(), isNull);
});
// Each pane's content still starts below its bar (and its 8 px gap)
// at rest, so nothing hides behind the taller margin.
expect(
tester.getTopLeft(find.text('list row 0')).dy,
greaterThanOrEqualTo(listBar.bottom + 8 - 0.5),
);
expect(
tester.getTopLeft(find.text('item row 0')).dy,
greaterThanOrEqualTo(itemBar.bottom + 8 - 0.5),
);
expect(tester.takeException(), isNull);
});
testWidgets('390: the phone keeps the bar at 8 px from the top and '
'12 px from the sides', (tester) async {
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(app(split: false));
await tester.pump();
// The pieces pop in; measure them at rest.
await tester.pump(const Duration(seconds: 2));
testWidgets('$host 390: the phone keeps the bar at 8 px from the top and '
'12 px from the sides', (tester) async {
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(app(cupertino: cupertino, split: false));
await tester.pump();
// The pieces pop in; measure them at rest.
await tester.pump(const Duration(seconds: 2));
final bar = span(tester, shellBar);
expect(bar.top, closeTo(8, 0.5));
expect(bar.left, closeTo(12, 0.5));
expect(bar.right, closeTo(390 - 12, 0.5));
expect(
tester.getTopLeft(find.text('list row 0')).dy,
greaterThanOrEqualTo(bar.bottom + 8 - 0.5),
);
expect(tester.takeException(), isNull);
});
final bar = span(tester, shellBar);
expect(bar.top, closeTo(8, 0.5));
expect(bar.left, closeTo(12, 0.5));
expect(bar.right, closeTo(390 - 12, 0.5));
expect(
tester.getTopLeft(find.text('list row 0')).dy,
greaterThanOrEqualTo(bar.bottom + 8 - 0.5),
);
expect(tester.takeException(), isNull);
});
testWidgets('1280: a pushed page\'s bar keeps the wide margins', (
tester,
) async {
await setSize(tester, const Size(1280, 800));
final bar = SegmentedBar(
cupertino: false,
title: 'Settings',
actions: const [Icon(Icons.more_vert, semanticLabel: 'More')],
);
final body = Builder(
builder: (context) => ListView(
padding: withTopBarClearance(context, EdgeInsets.zero),
children: const [SizedBox(height: 40, child: Text('first row'))],
),
);
Widget margins(BuildContext context, Widget? child) =>
WindowMargins(child: child!);
await tester.pumpWidget(
MaterialApp(
builder: margins,
home: Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: body),
),
);
await tester.pump(const Duration(seconds: 2));
testWidgets('$host 1280: a pushed page\'s bar keeps the wide margins', (
tester,
) async {
await setSize(tester, const Size(1280, 800));
final bar = SegmentedBar(
cupertino: cupertino,
title: 'Settings',
actions: const [Icon(Icons.more_vert, semanticLabel: 'More')],
);
final body = Builder(
builder: (context) => ListView(
padding: withTopBarClearance(context, EdgeInsets.zero),
children: const [SizedBox(height: 40, child: Text('first row'))],
),
);
Widget margins(BuildContext context, Widget? child) =>
WindowMargins(child: child!);
await tester.pumpWidget(
cupertino
? CupertinoApp(
builder: margins,
home: CupertinoPageScaffold(navigationBar: bar, child: body),
)
: MaterialApp(
builder: margins,
home: Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: body,
),
),
);
await tester.pump(const Duration(seconds: 2));
final pieces = span(tester, find.byType(SegmentedBar));
expect(pieces.top, closeTo(16, 0.5));
expect(pieces.left, closeTo(16, 0.5));
expect(pieces.right, closeTo(1280 - 16, 0.5));
expect(
tester.getTopLeft(find.text('first row')).dy,
closeTo(pieces.bottom + 8, 0.5),
);
expect(tester.takeException(), isNull);
});
}
final pieces = span(tester, find.byType(SegmentedBar));
expect(pieces.top, closeTo(16, 0.5));
expect(pieces.left, closeTo(16, 0.5));
expect(pieces.right, closeTo(1280 - 16, 0.5));
expect(
tester.getTopLeft(find.text('first row')).dy,
closeTo(pieces.bottom + 8, 0.5),
);
expect(tester.takeException(), isNull);
});
}
@@ -300,54 +300,48 @@ void main() {
);
expect(iconWidth(tester, 0), moreOrLessEquals(iconSize));
});
}
testWidgets('$host: switching the shell tabs never replays the main '
"bar's entrance", (tester) async {
animate(tester, on: true);
var destination = AppDestination.runs;
final shell = StatefulBuilder(
builder: (context, setState) => AdaptiveShell(
cupertino: cupertino,
destination: destination,
onDestinationSelected: (value) => setState(() => destination = value),
),
);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell),
);
await tester.pumpAndSettle();
for (final next in [
AppDestination.pipelines,
AppDestination.chat,
AppDestination.runs,
]) {
await tester.tap(
find.byKey(ValueKey('shell.destination.${next.name}')),
);
for (var frame = 0; frame < 12; frame += 1) {
await tester.pump(const Duration(milliseconds: 25));
for (final tab in shellTabDestinations) {
final finder = find.byKey(
ValueKey('shell.destination.${tab.name}'),
);
testWidgets('switching the shell tabs never replays the main '
"bar's entrance", (tester) async {
final size = FloatingDestinationBar.buttonSize(cupertino: false);
animate(tester, on: true);
var destination = AppDestination.runs;
final shell = StatefulBuilder(
builder: (context, setState) => AdaptiveShell(
destination: destination,
onDestinationSelected: (value) => setState(() => destination = value),
),
);
await tester.pumpWidget(MaterialApp(home: shell));
await tester.pumpAndSettle();
for (final next in [
AppDestination.pipelines,
AppDestination.chat,
AppDestination.runs,
]) {
await tester.tap(find.byKey(ValueKey('shell.destination.${next.name}')));
for (var frame = 0; frame < 12; frame += 1) {
await tester.pump(const Duration(milliseconds: 25));
for (final tab in shellTabDestinations) {
final finder = find.byKey(ValueKey('shell.destination.${tab.name}'));
expect(
opacityOf(tester, finder),
1,
reason: '${tab.name} faded switching to ${next.name}',
);
if (tab != next) {
// The previous selection shrinks back to its size; nothing
// pops again from 0.6.
expect(
opacityOf(tester, finder),
1,
reason: '${tab.name} faded switching to ${next.name}',
widthOf(tester, finder),
greaterThan(size * 0.9),
reason: tab.name,
);
if (tab != next) {
// The previous selection shrinks back to its size; nothing
// pops again from 0.6.
expect(
widthOf(tester, finder),
greaterThan(size * 0.9),
reason: tab.name,
);
}
}
}
await tester.pumpAndSettle();
}
});
}
await tester.pumpAndSettle();
}
});
}
-8
View File
@@ -27,12 +27,4 @@ void main() {
debugDefaultTargetPlatformOverride = null;
});
}
testWidgets('an explicit cupertino choice still builds the Cupertino host', (
tester,
) async {
await tester.pumpWidget(const MyApp(cupertino: true));
expect(find.byType(CupertinoApp), findsOneWidget);
await tester.pumpWidget(const SizedBox.shrink());
});
}
@@ -105,47 +105,42 @@ void main() {
// The actions keep to the trailing edge.
expect(pillOf(tester, find.byKey(const Key('action'))).right, 1200 - 12);
});
testWidgets('$host: a shell tab publishing a field gets it in place of '
'the title, without the Search action', (tester) async {
setSize(tester, 560);
await tester.pumpWidget(
_shellApp(
cupertino,
AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.search,
onSearch: () {},
destinationBodies: {
AppDestination.search: (_) => ShellBar(
titleWidget: field(cupertino),
titleWidgetMaxWidth: 840,
child: const SizedBox.expand(),
),
},
),
),
);
await tester.pump();
final bar = find.byType(SegmentedBar);
expect(
find.descendant(of: bar, matching: find.byKey(fieldKey)),
findsOneWidget,
);
expect(
find.descendant(of: bar, matching: find.text('Search')),
findsNothing,
);
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
// Measured at rest, after the pieces' entrance.
await tester.pump(const Duration(seconds: 1));
final pill = pillOf(tester, find.byKey(fieldKey));
expect(pill.left, 12);
expect(pill.right, 560 - 12);
});
}
}
Widget _shellApp(bool cupertino, Widget shell) =>
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell);
testWidgets('a shell tab publishing a field gets it in place of the title, '
'without the Search action', (tester) async {
setSize(tester, 560);
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destination: AppDestination.search,
onSearch: () {},
destinationBodies: {
AppDestination.search: (_) => ShellBar(
titleWidget: const TextField(key: fieldKey),
titleWidgetMaxWidth: 840,
child: const SizedBox.expand(),
),
},
),
),
);
await tester.pump();
final bar = find.byType(SegmentedBar);
expect(
find.descendant(of: bar, matching: find.byKey(fieldKey)),
findsOneWidget,
);
expect(
find.descendant(of: bar, matching: find.text('Search')),
findsNothing,
);
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
// Measured at rest, after the pieces' entrance.
await tester.pump(const Duration(seconds: 1));
final pill = pillOf(tester, find.byKey(fieldKey));
expect(pill.left, 12);
expect(pill.right, 560 - 12);
});
}
+2 -49
View File
@@ -1,9 +1,8 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/main.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
void main() {
@@ -36,52 +35,6 @@ void main() {
);
}
testWidgets('Cupertino shell uses a tab bar on a narrow window', (
tester,
) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(const MyApp(cupertino: true));
expect(find.byType(SegmentedBar), findsOneWidget);
expect(find.byType(CupertinoNavigationBar), findsNothing);
expect(find.byType(FloatingDestinationBar), findsOneWidget);
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
});
testWidgets('Cupertino shell floats its tab bar on a wide window', (
tester,
) async {
tester.view.physicalSize = const Size(1280, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(const MyApp(cupertino: true));
expect(find.byType(FloatingDestinationBar), findsOneWidget);
expect(find.byType(CupertinoListTile), findsNothing);
expect(
find.byKey(const ValueKey('shell.destination.pipelines')),
findsOneWidget,
);
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle();
expect(find.text('Runs — Not implemented'), findsOneWidget);
});
testWidgets('Cupertino content stays inside safe area', (tester) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
tester.view.padding = const FakeViewPadding(top: 36, bottom: 28);
addTearDown(tester.view.resetPadding);
await tester.pumpWidget(const MyApp(cupertino: true));
final tabBar = tester.getRect(find.byType(FloatingDestinationBar));
expect(tabBar.bottom, lessThanOrEqualTo(900 - 28));
expect(tester.takeException(), isNull);
});
testWidgets('destination state survives switching tabs', (tester) async {
var builds = 0;
await tester.pumpWidget(