Merge branch 'worktree-agent-a992ffc22d3f335ed' into integrate/tabs-v2
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
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) {
|
||||
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);
|
||||
if (cupertino) {
|
||||
// No label is drawn at all.
|
||||
expect(
|
||||
find.descendant(of: floating, matching: find.byType(Text)),
|
||||
findsNothing,
|
||||
);
|
||||
} else {
|
||||
// NavigationBar keeps its label hidden (for semantics only).
|
||||
expect(
|
||||
NavigationBarTheme.of(
|
||||
tester.element(find.byType(NavigationDestination).first),
|
||||
).labelBehavior,
|
||||
NavigationDestinationLabelBehavior.alwaysHide,
|
||||
);
|
||||
}
|
||||
for (final (index, (key, tabLabel)) in tabs.indexed) {
|
||||
final node = tester.getSemantics(find.byKey(ValueKey(key)));
|
||||
expect(node.label, startsWith(tabLabel), reason: key);
|
||||
expect(
|
||||
node,
|
||||
index == 0
|
||||
? isSemantics(isSelected: true)
|
||||
: isNot(isSemantics(isSelected: true)),
|
||||
reason: key,
|
||||
);
|
||||
}
|
||||
// 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');
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user