diff --git a/app/lib/features/graph/viewport/graph_expanded_view.dart b/app/lib/features/graph/viewport/graph_expanded_view.dart index 9efa09bc..012196d7 100644 --- a/app/lib/features/graph/viewport/graph_expanded_view.dart +++ b/app/lib/features/graph/viewport/graph_expanded_view.dart @@ -1,8 +1,6 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../ui/adaptive/segmented_bar.dart'; -import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; import 'graph_viewport.dart'; import 'graph_viewport_controller.dart'; @@ -100,23 +98,6 @@ class _GraphExpandedViewState extends State { Expanded(child: viewport), ], ); - if (usesCupertinoHost(context)) { - return CupertinoPageScaffold( - navigationBar: SegmentedBar( - cupertino: true, - automaticallyImplyLeading: false, - leading: SegmentedBackButton(cupertino: true, onPressed: _close), - title: widget.title, - actions: [ - _GraphFitButton( - cupertino: true, - onPressed: _controller.fitToViewport, - ), - ], - ), - child: BelowTopBar(child: body), - ); - } return Scaffold( extendBodyBehindAppBar: true, appBar: SegmentedBar( @@ -124,12 +105,7 @@ class _GraphExpandedViewState extends State { title: widget.title, automaticallyImplyLeading: false, leading: SegmentedBackButton(cupertino: false, onPressed: _close), - actions: [ - _GraphFitButton( - cupertino: false, - onPressed: _controller.fitToViewport, - ), - ], + actions: [_GraphFitButton(onPressed: _controller.fitToViewport)], ), body: BelowTopBar(child: body), ); @@ -137,9 +113,8 @@ class _GraphExpandedViewState extends State { } class _GraphFitButton extends StatelessWidget { - const _GraphFitButton({required this.cupertino, required this.onPressed}); + const _GraphFitButton({required this.onPressed}); - final bool cupertino; final VoidCallback onPressed; @override @@ -147,22 +122,15 @@ class _GraphFitButton extends StatelessWidget { child: Semantics( button: true, label: graphFitLabel, - child: cupertino - ? CupertinoButton( - key: const Key('graph-fit'), - padding: const EdgeInsets.all(8), - onPressed: onPressed, - child: const ExcludeSemantics(child: Icon(CupertinoIcons.resize)), - ) - : Tooltip( - message: graphFitLabel, - excludeFromSemantics: true, - child: IconButton( - key: const Key('graph-fit'), - onPressed: onPressed, - icon: const ExcludeSemantics(child: Icon(Icons.fit_screen)), - ), - ), + child: Tooltip( + message: graphFitLabel, + excludeFromSemantics: true, + child: IconButton( + key: const Key('graph-fit'), + onPressed: onPressed, + icon: const ExcludeSemantics(child: Icon(Icons.fit_screen)), + ), + ), ), ); } @@ -190,8 +158,9 @@ Future openGraphExpanded( selectedStage: selectedStage, header: header, ); - final route = usesCupertinoHost(context) - ? CupertinoPageRoute(fullscreenDialog: true, builder: (_) => page) - : MaterialPageRoute(fullscreenDialog: true, builder: (_) => page); + final route = MaterialPageRoute( + fullscreenDialog: true, + builder: (_) => page, + ); return Navigator.of(context).push(route); } diff --git a/app/lib/features/graph/viewport/graph_viewport.dart b/app/lib/features/graph/viewport/graph_viewport.dart index 071b432d..787741fd 100644 --- a/app/lib/features/graph/viewport/graph_viewport.dart +++ b/app/lib/features/graph/viewport/graph_viewport.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/glass_pill.dart'; import 'graph_viewport_controller.dart'; @@ -121,20 +119,20 @@ class _GraphViewportState extends State { top: 8, end: 8, child: GlassPill( - cupertino: usesCupertinoHost(context), + cupertino: false, child: Wrap( spacing: 2, children: [ _ViewportButton( buttonKey: const Key('graph-fit'), - icon: _fitIcon(context), + icon: Icons.fit_screen, label: graphFitLabel, onPressed: widget.controller.fitToViewport, ), if (widget.onExpand != null) _ViewportButton( buttonKey: const Key('graph-expand'), - icon: _expandIcon(context), + icon: Icons.fullscreen, label: graphExpandLabel, onPressed: widget.onExpand, ), @@ -147,12 +145,6 @@ class _GraphViewportState extends State { }, ); } - - IconData _fitIcon(BuildContext context) => - usesCupertinoHost(context) ? CupertinoIcons.resize : Icons.fit_screen; - - IconData _expandIcon(BuildContext context) => - usesCupertinoHost(context) ? CupertinoIcons.fullscreen : Icons.fullscreen; } /// One native graph control inside the shared floating glass pill. @@ -160,7 +152,7 @@ class _GraphViewportState extends State { /// The label and the button's own tap action must reach the same semantics /// node: the icon is the only excluded child, and [MergeSemantics] folds the /// host button's action into the labelled node, so a screen reader can activate -/// Fit and Expand on either host. A hand-written `Semantics` sibling around an +/// Fit and Expand. A hand-written `Semantics` sibling around an /// excluded button would announce the control with no action at all. class _ViewportButton extends StatelessWidget { const _ViewportButton({ @@ -181,24 +173,17 @@ class _ViewportButton extends StatelessWidget { child: Semantics( button: true, label: label, - child: usesCupertinoHost(context) - ? CupertinoButton( - key: buttonKey, - padding: const EdgeInsets.all(8), - onPressed: onPressed, - child: ExcludeSemantics(child: Icon(icon)), - ) - : Tooltip( - message: label, - // The merged node already carries the label; the tooltip is - // only the pointer affordance. - excludeFromSemantics: true, - child: IconButton( - key: buttonKey, - onPressed: onPressed, - icon: ExcludeSemantics(child: Icon(icon)), - ), - ), + child: Tooltip( + message: label, + // The merged node already carries the label; the tooltip is + // only the pointer affordance. + excludeFromSemantics: true, + child: IconButton( + key: buttonKey, + onPressed: onPressed, + icon: ExcludeSemantics(child: Icon(icon)), + ), + ), ), ); } diff --git a/app/lib/features/graph/widgets/definition_graph_view.dart b/app/lib/features/graph/widgets/definition_graph_view.dart index c1285fb5..7eed93ee 100644 --- a/app/lib/features/graph/widgets/definition_graph_view.dart +++ b/app/lib/features/graph/widgets/definition_graph_view.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; diff --git a/app/lib/features/graph/widgets/graph_canvas_style.dart b/app/lib/features/graph/widgets/graph_canvas_style.dart index b4c97ef6..03347dce 100644 --- a/app/lib/features/graph/widgets/graph_canvas_style.dart +++ b/app/lib/features/graph/widgets/graph_canvas_style.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import '../layout/layout_models.dart'; import '../routing/route_models.dart'; @@ -32,9 +30,9 @@ RoutingConfig graphCanvasRoutingConfig() => RoutingConfig( /// The native theme roles one definition graph canvas needs. /// /// No palette, font family or size is defined here: every value comes from the -/// ambient Material or Cupertino theme, so light/dark and text scaling follow -/// the host exactly. Edge labels and diagnostics are metadata, so they use the -/// host's secondary-label role rather than the node's own label style. +/// ambient Material theme, so light/dark and text scaling follow the host +/// exactly. Edge labels and diagnostics are metadata, so they use the host's +/// secondary-label role rather than the node's own label style. class GraphCanvasStyle { const GraphCanvasStyle({ required this.labelStyle, @@ -44,20 +42,6 @@ class GraphCanvasStyle { }); factory GraphCanvasStyle.of(BuildContext context) { - if (usesCupertinoHost(context)) { - final theme = CupertinoTheme.of(context); - final secondary = CupertinoColors.secondaryLabel.resolveFrom(context); - return GraphCanvasStyle( - labelStyle: theme.textTheme.tabLabelTextStyle.copyWith( - color: secondary, - ), - messageStyle: theme.textTheme.textStyle.copyWith(color: secondary), - edgeColor: CupertinoColors.separator.resolveFrom(context), - // Cupertino has no divider-thickness token; its separators are one - // logical pixel hairlines, so the stroke keeps that native default. - edgeWidth: 1, - ); - } final theme = Theme.of(context); final secondary = theme.colorScheme.onSurfaceVariant; return GraphCanvasStyle( diff --git a/app/lib/features/graph/widgets/graph_stage_node.dart b/app/lib/features/graph/widgets/graph_stage_node.dart index c72ebbd3..2cbf7667 100644 --- a/app/lib/features/graph/widgets/graph_stage_node.dart +++ b/app/lib/features/graph/widgets/graph_stage_node.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import '../../../ui/status/run_status_icon.dart'; import '../domain/graph_definition.dart'; @@ -37,7 +35,7 @@ class GraphStageNode extends StatelessWidget { /// Reports [node.key] exactly as the definition recorded it. final ValueChanged onSelected; - /// Content inset shared by both hosts. It is spacing, not a size: the control + /// Content inset for a graph node. It is spacing, not a size: the control /// still takes its size from its label, and the inset keeps wrapped glyphs /// clear of a rounded surface's corners. static const EdgeInsets _contentPadding = EdgeInsets.all(16); @@ -61,9 +59,7 @@ class GraphStageNode extends StatelessWidget { button: true, selected: selected, label: _label, - child: usesCupertinoHost(context) - ? _cupertinoButton(onPressed, content) - : _materialCard(onPressed, content), + child: _materialCard(onPressed, content), ), ); return active ? StageActivityHalo(child: control) : control; @@ -106,12 +102,6 @@ class GraphStageNode extends StatelessWidget { ); } - /// Tinted is Cupertino's stock low-emphasis surface, so an unselected node is - /// still a visible node body; filled raises the selected one. - Widget _cupertinoButton(VoidCallback onPressed, Widget content) => selected - ? CupertinoButton.filled(onPressed: onPressed, child: content) - : CupertinoButton.tinted(onPressed: onPressed, child: content); - Widget _content(BuildContext context) { final status = _status; // The recorded status reads apart from the name: a coloured dot and @@ -215,10 +205,7 @@ class _StageActivityHaloState extends State @override Widget build(BuildContext context) { - final cupertino = usesCupertinoHost(context); - final color = cupertino - ? CupertinoTheme.of(context).primaryColor - : Theme.of(context).colorScheme.primary; + final color = Theme.of(context).colorScheme.primary; return AnimatedBuilder( animation: _controller, builder: (context, child) => CustomPaint( diff --git a/app/lib/features/graph/widgets/run_graph_canvas.dart b/app/lib/features/graph/widgets/run_graph_canvas.dart index 953bb2ba..113a3f1b 100644 --- a/app/lib/features/graph/widgets/run_graph_canvas.dart +++ b/app/lib/features/graph/widgets/run_graph_canvas.dart @@ -1,8 +1,6 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart' show listEquals; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import '../domain/graph_definition.dart'; import '../domain/run_graph_state.dart'; import '../layout/layout_models.dart'; @@ -200,10 +198,7 @@ class RunGraphCanvas extends StatelessWidget { final executedIds = {for (final route in executed) route.id}; final size = Size(routing.width, routing.height); final activeStage = state.activeStage; - final cupertino = usesCupertinoHost(context); - final executedColor = cupertino - ? CupertinoTheme.of(context).primaryColor - : Theme.of(context).colorScheme.primary; + final executedColor = Theme.of(context).colorScheme.primary; return Stack( clipBehavior: Clip.none, children: [ diff --git a/app/lib/features/graph/widgets/run_graph_header.dart b/app/lib/features/graph/widgets/run_graph_header.dart index ac7af652..ef0181bf 100644 --- a/app/lib/features/graph/widgets/run_graph_header.dart +++ b/app/lib/features/graph/widgets/run_graph_header.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import '../domain/run_graph_state.dart'; import 'graph_canvas_style.dart'; @@ -31,10 +29,7 @@ class RunGraphHeader extends StatelessWidget { @override Widget build(BuildContext context) { - final cupertino = usesCupertinoHost(context); - final executedColor = cupertino - ? CupertinoTheme.of(context).primaryColor - : Theme.of(context).colorScheme.primary; + final executedColor = Theme.of(context).colorScheme.primary; final mutedColor = style.edgeColor; final active = state.activeStage; return Padding( @@ -53,14 +48,12 @@ class RunGraphHeader extends StatelessWidget { crossAxisAlignment: WrapCrossAlignment.center, children: [ _LegendEntry( - icon: cupertino - ? CupertinoIcons.arrow_right - : Icons.arrow_forward, + icon: Icons.arrow_forward, label: runGraphExecuted, color: executedColor, ), _LegendEntry( - icon: cupertino ? CupertinoIcons.minus : Icons.remove, + icon: Icons.remove, label: runGraphNotExecuted, color: mutedColor, ), diff --git a/app/lib/features/graph/widgets/stage_definition_view.dart b/app/lib/features/graph/widgets/stage_definition_view.dart index 3244d9e9..42ba6dc9 100644 --- a/app/lib/features/graph/widgets/stage_definition_view.dart +++ b/app/lib/features/graph/widgets/stage_definition_view.dart @@ -1,14 +1,12 @@ -import '../../../ui/adaptive/segmented_bar.dart'; import 'dart:convert'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import '../../../ui/adaptive/segmented_bar.dart'; import '../../../ui/text/markdown_source_view.dart'; import '../../chat/ui/transcript/chat_markdown_view.dart'; import '../../../core/api_gateway.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; -import '../../../ui/adaptive/host.dart'; import '../domain/graph_protocol.dart'; import '../domain/stage_definition.dart'; @@ -159,30 +157,14 @@ Future openStageDefinition( // A terminal is a definition target, not its protocol key: the web pane // titles it with `nodeDisplayLabel` (`Failure`/`Success`). final title = '${nodeDisplayLabel(stageKey)} definition'; - final route = usesCupertinoHost(context) - ? CupertinoPageRoute( - settings: settings, - builder: (_) => CupertinoPageScaffold( - navigationBar: SegmentedBar( - cupertino: true, - title: title, - subtitle: identity, - ), - child: SafeArea(top: false, bottom: false, child: view), - ), - ) - : MaterialPageRoute( - settings: settings, - builder: (_) => Scaffold( - extendBodyBehindAppBar: true, - appBar: SegmentedBar( - cupertino: false, - title: title, - subtitle: identity, - ), - body: SafeArea(top: false, bottom: false, child: view), - ), - ); + final route = MaterialPageRoute( + settings: settings, + builder: (_) => Scaffold( + extendBodyBehindAppBar: true, + appBar: SegmentedBar(cupertino: false, title: title, subtitle: identity), + body: SafeArea(top: false, bottom: false, child: view), + ), + ); return Navigator.of(context).push(route); } @@ -263,22 +245,6 @@ class _StageDefinitionStyle { }); factory _StageDefinitionStyle.of(BuildContext context) { - if (usesCupertinoHost(context)) { - final theme = CupertinoTheme.of(context); - final secondary = CupertinoColors.secondaryLabel.resolveFrom(context); - return _StageDefinitionStyle( - label: theme.textTheme.tabLabelTextStyle.copyWith(color: secondary), - // SelectableText needs a style it can merge into the default text - // style; Cupertino's textStyle is a complete style with `inherit: false` - // and no baseline. - value: theme.textTheme.textStyle.copyWith(inherit: true), - muted: theme.textTheme.textStyle.copyWith( - inherit: true, - color: secondary, - ), - heading: theme.textTheme.navTitleTextStyle, - ); - } final theme = Theme.of(context); return _StageDefinitionStyle( label: (theme.textTheme.labelMedium ?? const TextStyle()).copyWith( diff --git a/app/test/features/graph/viewport/graph_expanded_view_test.dart b/app/test/features/graph/viewport/graph_expanded_view_test.dart index a1a7d077..84c680e4 100644 --- a/app/test/features/graph/viewport/graph_expanded_view_test.dart +++ b/app/test/features/graph/viewport/graph_expanded_view_test.dart @@ -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 = []; + 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(_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(_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', - ); - } }); } diff --git a/app/test/features/graph/viewport/graph_viewport_controls_test.dart b/app/test/features/graph/viewport/graph_viewport_controls_test.dart index cba0ed0a..7c305052 100644 --- a/app/test/features/graph/viewport/graph_viewport_controls_test.dart +++ b/app/test/features/graph/viewport/graph_viewport_controls_test.dart @@ -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); }); } diff --git a/app/test/features/graph/viewport/graph_viewport_fixtures.dart b/app/test/features/graph/viewport/graph_viewport_fixtures.dart index 72b7eb88..f467ffaa 100644 --- a/app/test/features/graph/viewport/graph_viewport_fixtures.dart +++ b/app/test/features/graph/viewport/graph_viewport_fixtures.dart @@ -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)), diff --git a/app/test/features/graph/widgets/definition_graph_view_test.dart b/app/test/features/graph/widgets/definition_graph_view_test.dart index 1051d604..d80fda54 100644 --- a/app/test/features/graph/widgets/definition_graph_view_test.dart +++ b/app/test/features/graph/widgets/definition_graph_view_test.dart @@ -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? 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 _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 = []; - 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']); - }); } diff --git a/app/test/features/graph/widgets/graph_stage_node_render_test.dart b/app/test/features/graph/widgets/graph_stage_node_render_test.dart index 113a09ae..9135044d 100644 --- a/app/test/features/graph/widgets/graph_stage_node_render_test.dart +++ b/app/test/features/graph/widgets/graph_stage_node_render_test.dart @@ -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 = {}; - 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 = {}; + 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', + ); }); } diff --git a/app/test/features/graph/widgets/graph_stage_node_test.dart b/app/test/features/graph/widgets/graph_stage_node_test.dart index 3d2ade29..34b0e428 100644 --- a/app/test/features/graph/widgets/graph_stage_node_test.dart +++ b/app/test/features/graph/widgets/graph_stage_node_test.dart @@ -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 = []; - 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 = []; + 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(_visual(label)); - expect(text.data!.replaceAll('\u200B', ''), label); - expect(text.maxLines, isNull); - expect(text.overflow, isNull); - final paragraph = tester.renderObject(_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(_visual(label)); + expect(text.data!.replaceAll('\u200B', ''), label); + expect(text.maxLines, isNull); + expect(text.overflow, isNull); + final paragraph = tester.renderObject(_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', diff --git a/app/test/features/graph/widgets/run_graph_view_test.dart b/app/test/features/graph/widgets/run_graph_view_test.dart index 30a12979..ac47e2af 100644 --- a/app/test/features/graph/widgets/run_graph_view_test.dart +++ b/app/test/features/graph/widgets/run_graph_view_test.dart @@ -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? 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 _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 = []; - 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(_node('plan')).recordedStatus, - 'completed', - ); - expect( - tester.widget(_node('build')).recordedStatus, - 'running', - ); - _expectNoOverlaps(tester); - - await tester.tap(_node('plan')); - await tester.pump(); - expect(picked, ['plan']); - expect(tester.takeException(), isNull); - }); } diff --git a/app/test/features/graph/widgets/stage_definition_view_test.dart b/app/test/features/graph/widgets/stage_definition_view_test.dart index 115d89ed..9c345748 100644 --- a/app/test/features/graph/widgets/stage_definition_view_test.dart +++ b/app/test/features/graph/widgets/stage_definition_view_test.dart @@ -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('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(find.byType(SelectableText))