71 lines
2.4 KiB
Dart
71 lines
2.4 KiB
Dart
import 'package:flutter/rendering.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/attention/ui/needs_you_keys.dart';
|
|
|
|
import 'needs_you_test_support.dart';
|
|
|
|
/// Layout evidence for the hardest case: a narrow phone at a doubled text scale.
|
|
void main() {
|
|
for (final native in [false, true]) {
|
|
final host = native ? 'Cupertino' : 'Material';
|
|
|
|
testWidgets('$host sheet wraps at 320 logical px and 2x in dark', (
|
|
tester,
|
|
) async {
|
|
tester.view.devicePixelRatio = 2;
|
|
tester.view.physicalSize = const Size(640, 1280);
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
const longTitle =
|
|
'Implementer-with-an-unshortened-stage-label that the operator sees';
|
|
const longDetail =
|
|
'Stage 3 stopped at the export archive step because the credential '
|
|
'it needs is no longer configured on this server.';
|
|
final entry = attentionFixture(
|
|
id: 1,
|
|
name: 'Release',
|
|
title: longTitle,
|
|
diagnostic: longDetail,
|
|
);
|
|
await tester.pumpWidget(
|
|
attentionApp(
|
|
NeedsYouPage(entries: [entry], cupertino: native),
|
|
cupertino: native,
|
|
dark: true,
|
|
textScale: 2,
|
|
),
|
|
);
|
|
|
|
await tester.tap(find.byKey(attentionBellKey));
|
|
await tester.pumpAndSettle();
|
|
expect(tester.takeException(), isNull);
|
|
|
|
final label = find.text(longTitle);
|
|
final description = find.text('Release · $longDetail');
|
|
expect(label, findsOneWidget);
|
|
expect(description, findsOneWidget);
|
|
await tester.ensureVisible(label);
|
|
final paragraph = tester.renderObject<RenderParagraph>(label);
|
|
expect(paragraph.didExceedMaxLines, isFalse);
|
|
final unscaled = TextPainter(
|
|
text: paragraph.text,
|
|
textDirection: paragraph.textDirection,
|
|
textScaler: TextScaler.noScaling,
|
|
)..layout();
|
|
expect(
|
|
unscaled.width,
|
|
greaterThan(paragraph.size.width),
|
|
reason: 'the long label wraps instead of shrinking to one line',
|
|
);
|
|
unscaled.dispose();
|
|
|
|
final sheet = tester.getRect(find.byKey(attentionSheetKey));
|
|
expect(sheet.left, greaterThanOrEqualTo(0));
|
|
expect(sheet.right, lessThanOrEqualTo(320));
|
|
expect(sheet.top, greaterThanOrEqualTo(0));
|
|
expect(sheet.bottom, lessThanOrEqualTo(640));
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
}
|
|
}
|