d1b05217c9
Keep the pipeline feature on its existing Material path because the app runs under MaterialApp and never selects Cupertino hosts. Preserve public cupertino parameters and required Cupertino icon values for later cleanup and shared controls.
158 lines
5.5 KiB
Dart
158 lines
5.5 KiB
Dart
import 'dart:ui' show SemanticsRole;
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
|
|
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
|
|
import 'package:pipelines_app/features/runs/ui/run_detail_tab_strip.dart';
|
|
import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
|
|
import 'package:pipelines_app/shell/destination.dart';
|
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
|
|
|
/// Every bottom tab bar shows icons only, yet each tab keeps its name for
|
|
/// assistive technology (and a Material tooltip), its selected state and its
|
|
/// test key; the icons within a bar, and against the shell's tabs a detail's
|
|
/// bar floats above, are distinct.
|
|
void main() {
|
|
Widget host(bool cupertino, Widget bar) {
|
|
final body = Align(alignment: Alignment.bottomCenter, child: bar);
|
|
return cupertino
|
|
? CupertinoApp(home: CupertinoPageScaffold(child: body))
|
|
: MaterialApp(home: Scaffold(body: body));
|
|
}
|
|
|
|
final bars = <String, (Widget, List<(String, String)>)>{
|
|
'run detail': (
|
|
RunDetailTabStrip(selected: RunDetailTab.summary, onSelected: (_) {}),
|
|
[
|
|
for (final tab in renderedRunDetailTabs)
|
|
('run-detail-tab-${tab.name}', tab.label),
|
|
],
|
|
),
|
|
'stage page': (
|
|
RunVisitSectionStrip(
|
|
selected: RunVisitSection.summary,
|
|
onSelected: (_) {},
|
|
),
|
|
[
|
|
for (final section in shownVisitSections)
|
|
('run-visit-tab-${section.name}', section.label),
|
|
],
|
|
),
|
|
'pipeline detail': (
|
|
PipelineDetailTabs(
|
|
selected: PipelineDetailTab.summary,
|
|
onSelected: (_) {},
|
|
),
|
|
[
|
|
for (final tab in PipelineDetailTab.values)
|
|
('pipeline-detail-tab-${tab.name}', tab.label),
|
|
],
|
|
),
|
|
};
|
|
|
|
for (final cupertino in [false, true]) {
|
|
final name = cupertino ? 'Cupertino' : 'Material';
|
|
for (final MapEntry(key: label, value: (bar, tabs)) in bars.entries) {
|
|
// The pipeline detail bar is Material on every host.
|
|
if (cupertino && label == 'pipeline detail') continue;
|
|
testWidgets('$name $label tabs are icons named for assistive '
|
|
'technology', (tester) async {
|
|
final semantics = tester.ensureSemantics();
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
await tester.pumpWidget(host(cupertino, bar));
|
|
await tester.pumpAndSettle();
|
|
|
|
final floating = find.byType(FloatingDestinationBar);
|
|
// No label is drawn at all.
|
|
expect(
|
|
find.descendant(of: floating, matching: find.byType(Text)),
|
|
findsNothing,
|
|
);
|
|
for (final (index, (key, tabLabel)) in tabs.indexed) {
|
|
final finder = find.byKey(ValueKey(key));
|
|
final node = tester.getSemantics(finder);
|
|
expect(node.label, startsWith(tabLabel), reason: key);
|
|
expect(
|
|
node,
|
|
isSemantics(
|
|
isSelected: index == 0,
|
|
hasSelectedState: true,
|
|
isButton: true,
|
|
hasTapAction: true,
|
|
),
|
|
reason: key,
|
|
);
|
|
expect(node.role, SemanticsRole.tab, reason: key);
|
|
// "Tab n of m", as the host navigation controls announce it: in the
|
|
// Material label, the Cupertino hint.
|
|
final position = 'Tab ${index + 1} of ${tabs.length}';
|
|
expect(
|
|
cupertino ? node.hint : node.label,
|
|
contains(position),
|
|
reason: key,
|
|
);
|
|
// Material names the tab in its tooltip too.
|
|
if (!cupertino) {
|
|
expect(
|
|
find.descendant(
|
|
of: finder,
|
|
matching: find.byWidgetPredicate(
|
|
(widget) => widget is Tooltip && widget.message == tabLabel,
|
|
),
|
|
),
|
|
findsOneWidget,
|
|
reason: key,
|
|
);
|
|
}
|
|
// A hit target at least the platform minimum.
|
|
expect(
|
|
tester.getSize(finder).shortestSide,
|
|
greaterThanOrEqualTo(cupertino ? 44 : 48),
|
|
);
|
|
}
|
|
// The tabs make up one tab bar.
|
|
final tabBar = tester.getSemantics(
|
|
find.byKey(FloatingDestinationBar.rowKey),
|
|
);
|
|
expect(tabBar.role, SemanticsRole.tabBar);
|
|
// Distinct glyphs within the bar.
|
|
final icons = tester
|
|
.widgetList<Icon>(
|
|
find.descendant(of: floating, matching: find.byType(Icon)),
|
|
)
|
|
.map((icon) => icon.icon)
|
|
.toSet();
|
|
expect(icons.length, greaterThanOrEqualTo(tabs.length));
|
|
semantics.dispose();
|
|
});
|
|
}
|
|
}
|
|
|
|
test('detail tab icons differ from the shell tabs they float above', () {
|
|
final shell = {
|
|
for (final destination in shellTabDestinations) ...[
|
|
destinationDetails(destination).icon,
|
|
destinationDetails(destination).cupertinoIcon,
|
|
],
|
|
};
|
|
final details = [
|
|
for (final tab in renderedRunDetailTabs) ...[tab.icon, tab.cupertinoIcon],
|
|
for (final section in shownVisitSections) ...[
|
|
section.icon,
|
|
section.cupertinoIcon,
|
|
],
|
|
for (final tab in PipelineDetailTab.values) ...[
|
|
tab.icon,
|
|
tab.cupertinoIcon,
|
|
],
|
|
];
|
|
for (final icon in details) {
|
|
expect(shell.contains(icon), isFalse, reason: '$icon');
|
|
}
|
|
});
|
|
}
|