9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
181 lines
5.6 KiB
Dart
181 lines
5.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/rendering.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
|
import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart';
|
|
|
|
void _size(WidgetTester tester, double width, {double scale = 1}) {
|
|
tester.view.physicalSize = Size(width, 700);
|
|
tester.view.devicePixelRatio = 1;
|
|
tester.platformDispatcher.textScaleFactorTestValue = scale;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
|
}
|
|
|
|
bool _ellipsised(WidgetTester tester, String text) {
|
|
final paragraph = tester.renderObject<RenderParagraph>(find.text(text));
|
|
return paragraph.didExceedMaxLines ||
|
|
paragraph.size.width <
|
|
(TextPainter(
|
|
text: TextSpan(text: text, style: paragraph.text.style),
|
|
textDirection: TextDirection.ltr,
|
|
textScaler: paragraph.textScaler,
|
|
)..layout()).width -
|
|
0.5;
|
|
}
|
|
|
|
Widget _modelAction(String model) => TextButton(
|
|
onPressed: () {},
|
|
child: Text(model, maxLines: 1, overflow: TextOverflow.ellipsis),
|
|
);
|
|
|
|
void main() {
|
|
// The test font draws every glyph a square, so names run wider than in
|
|
// a browser; each width takes the longest id that fits it there.
|
|
for (final (width, model) in [
|
|
(390.0, 'gpt-5.6-luna'),
|
|
(560.0, 'claude-opus-5-5'),
|
|
]) {
|
|
testWidgets('a long model name ($model) shows whole at ${width}px', (
|
|
tester,
|
|
) async {
|
|
_size(tester, width);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
extendBodyBehindAppBar: true,
|
|
appBar: SegmentedBar(
|
|
leading: const BackButton(),
|
|
title: 'A conversation with a rather long title indeed',
|
|
subtitle: 'tank',
|
|
actions: [_modelAction(model)],
|
|
),
|
|
body: const SizedBox.expand(),
|
|
),
|
|
),
|
|
);
|
|
expect(_ellipsised(tester, model), isFalse);
|
|
// The title gives way first.
|
|
expect(
|
|
_ellipsised(tester, 'A conversation with a rather long title indeed'),
|
|
isTrue,
|
|
);
|
|
});
|
|
}
|
|
|
|
testWidgets('320px at 2x text lays out without overflow', (tester) async {
|
|
_size(tester, 320, scale: 2);
|
|
final bar = SegmentedBar(
|
|
leading: SegmentedBackButton(onPressed: () {}),
|
|
title: 'A long conversation title',
|
|
subtitle: 'a-working-folder',
|
|
subtitleIcon: Icons.folder_outlined,
|
|
onTitlePressed: () {},
|
|
actions: [
|
|
_modelAction('gpt-5.6-luna'),
|
|
IconButton(onPressed: () {}, icon: const Icon(Icons.refresh)),
|
|
],
|
|
);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
extendBodyBehindAppBar: true,
|
|
appBar: bar,
|
|
body: const SizedBox.expand(),
|
|
),
|
|
),
|
|
);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
|
|
testWidgets('taps between the pieces reach the content behind', (
|
|
tester,
|
|
) async {
|
|
_size(tester, 560);
|
|
var behind = 0;
|
|
var back = 0;
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
extendBodyBehindAppBar: true,
|
|
appBar: SegmentedBar(
|
|
leading: BackButton(onPressed: () => back++),
|
|
title: 'Short',
|
|
),
|
|
body: GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () => behind++,
|
|
child: const SizedBox.expand(),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
final barRect = tester.getRect(find.byType(SegmentedBar));
|
|
// The empty middle of the bar, right of the short title.
|
|
await tester.tapAt(Offset(barRect.width * 0.75, barRect.center.dy));
|
|
expect(behind, 1);
|
|
await tester.tap(find.byType(BackButton));
|
|
expect(back, 1);
|
|
expect(behind, 1);
|
|
});
|
|
|
|
testWidgets('content starts below the bar at rest', (tester) async {
|
|
_size(tester, 560);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: SegmentedBarOverlay(
|
|
bar: const SegmentedBar(title: 'Overlay'),
|
|
child: ListView(
|
|
children: const [ListTile(title: Text('First row'))],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
final bar = tester.getRect(find.byType(SegmentedBar));
|
|
final row = tester.getRect(find.text('First row'));
|
|
expect(row.top, greaterThanOrEqualTo(bar.bottom));
|
|
// The list itself reaches the top, behind the bar.
|
|
expect(tester.getRect(find.byType(ListView)).top, 0);
|
|
});
|
|
|
|
testWidgets('pieces are frosted glass, solid under high contrast', (
|
|
tester,
|
|
) async {
|
|
Widget app(bool highContrast) => MaterialApp(
|
|
home: MediaQuery(
|
|
data: MediaQueryData(highContrast: highContrast),
|
|
child: Scaffold(
|
|
appBar: const SegmentedBar(title: 'Glass'),
|
|
body: const SizedBox.expand(),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpWidget(app(false));
|
|
expect(find.byType(GlassPill), findsOneWidget);
|
|
expect(find.byType(BackdropFilter), findsOneWidget);
|
|
expect(find.byType(Material), findsWidgets);
|
|
|
|
await tester.pumpWidget(app(true));
|
|
expect(find.byType(BackdropFilter), findsNothing);
|
|
});
|
|
|
|
testWidgets('Material titles use semibold text', (tester) async {
|
|
await tester.pumpWidget(
|
|
const MaterialApp(
|
|
home: Scaffold(
|
|
appBar: SegmentedBar(title: 'Title'),
|
|
body: SizedBox.expand(),
|
|
),
|
|
),
|
|
);
|
|
expect(
|
|
tester.widget<Text>(find.text('Title')).style?.fontWeight,
|
|
FontWeight.w600,
|
|
);
|
|
});
|
|
}
|