Unverified Commit f4551e64 authored by LongCatIsLooong's avatar LongCatIsLooong Committed by GitHub

Reland "Update test font (#121306)" (#122068)

Reland "Update test font (#121306)"
parent c5da5070
......@@ -12,7 +12,6 @@ import 'package:flutter_test/flutter_test.dart';
import '../widgets/semantics_tester.dart';
const TextStyle testStyle = TextStyle(
fontFamily: 'Ahem',
fontSize: 10.0,
letterSpacing: 0.0,
);
......
......@@ -160,7 +160,7 @@ void main() {
// Also shows the previous page's title next to the back button.
expect(find.widgetWithText(CupertinoButton, 'An iPod'), findsOneWidget);
// 3 paddings + 1 ahem character at font size 34.0.
// 3 paddings + 1 test font character at font size 34.0.
expect(tester.getTopLeft(find.text('An iPod')).dx, 8.0 + 4.0 + 34.0 + 6.0);
});
......
......@@ -3496,10 +3496,7 @@ void main() {
child: CupertinoTextField(
dragStartBehavior: DragStartBehavior.down,
controller: controller,
style: const TextStyle(
fontFamily: 'Ahem',
fontSize: 10.0,
),
style: const TextStyle(fontSize: 10.0),
),
),
),
......@@ -4045,10 +4042,7 @@ void main() {
child: CupertinoTextField(
dragStartBehavior: DragStartBehavior.down,
controller: controller,
style: const TextStyle(
fontFamily: 'Ahem',
fontSize: 10.0,
),
style: const TextStyle(fontSize: 10.0),
),
),
),
......@@ -4180,10 +4174,7 @@ void main() {
child: CupertinoTextField(
dragStartBehavior: DragStartBehavior.down,
controller: controller,
style: const TextStyle(
fontFamily: 'Ahem',
fontSize: 10.0,
),
style: const TextStyle(fontSize: 10.0),
),
),
),
......@@ -7858,7 +7849,6 @@ void main() {
testWidgets('placeholder style overflow works', (WidgetTester tester) async {
final String placeholder = 'hint text' * 20;
const TextStyle placeholderStyle = TextStyle(
fontFamily: 'Ahem',
fontSize: 14.0,
overflow: TextOverflow.fade,
);
......
......@@ -576,7 +576,7 @@ void main() {
);
testWidgets('Chip in row works ok', (WidgetTester tester) async {
const TextStyle style = TextStyle(fontFamily: 'Ahem', fontSize: 10.0);
const TextStyle style = TextStyle(fontSize: 10.0);
await tester.pumpWidget(
wrapForChip(
child: const Row(
......
......@@ -288,24 +288,24 @@ void main() {
testWidgets('Tab sizing - text', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(theme: ThemeData(fontFamily: 'Ahem'), home: const Center(child: Material(child: Tab(text: 'x')))),
MaterialApp(theme: ThemeData(fontFamily: 'FlutterTest'), home: const Center(child: Material(child: Tab(text: 'x')))),
);
expect(tester.renderObject<RenderParagraph>(find.byType(RichText)).text.style!.fontFamily, 'Ahem');
expect(tester.renderObject<RenderParagraph>(find.byType(RichText)).text.style!.fontFamily, 'FlutterTest');
expect(tester.getSize(find.byType(Tab)), const Size(14.0, 46.0));
});
testWidgets('Tab sizing - icon and text', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(theme: ThemeData(fontFamily: 'Ahem'), home: const Center(child: Material(child: Tab(icon: SizedBox(width: 10.0, height: 10.0), text: 'x')))),
MaterialApp(theme: ThemeData(fontFamily: 'FlutterTest'), home: const Center(child: Material(child: Tab(icon: SizedBox(width: 10.0, height: 10.0), text: 'x')))),
);
expect(tester.renderObject<RenderParagraph>(find.byType(RichText)).text.style!.fontFamily, 'Ahem');
expect(tester.renderObject<RenderParagraph>(find.byType(RichText)).text.style!.fontFamily, 'FlutterTest');
expect(tester.getSize(find.byType(Tab)), const Size(14.0, 72.0));
});
testWidgets('Tab sizing - icon, iconMargin and text', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(fontFamily: 'Ahem'),
theme: ThemeData(fontFamily: 'FlutterTest'),
home: const Center(
child: Material(
child: Tab(
......@@ -322,15 +322,15 @@ void main() {
),
),
);
expect(tester.renderObject<RenderParagraph>(find.byType(RichText)).text.style!.fontFamily, 'Ahem');
expect(tester.renderObject<RenderParagraph>(find.byType(RichText)).text.style!.fontFamily, 'FlutterTest');
expect(tester.getSize(find.byType(Tab)), const Size(210.0, 72.0));
});
testWidgets('Tab sizing - icon and child', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(theme: ThemeData(fontFamily: 'Ahem'), home: const Center(child: Material(child: Tab(icon: SizedBox(width: 10.0, height: 10.0), child: Text('x'))))),
MaterialApp(theme: ThemeData(fontFamily: 'FlutterTest'), home: const Center(child: Material(child: Tab(icon: SizedBox(width: 10.0, height: 10.0), child: Text('x'))))),
);
expect(tester.renderObject<RenderParagraph>(find.byType(RichText)).text.style!.fontFamily, 'Ahem');
expect(tester.renderObject<RenderParagraph>(find.byType(RichText)).text.style!.fontFamily, 'FlutterTest');
expect(tester.getSize(find.byType(Tab)), const Size(14.0, 72.0));
});
......
......@@ -2241,7 +2241,7 @@ void main() {
child: TextField(
dragStartBehavior: DragStartBehavior.down,
controller: controller,
style: const TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: const TextStyle(fontSize: 10.0),
),
),
),
......@@ -6913,20 +6913,26 @@ void main() {
key: keyA,
decoration: null,
controller: controllerA,
style: const TextStyle(fontSize: 10.0),
// The point size of the font must be a multiple of 4 until
// https://github.com/flutter/flutter/issues/122066 is resolved.
style: const TextStyle(fontFamily: 'FlutterTest', fontSize: 12.0),
strutStyle: StrutStyle.disabled,
),
),
const Text(
'abc',
style: TextStyle(fontSize: 20.0),
// The point size of the font must be a multiple of 4 until
// https://github.com/flutter/flutter/issues/122066 is resolved.
style: TextStyle(fontFamily: 'FlutterTest', fontSize: 24.0),
),
Expanded(
child: TextField(
key: keyB,
decoration: null,
controller: controllerB,
style: const TextStyle(fontSize: 30.0),
// The point size of the font must be a multiple of 4 until
// https://github.com/flutter/flutter/issues/122066 is resolved.
style: const TextStyle(fontFamily: 'FlutterTest', fontSize: 36.0),
strutStyle: StrutStyle.disabled,
),
),
......@@ -6935,17 +6941,17 @@ void main() {
),
);
// The Ahem font extends 0.2 * fontSize below the baseline.
// The test font extends 0.25 * fontSize below the baseline.
// So the three row elements line up like this:
//
// A abc B
// --------- baseline
// 2 4 6 space below the baseline = 0.2 * fontSize
// --------- rowBottomY
// --------- baseline
// 3 6 9 space below the baseline = 0.25 * fontSize
// --------- rowBottomY
final double rowBottomY = tester.getBottomLeft(find.byType(Row)).dy;
expect(tester.getBottomLeft(find.byKey(keyA)).dy, moreOrLessEquals(rowBottomY - 4.0, epsilon: 0.001));
expect(tester.getBottomLeft(find.text('abc')).dy, moreOrLessEquals(rowBottomY - 2.0, epsilon: 0.001));
expect(tester.getBottomLeft(find.byKey(keyA)).dy, rowBottomY - 6.0);
expect(tester.getBottomLeft(find.text('abc')).dy, rowBottomY - 3.0);
expect(tester.getBottomLeft(find.byKey(keyB)).dy, rowBottomY);
});
......@@ -6966,19 +6972,25 @@ void main() {
key: keyA,
decoration: null,
controller: controllerA,
style: const TextStyle(fontSize: 10.0),
// The point size of the font must be a multiple of 4 until
// https://github.com/flutter/flutter/issues/122066 is resolved.
style: const TextStyle(fontFamily: 'FlutterTest', fontSize: 12.0),
),
),
const Text(
'abc',
style: TextStyle(fontSize: 20.0),
// The point size of the font must be a multiple of 4 until
// https://github.com/flutter/flutter/issues/122066 is resolved.
style: TextStyle(fontFamily: 'FlutterTest', fontSize: 24.0),
),
Expanded(
child: TextField(
key: keyB,
decoration: null,
controller: controllerB,
style: const TextStyle(fontSize: 30.0),
// The point size of the font must be a multiple of 4 until
// https://github.com/flutter/flutter/issues/122066 is resolved.
style: const TextStyle(fontFamily: 'FlutterTest', fontSize: 36.0),
),
),
],
......@@ -6986,18 +6998,18 @@ void main() {
),
);
// The Ahem font extends 0.2 * fontSize below the baseline.
// The test font extends 0.25 * fontSize below the baseline.
// So the three row elements line up like this:
//
// A abc B
// --------- baseline
// 2 4 6 space below the baseline = 0.2 * fontSize
// --------- rowBottomY
// --------- baseline
// 3 6 9 space below the baseline = 0.25 * fontSize
// --------- rowBottomY
final double rowBottomY = tester.getBottomLeft(find.byType(Row)).dy;
// The values here should match the version with strut disabled ('TextField baseline alignment no-strut')
expect(tester.getBottomLeft(find.byKey(keyA)).dy, moreOrLessEquals(rowBottomY - 4.0, epsilon: 0.001));
expect(tester.getBottomLeft(find.text('abc')).dy, moreOrLessEquals(rowBottomY - 2.0, epsilon: 0.001));
expect(tester.getBottomLeft(find.byKey(keyA)).dy, rowBottomY - 6.0);
expect(tester.getBottomLeft(find.text('abc')).dy, rowBottomY - 3.0);
expect(tester.getBottomLeft(find.byKey(keyB)).dy, rowBottomY);
});
......
......@@ -101,14 +101,14 @@ void main() {
test('Can control fontFamily default', () {
final ThemeData themeData = ThemeData(
fontFamily: 'Ahem',
fontFamily: 'FlutterTest',
textTheme: const TextTheme(
titleLarge: TextStyle(fontFamily: 'Roboto'),
),
);
expect(themeData.textTheme.bodyLarge!.fontFamily, equals('Ahem'));
expect(themeData.primaryTextTheme.displaySmall!.fontFamily, equals('Ahem'));
expect(themeData.textTheme.bodyLarge!.fontFamily, equals('FlutterTest'));
expect(themeData.primaryTextTheme.displaySmall!.fontFamily, equals('FlutterTest'));
// Shouldn't override the specified style's family
expect(themeData.textTheme.titleLarge!.fontFamily, equals('Roboto'));
......
......@@ -1326,6 +1326,8 @@ void main() {
});
testWidgets('ToggleButtons text baseline alignment', (WidgetTester tester) async {
// The point size of the fonts must be a multiple of 4 until
// https://github.com/flutter/flutter/issues/122066 is resolved.
await tester.pumpWidget(
Material(
child: boilerplate(
......@@ -1337,27 +1339,27 @@ void main() {
borderWidth: 5.0,
isSelected: const <bool>[false, true],
children: const <Widget>[
Text('First child', style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0)),
Text('Second child', style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0)),
Text('First child', style: TextStyle(fontFamily: 'FlutterTest', fontSize: 8.0)),
Text('Second child', style: TextStyle(fontFamily: 'FlutterTest', fontSize: 8.0)),
],
),
const MaterialButton(
onPressed: null,
child: Text('Material Button', style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0)),
child: Text('Material Button', style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0)),
),
const Text('Text', style: TextStyle(fontFamily: 'Ahem', fontSize: 30.0)),
const Text('Text', style: TextStyle(fontFamily: 'FlutterTest', fontSize: 28.0)),
],
),
),
),
);
// The Ahem font extends 0.2 * fontSize below the baseline.
// The test font extends 0.25 * fontSize below the baseline.
// So the three row elements line up like this:
//
// ToggleButton MaterialButton Text
// ------------------------------------ baseline
// 2 4 6 space below the baseline = 0.2 * fontSize
// 2.0 5.0 7.0 space below the baseline = 0.25 * fontSize
// ------------------------------------ widget text dy values
final double firstToggleButtonDy = tester.getBottomLeft(find.text('First child')).dy;
......@@ -1366,8 +1368,8 @@ void main() {
final double textDy = tester.getBottomLeft(find.text('Text')).dy;
expect(firstToggleButtonDy, secondToggleButtonDy);
expect(firstToggleButtonDy, moreOrLessEquals(materialButtonDy - 2.0, epsilon: 0.001));
expect(firstToggleButtonDy, moreOrLessEquals(textDy - 4.0, epsilon: 0.001));
expect(firstToggleButtonDy, materialButtonDy - 3.0);
expect(firstToggleButtonDy, textDy - 5.0);
});
testWidgets('Directionality test', (WidgetTester tester) async {
......
......@@ -16,7 +16,7 @@ void main() {
painter.text = const TextSpan(
text: 'ABC DEF\nGHI',
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontSize: 10.0),
);
painter.layout();
......@@ -42,7 +42,7 @@ void main() {
painter.text = const TextSpan(
text: '${Unicode.RLO}HEBREW1 ${Unicode.LRO}english2${Unicode.PDF} HEBREW3${Unicode.PDF}',
// 0 12345678 9 101234567 18 90123456 27
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontSize: 10.0),
);
TextSpan textSpan = painter.text! as TextSpan;
expect(textSpan.text!.length, 28);
......@@ -175,7 +175,7 @@ void main() {
painter.text = const TextSpan(
text: '${Unicode.RLO}HEBREW1 ${Unicode.LRO}english2${Unicode.PDF} HEBREW3${Unicode.PDF}',
// 0 12345678 9 101234567 18 90123456 27
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontSize: 10.0),
);
final TextSpan textSpan = painter.text! as TextSpan;
expect(textSpan.text!.length, 28);
......@@ -266,7 +266,7 @@ void main() {
painter.text = const TextSpan(
text: 'A\u05D0', // A, Alef
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontSize: 10.0),
);
final TextSpan textSpan = painter.text! as TextSpan;
expect(textSpan.text!.length, 2);
......@@ -333,14 +333,14 @@ void main() {
..textDirection = TextDirection.ltr;
painter.text = const TextSpan(
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontSize: 10.0),
children: <TextSpan>[
TextSpan(
text: 'hello', // width 50
),
TextSpan(
text: 'lovely', // width 120
style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0),
style: TextStyle(fontSize: 20.0),
),
TextSpan(
text: 'world', // width 50
......@@ -368,14 +368,14 @@ void main() {
..textDirection = TextDirection.ltr;
painter.text = const TextSpan(
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontSize: 10.0),
children: <TextSpan>[
TextSpan(
text: 'hello', // width 50
),
TextSpan(
text: '\u062C\u0645\u064A\u0644', // width 80
style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0),
style: TextStyle(fontSize: 20.0),
),
TextSpan(
text: 'world', // width 50
......@@ -425,14 +425,14 @@ void main() {
..textDirection = TextDirection.rtl;
painter.text = const TextSpan(
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontSize: 10.0),
children: <TextSpan>[
TextSpan(
text: 'hello', // width 50
),
TextSpan(
text: '\u062C\u0645\u064A\u0644', // width 80
style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0),
style: TextStyle(fontSize: 20.0),
),
TextSpan(
text: 'world', // width 50
......@@ -463,7 +463,7 @@ void main() {
final String pyramid = rlo(lro(rlo(lro(rlo('')))));
painter.text = TextSpan(
text: pyramid,
style: const TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: const TextStyle(fontSize: 10.0),
);
painter.layout();
......@@ -494,7 +494,7 @@ void main() {
painter.text = const TextSpan(
text: 'ABC\u05D0\u05D1\u05D2DEF', // A B C Alef Bet Gimel D E F -- but the Hebrew letters are RTL
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontSize: 10.0),
);
painter.layout();
......@@ -578,7 +578,7 @@ void main() {
painter.text = const TextSpan(
text: '\u05D0\u05D1\u05D2ABC\u05D3\u05D4\u05D5',
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontSize: 10.0),
);
painter.layout();
......@@ -624,7 +624,7 @@ void main() {
painter.text = const TextSpan(
text: ' ',
style: TextStyle(fontFamily: 'Ahem', fontSize: 100.0),
style: TextStyle(fontSize: 100.0),
children: <TextSpan>[
TextSpan(
text: ' ',
......@@ -685,10 +685,10 @@ void main() {
..textDirection = TextDirection.ltr;
painter.text = const TextSpan(
text: '',
style: TextStyle(fontFamily: 'Ahem', fontSize: 100.0, height: 1.0),
style: TextStyle(fontFamily: 'FlutterTest', fontSize: 100.0, height: 1.0),
);
painter.layout();
expect(painter.computeDistanceToActualBaseline(TextBaseline.alphabetic), moreOrLessEquals(80.0, epsilon: 0.001));
expect(painter.computeDistanceToActualBaseline(TextBaseline.alphabetic), 75.0);
painter.dispose();
});
}
......
......@@ -199,11 +199,7 @@ void main() {
final TextPainter painter = TextPainter(
text: const TextSpan(
text: 'X',
style: TextStyle(
inherit: false,
fontFamily: 'Ahem',
fontSize: 123.0,
),
style: TextStyle(inherit: false, fontSize: 123.0),
),
textDirection: TextDirection.ltr,
);
......@@ -216,11 +212,7 @@ void main() {
final TextPainter painter = TextPainter(
text: const TextSpan(
text: 'X',
style: TextStyle(
inherit: false,
fontFamily: 'Ahem',
fontSize: 10.0,
),
style: TextStyle(inherit: false, fontSize: 10.0),
),
textDirection: TextDirection.ltr,
textScaleFactor: 2.0,
......@@ -268,7 +260,6 @@ void main() {
test('TextPainter intrinsic dimensions', () {
const TextStyle style = TextStyle(
inherit: false,
fontFamily: 'Ahem',
fontSize: 10.0,
);
TextPainter painter;
......
......@@ -21,9 +21,7 @@ void main() {
textSelectionDelegate: delegate,
text: const TextSpan(
text: 'test',
style: TextStyle(
height: 1.0, fontSize: 10.0, fontFamily: 'Ahem',
),
style: TextStyle(height: 1.0, fontSize: 10.0),
),
startHandleLayerLink: LayerLink(),
endHandleLayerLink: LayerLink(),
......
......@@ -148,7 +148,7 @@ void main() {
final RenderParagraph paragraph = RenderParagraph(
const TextSpan(
text: 'First ',
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontFamily: 'FlutterTest', fontSize: 10.0),
children: <InlineSpan>[
TextSpan(text: 'smallsecond ', style: TextStyle(fontSize: 5.0)),
TextSpan(text: 'third fourth fifth'),
......@@ -175,14 +175,14 @@ void main() {
// The widths of the boxes should match the calculations above.
// The heights should all be 10, except for the box for 'smallsecond ',
// which should have height 5, and be alphabetic baseline-aligned with
// 'First '. The Ahem font specifies alphabetic baselines at 0.2em above the
// bottom extent, and 0.8em below the top, so the difference in top
// alignment becomes (10px * 0.8 - 5px * 0.8) = 4px.
// 'First '. The test font specifies alphabetic baselines at 0.25em above
// the bottom extent, and 0.75em below the top, so the difference in top
// alignment becomes (10px * 0.75 - 5px * 0.75) = 3.75px.
// 'First ':
expect(boxes[0], const TextBox.fromLTRBD(0.0, 0.0, 60.0, 10.0, TextDirection.ltr));
// 'smallsecond ' in size 5:
expect(boxes[1], const TextBox.fromLTRBD(60.0, 4.0, 120.0, 9.0, TextDirection.ltr));
expect(boxes[1], const TextBox.fromLTRBD(60.0, 3.75, 120.0, 8.75, TextDirection.ltr));
// 'third fourth ':
expect(boxes[2], const TextBox.fromLTRBD(0.0, 10.0, 130.0, 20.0, TextDirection.ltr));
// 'fifth':
......@@ -193,7 +193,7 @@ void main() {
final RenderParagraph paragraph = RenderParagraph(
const TextSpan(
text: 'First ',
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontFamily: 'FlutterTest', fontSize: 10.0),
children: <InlineSpan>[
TextSpan(text: 'smallsecond ', style: TextStyle(fontSize: 8.0)),
TextSpan(text: 'third fourth fifth'),
......@@ -253,7 +253,7 @@ void main() {
const TextSpan(
text: 'This\n' // 4 characters * 10px font size = 40px width on the first line
'is a wrapping test. It should wrap at manual newlines, and if softWrap is true, also at spaces.',
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontSize: 10.0),
),
textDirection: TextDirection.ltr,
maxLines: 1,
......@@ -333,7 +333,7 @@ void main() {
text: "How do you write like you're running out of time? Write day and night like you're running out of time?",
// 0123456789 0123456789 012 345 0123456 012345 01234 012345678 012345678 0123 012 345 0123456 012345 01234
// 0 1 2 3 4 5 6 7 8 9 10 11 12
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontSize: 10.0),
),
textDirection: TextDirection.ltr,
);
......
......@@ -11,7 +11,6 @@ void main() {
const Center(
child: DefaultTextStyle(
style: TextStyle(
fontFamily: 'Ahem',
fontSize: 100.0,
),
child: Text('X', textDirection: TextDirection.ltr),
......@@ -25,11 +24,11 @@ void main() {
await tester.pumpWidget(
const Center(
child: Baseline(
baseline: 180.0,
baseline: 175.0,
baselineType: TextBaseline.alphabetic,
child: DefaultTextStyle(
style: TextStyle(
fontFamily: 'Ahem',
fontFamily: 'FlutterTest',
fontSize: 100.0,
),
child: Text('X', textDirection: TextDirection.ltr),
......@@ -40,7 +39,7 @@ void main() {
expect(tester.renderObject<RenderBox>(find.text('X')).size, const Size(100.0, 100.0));
expect(
tester.renderObject<RenderBox>(find.byType(Baseline)).size,
within<Size>(from: const Size(100.0, 200.0), distance: 0.001),
const Size(100.0, 200),
);
});
......
......@@ -454,8 +454,10 @@ void main() {
testWidgets('multiple baseline aligned children', (WidgetTester tester) async {
final UniqueKey key1 = UniqueKey();
final UniqueKey key2 = UniqueKey();
const double fontSize1 = 54;
const double fontSize2 = 14;
// The point size of the font must be a multiple of 4 until
// https://github.com/flutter/flutter/issues/122066 is resolved.
const double fontSize1 = 52;
const double fontSize2 = 12;
await tester.pumpWidget(
MaterialApp(
......@@ -466,11 +468,11 @@ void main() {
children: <Widget>[
Text('big text',
key: key1,
style: const TextStyle(fontSize: fontSize1),
style: const TextStyle(fontFamily: 'FlutterTest', fontSize: fontSize1),
),
Text('one\ntwo\nthree\nfour\nfive\nsix\nseven',
key: key2,
style: const TextStyle(fontSize: fontSize2),
style: const TextStyle(fontFamily: 'FlutterTest', fontSize: fontSize2),
),
],
),
......@@ -488,29 +490,28 @@ void main() {
// lines, but being aligned by the first line's baseline, they hang far
// below the baseline. The size of the parent row is just enough to
// contain both of them.
const double ahemBaselineLocation = 0.8; // https://web-platform-tests.org/writing-tests/ahem.html
const double aboveBaseline1 = fontSize1 * ahemBaselineLocation;
const double belowBaseline1 = fontSize1 * (1 - ahemBaselineLocation);
const double aboveBaseline2 = fontSize2 * ahemBaselineLocation;
const double belowBaseline2 = fontSize2 * (1 - ahemBaselineLocation) + fontSize2 * 6;
const double ascentRatio = 0.75;
const double aboveBaseline1 = fontSize1 * ascentRatio;
const double belowBaseline1 = fontSize1 * (1 - ascentRatio);
const double aboveBaseline2 = fontSize2 * ascentRatio;
const double belowBaseline2 = fontSize2 * (1 - ascentRatio) + fontSize2 * 6;
final double aboveBaseline = math.max(aboveBaseline1, aboveBaseline2);
final double belowBaseline = math.max(belowBaseline1, belowBaseline2);
expect(rowBox.size.height, greaterThan(textBox1.size.height));
expect(rowBox.size.height, greaterThan(textBox2.size.height));
expect(rowBox.size.height, moreOrLessEquals(aboveBaseline + belowBaseline, epsilon: .001));
expect(rowBox.size.height, aboveBaseline + belowBaseline, );
expect(tester.getTopLeft(find.byKey(key1)).dy, 0);
expect(
tester.getTopLeft(find.byKey(key2)).dy,
moreOrLessEquals(aboveBaseline1 - aboveBaseline2, epsilon: .001),
);
expect(tester.getTopLeft(find.byKey(key2)).dy, aboveBaseline1 - aboveBaseline2);
});
testWidgets('baseline aligned children account for a larger, no-baseline child size', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/58898
final UniqueKey key1 = UniqueKey();
final UniqueKey key2 = UniqueKey();
const double fontSize1 = 54;
const double fontSize2 = 14;
// The point size of the font must be a multiple of 4 until
// https://github.com/flutter/flutter/issues/122066 is resolved.
const double fontSize1 = 52;
const double fontSize2 = 12;
await tester.pumpWidget(
MaterialApp(
......@@ -521,11 +522,11 @@ void main() {
children: <Widget>[
Text('big text',
key: key1,
style: const TextStyle(fontSize: fontSize1),
style: const TextStyle(fontFamily: 'FlutterTest', fontSize: fontSize1),
),
Text('one\ntwo\nthree\nfour\nfive\nsix\nseven',
key: key2,
style: const TextStyle(fontSize: fontSize2),
style: const TextStyle(fontFamily: 'FlutterTest', fontSize: fontSize2),
),
const FlutterLogo(size: 250),
],
......@@ -544,16 +545,16 @@ void main() {
// lines, but being aligned by the first line's baseline, they hang far
// below the baseline. The FlutterLogo extends further than both Texts,
// so the size of the parent row should contain the FlutterLogo as well.
const double ahemBaselineLocation = 0.8; // https://web-platform-tests.org/writing-tests/ahem.html
const double aboveBaseline1 = fontSize1 * ahemBaselineLocation;
const double aboveBaseline2 = fontSize2 * ahemBaselineLocation;
const double ascentRatio = 0.75;
const double aboveBaseline1 = fontSize1 * ascentRatio;
const double aboveBaseline2 = fontSize2 * ascentRatio;
expect(rowBox.size.height, greaterThan(textBox1.size.height));
expect(rowBox.size.height, greaterThan(textBox2.size.height));
expect(rowBox.size.height, 250);
expect(tester.getTopLeft(find.byKey(key1)).dy, 0);
expect(
tester.getTopLeft(find.byKey(key2)).dy,
moreOrLessEquals(aboveBaseline1 - aboveBaseline2, epsilon: .001),
aboveBaseline1 - aboveBaseline2,
);
});
});
......
......@@ -9,7 +9,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
const double _crispText = 100.0; // this font size is selected to avoid needing any antialiasing.
const String _expText = 'Éxp'; // renders in Ahem as:
const String _expText = 'Éxp'; // renders in the test font as:
// ########
// ########
......
......@@ -8,7 +8,6 @@ import 'package:flutter_test/flutter_test.dart';
const TextStyle testFont = TextStyle(
color: Color(0xFF00FF00),
fontFamily: 'Ahem',
);
Future<void> pumpTest(WidgetTester tester, TargetPlatform platform) async {
......
......@@ -797,7 +797,7 @@ void main() {
child: SelectableText(
'abc def ghi',
dragStartBehavior: DragStartBehavior.down,
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
style: TextStyle(fontSize: 10.0),
),
),
),
......@@ -2071,19 +2071,19 @@ void main() {
child: SelectableText(
'A',
key: keyA,
style: const TextStyle(fontSize: 10.0),
style: const TextStyle(fontFamily: 'FlutterTest', fontSize: 10.0),
strutStyle: StrutStyle.disabled,
),
),
const Text(
'abc',
style: TextStyle(fontSize: 20.0),
style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0),
),
Expanded(
child: SelectableText(
'B',
key: keyB,
style: const TextStyle(fontSize: 30.0),
style: const TextStyle(fontFamily: 'FlutterTest', fontSize: 30.0),
strutStyle: StrutStyle.disabled,
),
),
......@@ -2092,17 +2092,17 @@ void main() {
),
);
// The Ahem font extends 0.2 * fontSize below the baseline.
// The test font extends 0.25 * fontSize below the baseline.
// So the three row elements line up like this:
//
// A abc B
// --------- baseline
// 2 4 6 space below the baseline = 0.2 * fontSize
// --------- rowBottomY
// A abc B
// ------------- baseline
// 2.5 5 7.5 space below the baseline = 0.25 * fontSize
// ------------- rowBottomY
final double rowBottomY = tester.getBottomLeft(find.byType(Row)).dy;
expect(tester.getBottomLeft(find.byKey(keyA)).dy, moreOrLessEquals(rowBottomY - 4.0, epsilon: 1e-3));
expect(tester.getBottomLeft(find.text('abc')).dy, moreOrLessEquals(rowBottomY - 2.0, epsilon: 1e-3));
expect(tester.getBottomLeft(find.byKey(keyA)).dy, rowBottomY - 5.0);
expect(tester.getBottomLeft(find.text('abc')).dy, rowBottomY - 2.5);
expect(tester.getBottomLeft(find.byKey(keyB)).dy, rowBottomY);
});
......@@ -2120,18 +2120,18 @@ void main() {
child: SelectableText(
'A',
key: keyA,
style: const TextStyle(fontSize: 10.0),
style: const TextStyle(fontFamily: 'FlutterTest', fontSize: 10.0),
),
),
const Text(
'abc',
style: TextStyle(fontSize: 20.0),
style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0),
),
Expanded(
child: SelectableText(
'B',
key: keyB,
style: const TextStyle(fontSize: 30.0),
style: const TextStyle(fontFamily: 'FlutterTest', fontSize: 30.0),
),
),
],
......@@ -2139,17 +2139,17 @@ void main() {
),
);
// The Ahem font extends 0.2 * fontSize below the baseline.
// The test font extends 0.25 * fontSize below the baseline.
// So the three row elements line up like this:
//
// A abc B
// --------- baseline
// 2 4 6 space below the baseline = 0.2 * fontSize
// --------- rowBottomY
// A abc B
// ------------- baseline
// 2.5 5 7.5 space below the baseline = 0.25 * fontSize
// ------------- rowBottomY
final double rowBottomY = tester.getBottomLeft(find.byType(Row)).dy;
expect(tester.getBottomLeft(find.byKey(keyA)).dy, moreOrLessEquals(rowBottomY - 4.0, epsilon: 1e-3));
expect(tester.getBottomLeft(find.text('abc')).dy, moreOrLessEquals(rowBottomY - 2.0, epsilon: 1e-3));
expect(tester.getBottomLeft(find.byKey(keyA)).dy, rowBottomY - 5.0);
expect(tester.getBottomLeft(find.text('abc')).dy, rowBottomY - 2.5);
expect(tester.getBottomLeft(find.byKey(keyB)).dy, rowBottomY);
});
......@@ -2445,7 +2445,7 @@ void main() {
testWidgets('semantic nodes of offscreen recognizers are marked hidden', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/100395.
final SemanticsTester semantics = SemanticsTester(tester);
const TextStyle textStyle = TextStyle(fontFamily: 'Ahem', fontSize: 200);
const TextStyle textStyle = TextStyle(fontSize: 200);
const String onScreenText = 'onscreen\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n';
const String offScreenText = 'off screen';
final ScrollController controller = ScrollController();
......
......@@ -11,7 +11,7 @@ import 'semantics_tester.dart';
void main() {
testWidgets('Semantics tester visits last child', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
const TextStyle textStyle = TextStyle(fontFamily: 'Ahem');
const TextStyle textStyle = TextStyle();
await tester.pumpWidget(
Text.rich(
TextSpan(
......
......@@ -1662,7 +1662,7 @@ class FakeEditable extends LeafRenderObjectWidget {
class FakeRenderEditable extends RenderEditable {
FakeRenderEditable(EditableTextState delegate) : super(
text: const TextSpan(
style: TextStyle(height: 1.0, fontSize: 10.0, fontFamily: 'Ahem'),
style: TextStyle(height: 1.0, fontSize: 10.0),
text: 'placeholder',
),
startHandleLayerLink: LayerLink(),
......
......@@ -135,7 +135,7 @@ void main() {
testWidgets('inline widgets works with ellipsis', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/35869
const TextStyle textStyle = TextStyle(fontFamily: 'Ahem');
const TextStyle textStyle = TextStyle();
await tester.pumpWidget(
Text.rich(
TextSpan(
......@@ -168,7 +168,7 @@ void main() {
testWidgets('inline widgets hitTest works with ellipsis', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/68559
const TextStyle textStyle = TextStyle(fontFamily: 'Ahem');
const TextStyle textStyle = TextStyle();
await tester.pumpWidget(
Text.rich(
TextSpan(
......@@ -514,7 +514,7 @@ void main() {
testWidgets('recognizers split semantic node', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
const TextStyle textStyle = TextStyle(fontFamily: 'Ahem');
const TextStyle textStyle = TextStyle();
await tester.pumpWidget(
Text.rich(
TextSpan(
......@@ -569,7 +569,7 @@ void main() {
testWidgets('semantic nodes of offscreen recognizers are marked hidden', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/100395.
final SemanticsTester semantics = SemanticsTester(tester);
const TextStyle textStyle = TextStyle(fontFamily: 'Ahem', fontSize: 200);
const TextStyle textStyle = TextStyle(fontSize: 200);
const String onScreenText = 'onscreen\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n';
const String offScreenText = 'off screen';
final ScrollController controller = ScrollController();
......@@ -637,7 +637,7 @@ void main() {
testWidgets('recognizers split semantic node when TextSpan overflows', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
const TextStyle textStyle = TextStyle(fontFamily: 'Ahem');
const TextStyle textStyle = TextStyle();
await tester.pumpWidget(
SizedBox(
height: 10,
......@@ -688,7 +688,7 @@ void main() {
testWidgets('recognizers split semantic nodes with text span labels', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
const TextStyle textStyle = TextStyle(fontFamily: 'Ahem');
const TextStyle textStyle = TextStyle();
await tester.pumpWidget(
Text.rich(
TextSpan(
......@@ -746,7 +746,7 @@ void main() {
testWidgets('recognizers split semantic node - bidi', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
const TextStyle textStyle = TextStyle(fontFamily: 'Ahem');
const TextStyle textStyle = TextStyle();
await tester.pumpWidget(
RichText(
text: TextSpan(
......@@ -827,7 +827,7 @@ void main() {
testWidgets('TapGesture recognizers contribute link semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
const TextStyle textStyle = TextStyle(fontFamily: 'Ahem');
const TextStyle textStyle = TextStyle();
await tester.pumpWidget(
Text.rich(
TextSpan(
......@@ -867,7 +867,7 @@ void main() {
testWidgets('inline widgets generate semantic nodes', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
const TextStyle textStyle = TextStyle(fontFamily: 'Ahem');
const TextStyle textStyle = TextStyle();
await tester.pumpWidget(
Text.rich(
TextSpan(
......@@ -941,7 +941,7 @@ void main() {
testWidgets('inline widgets semantic nodes scale', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
const TextStyle textStyle = TextStyle(fontFamily: 'Ahem');
const TextStyle textStyle = TextStyle();
await tester.pumpWidget(
Text.rich(
TextSpan(
......
......@@ -793,11 +793,11 @@ void main() {
await tester.pumpWidget(
const Center(
child: Baseline(
baseline: 180.0,
baseline: 175.0,
baselineType: TextBaseline.alphabetic,
child: DefaultTextStyle(
style: TextStyle(
fontFamily: 'Ahem',
fontFamily: 'FlutterTest',
fontSize: 100.0,
),
child: Wrap(
......@@ -813,7 +813,7 @@ void main() {
expect(tester.renderObject<RenderBox>(find.text('X')).size, const Size(100.0, 100.0));
expect(
tester.renderObject<RenderBox>(find.byType(Baseline)).size,
within<Size>(from: const Size(100.0, 200.0), distance: 0.001),
const Size(100.0, 200.0),
);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment