Merge commit '148b3e790560f14d97c6ebfee69b0bf578c9d11d' into pipelines/run-20261111-0216-cupertino-out-templates-29f5

This commit is contained in:
2026-11-11 03:06:11 +00:00
22 changed files with 536 additions and 698 deletions
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -164,95 +163,27 @@ void main() {
expect(clamped, lessThan(panned));
});
testWidgets('320px at 2x opens and closes on the dark Cupertino host', (
tester,
) async {
tester.view.physicalSize = const Size(320, 700);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final picked = <String>[];
testWidgets('expanded Fit is an activatable labelled button', (tester) async {
await tester.pumpWidget(
CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.dark),
home: CupertinoPageScaffold(
child: Builder(
builder: (context) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: const TextScaler.linear(2)),
child: DefinitionGraphView(
graph: linearGraph(),
selectedStage: 'build',
onSelected: picked.add,
),
),
),
),
_materialHost(
graph: linearGraph(),
selected: 'build',
onSelected: (_) {},
),
);
await _settle(tester);
final inline = _inlineTransform(tester);
final inlineMatrix = Matrix4.copy(inline.value);
await tester.tap(find.byKey(const Key('graph-expand')));
await tester.pumpAndSettle();
expect(find.byType(GraphExpandedView), findsOneWidget);
final fit = tester
.getSemantics(_inExpanded(find.byKey(const Key('graph-fit'))))
.getSemanticsData();
expect(fit.label, graphFitLabel);
expect(fit.flagsCollection.isButton, isTrue);
expect(
_inExpanded(find.byType(CupertinoNavigationBarBackButton)),
findsOneWidget,
);
expect(_inExpanded(find.byKey(const Key('graph-fit'))), findsOneWidget);
expect(
tester.widget<GraphStageNode>(_inExpanded(_node('build'))).selected,
fit.hasAction(SemanticsAction.tap),
isTrue,
reason: 'Fit must expose its tap action on the labelled node',
);
expect(tester.takeException(), isNull);
await tester.tap(find.byType(CupertinoNavigationBarBackButton));
await tester.pumpAndSettle();
expect(find.byType(GraphExpandedView), findsNothing);
expect(tester.widget<GraphStageNode>(_node('build')).selected, isTrue);
expect(inline.value.storage, orderedEquals(inlineMatrix.storage));
expect(picked, isEmpty);
expect(tester.takeException(), isNull);
});
testWidgets('expanded Fit is an activatable labelled button on both hosts', (
tester,
) async {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
await tester.pumpWidget(
cupertino
? CupertinoApp(
home: CupertinoPageScaffold(
child: DefinitionGraphView(
graph: linearGraph(),
selectedStage: 'build',
onSelected: (_) {},
),
),
)
: _materialHost(
graph: linearGraph(),
selected: 'build',
onSelected: (_) {},
),
);
await _settle(tester);
await tester.tap(find.byKey(const Key('graph-expand')));
await tester.pumpAndSettle();
final fit = tester
.getSemantics(_inExpanded(find.byKey(const Key('graph-fit'))))
.getSemanticsData();
expect(fit.label, graphFitLabel, reason: '$host Fit must be labelled');
expect(fit.flagsCollection.isButton, isTrue);
expect(
fit.hasAction(SemanticsAction.tap),
isTrue,
reason: '$host Fit must expose its tap action on the labelled node',
);
}
});
}
@@ -7,101 +7,79 @@ import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'graph_viewport_fixtures.dart';
void main() {
testWidgets('Fit and Expand stay labelled, activatable buttons on both hosts', (
testWidgets('Fit and Expand stay labelled, activatable buttons', (
tester,
) async {
for (final cupertino in [false, true]) {
final host = cupertino ? 'cupertino' : 'material';
final controller = GraphViewportController();
addTearDown(controller.dispose);
var expands = 0;
await tester.pumpWidget(
viewportHost(
controller: controller,
child: viewportTargets([]),
cupertino: cupertino,
onExpand: () => expands += 1,
),
);
await settleViewport(tester);
final fitted = controller.snapshot;
expect(
find.ancestor(
of: find.byKey(const Key('graph-fit')),
matching: find.byType(GlassPill),
),
findsOneWidget,
);
final controller = GraphViewportController();
addTearDown(controller.dispose);
var expands = 0;
await tester.pumpWidget(
viewportHost(
controller: controller,
child: viewportTargets([]),
onExpand: () => expands += 1,
),
);
await settleViewport(tester);
final fitted = controller.snapshot;
expect(
find.ancestor(
of: find.byKey(const Key('graph-fit')),
matching: find.byType(GlassPill),
),
findsOneWidget,
);
for (final control in viewportControls().entries) {
final node = tester.getSemantics(find.byKey(control.key));
final data = node.getSemanticsData();
expect(
data.label,
control.value,
reason: '$host ${control.key} must have the web name',
);
expect(
data.flagsCollection.isButton,
isTrue,
reason: '$host ${control.key} must be announced as a button',
);
// A labelled button with no action is unusable with VoiceOver/TalkBack;
// this is the regression the excluded-button wrapper introduced.
expect(
data.hasAction(SemanticsAction.tap),
isTrue,
reason: '$host ${control.key} must expose a tap action',
);
}
// The exposed action must run the real callback, not just be announced.
await pinchViewport(tester, const Offset(200, 150), 2);
await tester.pumpAndSettle();
expect(controller.snapshot, isNot(fitted));
performViewportTap(tester, find.byKey(const Key('graph-fit')));
await tester.pump();
expect(controller.scale, closeTo(fitted.scale, 1e-9));
performViewportTap(tester, find.byKey(const Key('graph-expand')));
await tester.pump();
expect(expands, 1, reason: '$host Expand must activate');
for (final control in viewportControls().entries) {
final node = tester.getSemantics(find.byKey(control.key));
final data = node.getSemanticsData();
expect(data.label, control.value);
expect(data.flagsCollection.isButton, isTrue);
// A labelled button with no action is unusable with a screen reader;
// this is the regression the excluded-button wrapper introduced.
expect(data.hasAction(SemanticsAction.tap), isTrue);
}
// The exposed action must run the real callback, not just be announced.
await pinchViewport(tester, const Offset(200, 150), 2);
await tester.pumpAndSettle();
expect(controller.snapshot, isNot(fitted));
performViewportTap(tester, find.byKey(const Key('graph-fit')));
await tester.pump();
expect(controller.scale, closeTo(fitted.scale, 1e-9));
performViewportTap(tester, find.byKey(const Key('graph-expand')));
await tester.pump();
expect(expands, 1);
});
testWidgets('320px at 2x keeps native controls and gestures on both hosts', (
tester,
) async {
for (final cupertino in [false, true]) {
final controller = GraphViewportController();
addTearDown(controller.dispose);
await tester.pumpWidget(
viewportHost(
controller: controller,
child: viewportTargets([]),
cupertino: cupertino,
dark: cupertino,
textScale: 2,
viewport: const Size(320, 300),
onExpand: () {},
),
);
await settleViewport(tester);
expect(find.byKey(const Key('graph-fit')), findsOneWidget);
expect(find.byKey(const Key('graph-expand')), findsOneWidget);
expect(tester.takeException(), isNull);
testWidgets('320px at 2x keeps native controls and gestures', (tester) async {
final controller = GraphViewportController();
addTearDown(controller.dispose);
await tester.pumpWidget(
viewportHost(
controller: controller,
child: viewportTargets([]),
textScale: 2,
viewport: const Size(320, 300),
onExpand: () {},
),
);
await settleViewport(tester);
expect(find.byKey(const Key('graph-fit')), findsOneWidget);
expect(find.byKey(const Key('graph-expand')), findsOneWidget);
expect(tester.takeException(), isNull);
final before = controller.offset;
await dragViewport(
tester,
find.byKey(const Key('graph-viewport')),
const Offset(-30, -10),
);
expect(controller.offset, isNot(before));
await pinchViewport(tester, const Offset(160, 150), 2);
await tester.pumpAndSettle();
expect(controller.scale, greaterThan(0.3));
expect(tester.takeException(), isNull);
}
final before = controller.offset;
await dragViewport(
tester,
find.byKey(const Key('graph-viewport')),
const Offset(-30, -10),
);
expect(controller.offset, isNot(before));
await pinchViewport(tester, const Offset(160, 150), 2);
await tester.pumpAndSettle();
expect(controller.scale, greaterThan(0.3));
expect(tester.takeException(), isNull);
});
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -48,7 +47,6 @@ Widget viewportHost({
required GraphViewportController controller,
required Widget child,
VoidCallback? onExpand,
bool cupertino = false,
bool dark = false,
double textScale = 1,
Size viewport = defaultViewportSize,
@@ -65,14 +63,6 @@ Widget viewportHost({
),
),
);
if (cupertino) {
return CupertinoApp(
theme: CupertinoThemeData(
brightness: dark ? Brightness.dark : Brightness.light,
),
home: CupertinoPageScaffold(child: Center(child: graph)),
);
}
return MaterialApp(
theme: dark ? ThemeData.dark() : ThemeData.light(),
home: Scaffold(body: Center(child: graph)),
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -57,21 +56,6 @@ Widget _materialHost(
);
}
Widget _cupertinoHost(JsonMap graph, {ValueChanged<String>? onSelected}) {
return CupertinoApp(
home: CupertinoPageScaffold(
child: SizedBox(
width: 900,
height: 700,
child: DefinitionGraphView(
graph: graph,
onSelected: onSelected ?? (_) {},
),
),
),
);
}
/// Settles the two-frame measure-then-place contract.
Future<void> _settle(WidgetTester tester) async {
await tester.pump();
@@ -315,27 +299,4 @@ void main() {
expect(find.byType(GraphStageNode), findsNothing);
expect(find.byType(InteractiveViewer), findsNothing);
});
testWidgets('cupertino host composes native buttons and keeps identity', (
tester,
) async {
final picked = <String>[];
await tester.pumpWidget(
_cupertinoHost(linearGraph(), onSelected: picked.add),
);
await _settle(tester);
expect(
find.descendant(
of: find.byType(GraphStageNode),
matching: find.byType(CupertinoButton),
),
findsNWidgets(5),
);
expect(find.byType(Card), findsNothing);
_expectNoOverlaps(tester);
await _tapNode(tester, '#failure');
expect(picked, ['#failure']);
});
}
@@ -1,7 +1,6 @@
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -21,10 +20,6 @@ Widget _material(Widget child) => MaterialApp(
home: Scaffold(body: Center(child: child)),
);
Widget _cupertino(Widget child) => CupertinoApp(
home: CupertinoPageScaffold(child: Center(child: child)),
);
/// The node centred on an opaque page, inside its own repaint boundary so the
/// painted result can be read back as pixels.
Widget _framed(Key key, Widget Function(Widget) wrap, Widget child) => wrap(
@@ -153,58 +148,27 @@ void main() {
}
});
testWidgets('unselected cupertino node paints a visible container', (
tester,
) async {
final key = GlobalKey();
await tester.pumpWidget(
_framed(
key,
_cupertino,
GraphStageNode(node: _stage, onSelected: (_) {}),
),
);
final shot = await _shot(tester, key);
final rect = tester.getRect(find.byType(CupertinoButton));
// Just inside the left edge of the control, clear of the label's inset.
final body = shot.at(rect.centerLeft + const Offset(4, 0));
final page = shot.at(const Offset(4, 4));
expect(
_distance(body, page),
greaterThan(24),
reason: 'an unselected cupertino node needs its own visible surface',
);
});
testWidgets('selected state changes the painted surface in both hosts', (
tester,
) async {
for (final wrap in [_material, _cupertino]) {
final colors = <bool, Color>{};
for (final selected in [false, true]) {
final key = GlobalKey();
await tester.pumpWidget(
_framed(
key,
wrap,
GraphStageNode(
node: _stage,
selected: selected,
onSelected: (_) {},
),
),
);
final shot = await _shot(tester, key);
final rect = tester.getRect(find.byType(GraphStageNode));
colors[selected] = shot.at(rect.centerLeft + const Offset(4, 0));
}
expect(
_distance(colors[false]!, colors[true]!),
greaterThan(16),
reason:
'selection must be visible, not only announced: the surface fill '
'and the outlined border change together',
testWidgets('selected state changes the painted surface', (tester) async {
final colors = <bool, Color>{};
for (final selected in [false, true]) {
final key = GlobalKey();
await tester.pumpWidget(
_framed(
key,
_material,
GraphStageNode(node: _stage, selected: selected, onSelected: (_) {}),
),
);
final shot = await _shot(tester, key);
final rect = tester.getRect(find.byType(GraphStageNode));
colors[selected] = shot.at(rect.centerLeft + const Offset(4, 0));
}
expect(
_distance(colors[false]!, colors[true]!),
greaterThan(16),
reason:
'selection must be visible, not only announced: the surface fill '
'and the outlined border change together',
);
});
}
@@ -1,6 +1,5 @@
import 'dart:ui' show Tristate;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
@@ -17,10 +16,6 @@ Widget _material(Widget child) => MaterialApp(
home: Scaffold(body: Center(child: child)),
);
Widget _cupertino(Widget child) => CupertinoApp(
home: CupertinoPageScaffold(child: Center(child: child)),
);
/// Applies a 2x text scale below the app so the fixture renders as a real
/// scale-2 layout rather than a test-only text property.
Widget _scaled(Widget child) => Builder(
@@ -65,9 +60,7 @@ void main() {
expect(_semantics(tester).label, 'Success');
});
testWidgets('selected node is announced selected in both native hosts', (
tester,
) async {
testWidgets('selected node is announced selected', (tester) async {
await tester.pumpWidget(
_material(
GraphStageNode(node: _stage, selected: true, onSelected: (_) {}),
@@ -76,15 +69,6 @@ void main() {
expect(find.byType(Card), findsOneWidget);
expect(find.byType(InkWell), findsOneWidget);
_expectSelectable(tester, selected: true);
await tester.pumpWidget(
_cupertino(
GraphStageNode(node: _stage, selected: true, onSelected: (_) {}),
),
);
expect(find.byType(CupertinoButton), findsOneWidget);
expect(find.byType(Card), findsNothing);
_expectSelectable(tester, selected: true);
});
testWidgets('unselected node is not announced selected', (tester) async {
@@ -96,17 +80,15 @@ void main() {
});
testWidgets('keyboard activation selects the node', (tester) async {
for (final wrap in [_material, _cupertino]) {
final picked = <String>[];
await tester.pumpWidget(
wrap(GraphStageNode(node: _stage, onSelected: picked.add)),
);
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.pumpAndSettle();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(picked, ['build']);
}
final picked = <String>[];
await tester.pumpWidget(
_material(GraphStageNode(node: _stage, onSelected: picked.add)),
);
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.pumpAndSettle();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(picked, ['build']);
});
testWidgets('keyboard selection keeps focus inside the material node', (
@@ -144,46 +126,44 @@ void main() {
) async {
const label = 'implementer-with-an-unshortened-stage-label';
const node = GraphNode(key: label, terminal: false, stageIndex: 0);
for (final wrap in [_material, _cupertino]) {
await tester.pumpWidget(
wrap(
_scaled(
SizedBox(
width: 150,
child: GraphStageNode(node: node, onSelected: (_) {}),
),
await tester.pumpWidget(
_material(
_scaled(
SizedBox(
width: 150,
child: GraphStageNode(node: node, onSelected: (_) {}),
),
),
);
),
);
expect(tester.takeException(), isNull);
final text = tester.widget<Text>(_visual(label));
expect(text.data!.replaceAll('\u200B', ''), label);
expect(text.maxLines, isNull);
expect(text.overflow, isNull);
final paragraph = tester.renderObject<RenderParagraph>(_visual(label));
expect(paragraph.size.width, lessThanOrEqualTo(150));
expect(
paragraph.size.height,
greaterThan(50),
reason: 'the 2x label must occupy more than one 2x text line',
);
// No glyph may paint outside the paragraph: every laid-out line,
// including a hyphen-broken segment, fits the width the control gave it.
final painter = TextPainter(
text: paragraph.text,
textDirection: paragraph.textDirection,
textScaler: paragraph.textScaler,
textAlign: paragraph.textAlign,
)..layout(maxWidth: paragraph.size.width);
expect(
painter.computeLineMetrics().every(
(line) => line.width <= paragraph.size.width + 0.5,
),
isTrue,
reason: 'an unshortened label must wrap, not paint over the control',
);
}
expect(tester.takeException(), isNull);
final text = tester.widget<Text>(_visual(label));
expect(text.data!.replaceAll('\u200B', ''), label);
expect(text.maxLines, isNull);
expect(text.overflow, isNull);
final paragraph = tester.renderObject<RenderParagraph>(_visual(label));
expect(paragraph.size.width, lessThanOrEqualTo(150));
expect(
paragraph.size.height,
greaterThan(50),
reason: 'the 2x label must occupy more than one 2x text line',
);
// No glyph may paint outside the paragraph: every laid-out line,
// including a hyphen-broken segment, fits the width the control gave it.
final painter = TextPainter(
text: paragraph.text,
textDirection: paragraph.textDirection,
textScaler: paragraph.textScaler,
textAlign: paragraph.textAlign,
)..layout(maxWidth: paragraph.size.width);
expect(
painter.computeLineMetrics().every(
(line) => line.width <= paragraph.size.width + 0.5,
),
isTrue,
reason: 'an unshortened label must wrap, not paint over the control',
);
});
testWidgets('terminal shows its definition label and no invented status', (
@@ -207,7 +187,7 @@ void main() {
testWidgets('a recorded status is shown verbatim', (tester) async {
await tester.pumpWidget(
_cupertino(
_material(
GraphStageNode(
node: _stage,
recordedStatus: 'failed',
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -113,35 +112,6 @@ Widget _materialHost(
);
}
Widget _cupertinoHost(
JsonMap graph,
JsonMap run, {
ValueChanged<String>? onSelected,
double scale = 1,
}) {
return CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.dark),
home: CupertinoPageScaffold(
child: Builder(
builder: (context) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(scale)),
child: SizedBox(
width: 320,
height: 700,
child: RunGraphView(
graph: graph,
run: run,
onStageSelected: onSelected ?? (_) {},
),
),
),
),
),
);
}
Future<void> _settle(WidgetTester tester) async {
await tester.pump();
await tester.pump();
@@ -450,39 +420,4 @@ void main() {
_expectNoOverlaps(tester);
expect(tester.takeException(), isNull);
});
testWidgets('dark Cupertino host keeps native nodes and evidence', (
tester,
) async {
final picked = <String>[];
await tester.pumpWidget(
_cupertinoHost(linearGraph(), _runningRun(), onSelected: picked.add),
);
await _settle(tester);
expect(find.byType(Card), findsNothing);
expect(
find.descendant(
of: find.byType(GraphStageNode),
matching: find.byType(CupertinoButton),
),
findsNWidgets(5),
);
expect(find.text(runGraphExecuted), findsOneWidget);
expect(find.text(runGraphNotExecuted), findsOneWidget);
expect(
tester.widget<GraphStageNode>(_node('plan')).recordedStatus,
'completed',
);
expect(
tester.widget<GraphStageNode>(_node('build')).recordedStatus,
'running',
);
_expectNoOverlaps(tester);
await tester.tap(_node('plan'));
await tester.pump();
expect(picked, ['plan']);
expect(tester.takeException(), isNull);
});
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -37,13 +36,6 @@ Widget _material(Widget child) => MaterialApp(
),
);
Widget _cupertino(Widget child, {bool dark = false}) => CupertinoApp(
theme: CupertinoThemeData(
brightness: dark ? Brightness.dark : Brightness.light,
),
home: CupertinoPageScaffold(child: child),
);
StageDefinitionView _view({String key = 'plan'}) => StageDefinitionView(
graph: _graph(),
stageKey: key,
@@ -138,26 +130,6 @@ void main() {
expect(_text('successful'), findsNothing);
});
testWidgets('Cupertino uses its theme roles in dark mode', (tester) async {
late Color secondary;
await tester.pumpWidget(
_cupertino(
Builder(
builder: (context) {
secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
return _view();
},
),
dark: true,
),
);
final identity = tester.widget<Text>(_text('Demo pipeline · v7'));
expect(identity.style?.color, secondary);
expect(_text('Plan the change.'), findsOneWidget);
expect(tester.takeException(), isNull);
});
testWidgets('the Material helper opens one bar and Back closes it', (
tester,
) async {
@@ -198,44 +170,6 @@ void main() {
expect(find.byType(StageDefinitionView), findsNothing);
});
testWidgets('the Cupertino helper opens one native bar and Back closes it', (
tester,
) async {
await tester.pumpWidget(
CupertinoApp(
home: Builder(
builder: (context) => CupertinoPageScaffold(
child: CupertinoButton(
onPressed: () => openStageDefinition(
context,
graph: _graph(),
stageKey: '#success',
pipelineId: 41,
pipelineName: 'Demo pipeline',
version: 7,
),
child: const Text('Open terminal'),
),
),
),
),
);
await tester.tap(find.text('Open terminal'));
await tester.pumpAndSettle();
expect(_text('Success definition'), findsOneWidget);
expect(_text('#success definition'), findsNothing);
expect(find.byType(SegmentedBar), findsOneWidget);
expect(find.byType(CupertinoNavigationBarBackButton), findsOneWidget);
expect(_text('Incoming routes'), findsOneWidget);
await tester.tap(find.byType(CupertinoNavigationBarBackButton));
await tester.pumpAndSettle();
expect(_text('Open terminal'), findsOneWidget);
expect(find.byType(StageDefinitionView), findsNothing);
});
testWidgets('the Material helper titles a terminal with its display label', (
tester,
) async {
@@ -270,7 +204,11 @@ void main() {
testWidgets('selectable blocks force the host strut for one line rhythm', (
tester,
) async {
await tester.pumpWidget(_cupertino(_view()));
// Tall enough that the raw section below the prompt is built.
tester.view.physicalSize = const Size(800, 2000);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(_material(_view()));
final selectable = tester
.widgetList<SelectableText>(find.byType(SelectableText))