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.
68 lines
2.9 KiB
Dart
68 lines
2.9 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/glass_surface.dart';
|
|
|
|
Widget _pill({Brightness brightness = Brightness.light, bool solid = false}) =>
|
|
MaterialApp(
|
|
theme: ThemeData(brightness: brightness),
|
|
home: MediaQuery(
|
|
data: MediaQueryData(highContrast: solid),
|
|
child: const Center(child: GlassPill(child: Text('Runs'))),
|
|
),
|
|
);
|
|
|
|
List<CustomPainter> _painters(WidgetTester tester) => [
|
|
for (final paint in tester.widgetList<CustomPaint>(
|
|
find.ancestor(of: find.text('Runs'), matching: find.byType(CustomPaint)),
|
|
)) ...[?paint.painter, ?paint.foregroundPainter],
|
|
];
|
|
|
|
void main() {
|
|
testWidgets('a piece has its highlight, rim and shadow, and one backdrop '
|
|
'read that blurs and saturates', (tester) async {
|
|
await tester.pumpWidget(_pill());
|
|
final painters = _painters(tester);
|
|
expect(painters.whereType<GlassHighlightPainter>(), hasLength(1));
|
|
expect(painters.whereType<GlassRimPainter>(), hasLength(1));
|
|
expect(painters.whereType<GlassShadowPainter>(), hasLength(1));
|
|
final layers = tester.layers.whereType<BackdropFilterLayer>().toList();
|
|
expect(layers, hasLength(1));
|
|
expect(layers.single.filter, GlassLook.backdrop(GlassPill.blurSigma));
|
|
});
|
|
|
|
testWidgets('light and dark fills get their own look', (tester) async {
|
|
await tester.pumpWidget(_pill());
|
|
final light = _painters(tester).whereType<GlassRimPainter>().single;
|
|
expect(light.top, GlassLook.light.rimTop);
|
|
await tester.pumpWidget(_pill(brightness: Brightness.dark));
|
|
await tester.pumpAndSettle();
|
|
final dark = _painters(tester).whereType<GlassRimPainter>().single;
|
|
expect(dark.top, GlassLook.dark.rimTop);
|
|
expect(GlassLook.forFill(Colors.white), same(GlassLook.light));
|
|
expect(GlassLook.forFill(Colors.black), same(GlassLook.dark));
|
|
});
|
|
|
|
test('the look stays subtle frosted glass, not a metallic sheen', () {
|
|
for (final look in [GlassLook.light, GlassLook.dark]) {
|
|
expect(look.highlight.a, lessThanOrEqualTo(0.2));
|
|
expect(look.rimTop.a, lessThanOrEqualTo(0.35));
|
|
expect(look.rimTop.a - look.rimBottom.a, lessThanOrEqualTo(0.2));
|
|
expect(look.shadow.a, lessThanOrEqualTo(0.26));
|
|
}
|
|
expect(GlassLook.highlightExtent, lessThanOrEqualTo(0.4));
|
|
expect(GlassLook.saturation, inInclusiveRange(1.0, 1.3));
|
|
});
|
|
|
|
testWidgets('high contrast keeps a solid piece without blur or sheen', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(_pill(solid: true));
|
|
expect(_painters(tester).whereType<GlassHighlightPainter>(), isEmpty);
|
|
expect(_painters(tester).whereType<GlassRimPainter>(), isEmpty);
|
|
expect(_painters(tester).whereType<GlassShadowPainter>(), isEmpty);
|
|
expect(tester.layers.whereType<BackdropFilterLayer>(), isEmpty);
|
|
});
|
|
}
|