Remove Cupertino graph branches
Keep the Material graph implementation while preserving public Cupertino parameters for callers. Remove unreachable Cupertino widgets, routes, theme branches, imports, and Cupertino-only tests because the app runs exclusively under MaterialApp.
This commit is contained in:
@@ -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)),
|
||||
|
||||
Reference in New Issue
Block a user