From f4551e6450165edcc2035d5b007797c818a4788e Mon Sep 17 00:00:00 2001 From: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Thu, 9 Mar 2023 11:05:32 -0800 Subject: [PATCH] Reland "Update test font (#121306)" (#122068) Reland "Update test font (#121306)" --- .../flutter/test/cupertino/button_test.dart | 1 - .../flutter/test/cupertino/route_test.dart | 2 +- .../test/cupertino/text_field_test.dart | 16 +- packages/flutter/test/material/chip_test.dart | 2 +- .../test/material/input_decorator_test.dart | 267 +++++++++--------- packages/flutter/test/material/tabs_test.dart | 16 +- .../test/material/text_field_test.dart | 50 ++-- .../test/material/theme_data_test.dart | 6 +- .../test/material/toggle_buttons_test.dart | 18 +- .../test/painting/text_painter_rtl_test.dart | 32 +-- .../test/painting/text_painter_test.dart | 13 +- .../test/rendering/editable_gesture_test.dart | 4 +- .../flutter/test/rendering/editable_test.dart | 90 ++---- .../test/rendering/paragraph_test.dart | 16 +- .../flutter/test/widgets/baseline_test.dart | 7 +- packages/flutter/test/widgets/basic_test.dart | 45 +-- .../test/widgets/default_colors_test.dart | 2 +- .../test/widgets/scrollable_fling_test.dart | 1 - .../test/widgets/selectable_text_test.dart | 44 +-- .../test/widgets/semantics_tester_test.dart | 2 +- .../test/widgets/text_selection_test.dart | 2 +- packages/flutter/test/widgets/text_test.dart | 20 +- packages/flutter/test/widgets/wrap_test.dart | 6 +- 23 files changed, 310 insertions(+), 352 deletions(-) diff --git a/packages/flutter/test/cupertino/button_test.dart b/packages/flutter/test/cupertino/button_test.dart index 72168d9cbf9a..e5e0cae05a4b 100644 --- a/packages/flutter/test/cupertino/button_test.dart +++ b/packages/flutter/test/cupertino/button_test.dart @@ -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, ); diff --git a/packages/flutter/test/cupertino/route_test.dart b/packages/flutter/test/cupertino/route_test.dart index 99186bc8373a..01e997c7fae5 100644 --- a/packages/flutter/test/cupertino/route_test.dart +++ b/packages/flutter/test/cupertino/route_test.dart @@ -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); }); diff --git a/packages/flutter/test/cupertino/text_field_test.dart b/packages/flutter/test/cupertino/text_field_test.dart index 5929a685f8e6..da1a86637295 100644 --- a/packages/flutter/test/cupertino/text_field_test.dart +++ b/packages/flutter/test/cupertino/text_field_test.dart @@ -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, ); diff --git a/packages/flutter/test/material/chip_test.dart b/packages/flutter/test/material/chip_test.dart index ad3b8d98ae5c..c5d16283fa40 100644 --- a/packages/flutter/test/material/chip_test.dart +++ b/packages/flutter/test/material/chip_test.dart @@ -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( diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index f078ea412122..00d85ad56f5d 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -31,7 +31,7 @@ Widget buildInputDecorator({ VisualDensity? visualDensity, Widget child = const Text( 'text', - style: TextStyle(fontFamily: 'Ahem', fontSize: 16.0), + style: TextStyle(fontSize: 16.0), ), }) { return MaterialApp( @@ -43,7 +43,7 @@ Widget buildInputDecorator({ inputDecorationTheme: inputDecorationTheme, visualDensity: visualDensity, useMaterial3: useMaterial3, - textTheme: const TextTheme(bodyLarge: TextStyle(fontFamily: 'Ahem', fontSize: 16.0)), + textTheme: const TextTheme(bodyLarge: TextStyle(fontSize: 16.0)), ), child: Align( alignment: Alignment.topLeft, @@ -173,9 +173,9 @@ void main() { // Overall height for this InputDecorator is 56dps: // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 56.0)); @@ -234,9 +234,9 @@ void main() { // Overall height for this InputDecorator is 56dps: // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding expect(tester.getTopLeft(find.text('label')).dy, 20.0); @@ -414,9 +414,9 @@ void main() { // Overall height for this InputDecorator is 56dps: // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 56.0)); @@ -510,9 +510,9 @@ void main() { // Overall height for this InputDecorator is 56dps: // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding expect(tester.getTopLeft(find.byKey(key)).dy, 20.0); @@ -991,7 +991,7 @@ void main() { // Overall height for this InputDecorator is 40.0dps // 12 - top padding - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding testWidgets('InputDecorator input/hint layout', (WidgetTester tester) async { // The hint aligns with the input text @@ -1035,15 +1035,15 @@ void main() { // label is "floating" (empty input or no focus) the layout is: // // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding // // When the label is not floating, it's vertically centered. // // 20 - top padding - // 16 - label (ahem font size 16dps) + // 16 - label (font size 16dps) // 20 - bottom padding (empty input text still appears here) @@ -1147,15 +1147,15 @@ void main() { // label is "floating" (empty input or no focus) the layout is: // // 8 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 8 - bottom padding // // When the label is not floating, it's vertically centered. // // 16 - top padding - // 16 - label (ahem font size 16dps) + // 16 - label (font size 16dps) // 16 - bottom padding (empty input text still appears here) // The label is not floating so it's vertically centered. @@ -1226,21 +1226,21 @@ void main() { // floating the layout is: // // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding // 8 - below the border padding - // 12 - help/error/counter text (ahem font size 12dps) + // 12 - help/error/counter text (font size 12dps) // // When the label is not floating, it's vertically centered in the space // above the subtext: // // 20 - top padding - // 16 - label (ahem font size 16dps) + // 16 - label (font size 16dps) // 20 - bottom padding (empty input text still appears here) // 8 - below the border padding - // 12 - help/error/counter text (ahem font size 12dps) + // 12 - help/error/counter text (font size 12dps) // isEmpty: true, the label is not floating expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 76.0)); @@ -1286,21 +1286,21 @@ void main() { // label is floating the layout is: // // 8 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 8 - bottom padding // 8 - below the border padding - // 12 - help/error/counter text (ahem font size 12dps) + // 12 - help/error/counter text (font size 12dps) // // When the label is not floating, it's vertically centered in the space // above the subtext: // // 16 - top padding - // 16 - label (ahem font size 16dps) + // 16 - label (font size 16dps) // 16 - bottom padding (empty input text still appears here) // 8 - below the border padding - // 12 - help/error/counter text (ahem font size 12dps) + // 12 - help/error/counter text (font size 12dps) // The layout of the error/helper/counter subtext doesn't change for dense layout. await tester.pumpWidget( buildInputDecorator( @@ -1484,12 +1484,12 @@ void main() { // Overall height for this InputDecorator is 100dps: // // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding // 8 - below the border padding - // 36 - error text (3 lines, ahem font size 12dps) + // 36 - error text (3 lines, font size 12dps) expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 100.0)); expect(tester.getTopLeft(find.text(kError3)), const Offset(12.0, 64.0)); @@ -1562,12 +1562,12 @@ void main() { // Overall height for this InputDecorator is 100dps: // // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding // 8 - below the border padding - // 36 - helper text (3 lines, ahem font size 12dps) + // 36 - helper text (3 lines, font size 12dps) expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 100.0)); expect(tester.getTopLeft(find.text(kHelper3)), const Offset(12.0, 64.0)); @@ -1653,7 +1653,7 @@ void main() { // Overall height for this InputDecorator is 40dps: // 12 - top padding - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding // // The prefix and suffix wrap the input text and are left and right justified @@ -1692,7 +1692,7 @@ void main() { // Overall height for this InputDecorator is 40dps: // 12 - top padding - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, kMinInteractiveDimension)); @@ -1794,7 +1794,7 @@ void main() { // the prefix and the suffix widget is surrounded with padding: // 12 - top padding // 4 - top prefix/suffix padding - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 4 - bottom prefix/suffix padding // 12 - bottom padding @@ -1836,7 +1836,7 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( 'text', - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); @@ -1846,16 +1846,16 @@ void main() { // overlapping the input a bit. // 12 - top padding // 100 - total height of prefix - // -16 - input prefix overlap (distance input top to baseline, not exact) - // 20 - input text (ahem font size 16dps) + // -15 - input prefix overlap (distance input top to baseline = 20 * 0.75) + // 20 - input text (font size 16dps) // 0 - bottom prefix/suffix padding // 12 - bottom padding expect(tester.getSize(find.byType(InputDecorator)).width, 800.0); - expect(tester.getSize(find.byType(InputDecorator)).height, moreOrLessEquals(128.0, epsilon: .0001)); + expect(tester.getSize(find.byType(InputDecorator)).height, 129.0); expect(tester.getSize(find.text('text')).height, 20.0); expect(tester.getSize(find.byKey(pKey)).height, 100.0); - expect(tester.getTopLeft(find.text('text')).dy, moreOrLessEquals(96, epsilon: .0001)); // 12 + 100 - 16 + expect(tester.getTopLeft(find.text('text')).dy, 97); // 12 + 100 - 15 expect(tester.getTopLeft(find.byKey(pKey)).dy, 12.0); // layout is a row: [prefix text suffix] @@ -1882,7 +1882,7 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( 'text', - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); @@ -1892,21 +1892,21 @@ void main() { // overlapping the input a bit. // 24 - top padding // 100 - total height of prefix - // -16 - input prefix overlap (distance input top to baseline, not exact) - // 20 - input text (ahem font size 16dps) + // -15 - input prefix overlap (distance input top to baseline, not exact) + // 20 - input text (font size 16dps) // 0 - bottom prefix/suffix padding // 16 - bottom padding // When a border is present, the input text and prefix/suffix are centered // within the input. Here, that will be content of height 106, including 2 - // extra pixels of space, centered within an input of height 144. That gives + // extra pixels of space, centered within an input of height 145. That gives // 19 pixels of space on each side of the content, so the prefix is - // positioned at 19, and the text is at 19+100-16=103. + // positioned at 19, and the text is at 19+100-15=104. expect(tester.getSize(find.byType(InputDecorator)).width, 800.0); - expect(tester.getSize(find.byType(InputDecorator)).height, moreOrLessEquals(144, epsilon: .0001)); + expect(tester.getSize(find.byType(InputDecorator)).height, 145); expect(tester.getSize(find.text('text')).height, 20.0); expect(tester.getSize(find.byKey(pKey)).height, 100.0); - expect(tester.getTopLeft(find.text('text')).dy, moreOrLessEquals(103, epsilon: .0001)); + expect(tester.getTopLeft(find.text('text')).dy, 104); expect(tester.getTopLeft(find.byKey(pKey)).dy, 19.0); // layout is a row: [prefix text suffix] @@ -1931,7 +1931,7 @@ void main() { // Overall height for this InputDecorator is 48dps because the prefix icon's minimum size // is 48x48 and the rest of the elements only require 40dps: // 12 - top padding - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 48.0)); @@ -2006,7 +2006,7 @@ void main() { // Overall height for this InputDecorator is 48dps because the prefix icon's minimum size // is 48x48 and the rest of the elements only require 40dps: // 12 - top padding - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 48.0)); @@ -2223,7 +2223,7 @@ void main() { // Overall height for this InputDecorator is 100dps because the prefix icon's size // is 100x100 and the rest of the elements only require 40dps: // 12 - top padding - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 100.0)); @@ -2295,13 +2295,13 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // Same as the default case above. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(12.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 12.0); }); testWidgets('align center', (WidgetTester tester) async { @@ -2319,13 +2319,13 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // Below the top aligned case. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(290.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 290.0); }); testWidgets('align bottom', (WidgetTester tester) async { @@ -2343,13 +2343,13 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // Below the center aligned case. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(568.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 568.0); }); testWidgets('align as a double', (WidgetTester tester) async { @@ -2367,13 +2367,13 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // In between the center and bottom aligned cases. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(498.5, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 498.5); }); testWidgets('works with density and content padding', (WidgetTester tester) async { @@ -2442,14 +2442,14 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // Similar to the case without a border, but with a little extra room at // the top to make room for the border. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(24.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 24.0); }); testWidgets('align center (default)', (WidgetTester tester) async { @@ -2468,13 +2468,13 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // Below the top aligned case. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(289.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 289.0); }); testWidgets('align bottom', (WidgetTester tester) async { @@ -2493,13 +2493,13 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // Below the center aligned case. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(564.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 564.0); }); }); @@ -2524,13 +2524,13 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // Same as the default case above. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(96, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 97.0); expect(tester.getTopLeft(find.byKey(pKey)).dy, 12.0); }); @@ -2554,13 +2554,13 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // Same as the default case above. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(96.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 97.0); expect(tester.getTopLeft(find.byKey(pKey)).dy, 12.0); }); @@ -2584,13 +2584,13 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // Top of the input + 100 prefix height - overlap - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(96.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 97.0); expect(tester.getTopLeft(find.byKey(pKey)).dy, 12.0); }); }); @@ -2618,14 +2618,14 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // In the middle of the expanded InputDecorator. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(331.0, epsilon: .0001)); - expect(tester.getTopLeft(find.byKey(pKey)).dy, moreOrLessEquals(247.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 331.5); + expect(tester.getTopLeft(find.byKey(pKey)).dy, 246.5); }); testWidgets('InputDecorator tall prefix with border align top', (WidgetTester tester) async { @@ -2650,13 +2650,13 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // Above the center example. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(108.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 109.0); // The prefix is positioned at the top of the input, so this value is // the same as the top aligned test without a prefix. expect(tester.getTopLeft(find.byKey(pKey)).dy, 24.0); @@ -2684,14 +2684,14 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // Below the center example. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(564.0, epsilon: .0001)); - expect(tester.getTopLeft(find.byKey(pKey)).dy, moreOrLessEquals(480.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 564.0); + expect(tester.getTopLeft(find.byKey(pKey)).dy, 479.0); }); testWidgets('InputDecorator tall prefix with border align double', (WidgetTester tester) async { @@ -2716,14 +2716,14 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // Between the top and center examples. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(354.3, epsilon: .0001)); - expect(tester.getTopLeft(find.byKey(pKey)).dy, moreOrLessEquals(270.3, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 354.75); + expect(tester.getTopLeft(find.byKey(pKey)).dy, 269.75); }); }); @@ -2744,14 +2744,14 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // The label causes the text to start slightly lower than it would // otherwise. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(28.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 28.0); }); testWidgets('align center', (WidgetTester tester) async { @@ -2770,14 +2770,14 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // The label reduces the amount of space available for text, so the // center is slightly lower. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(298.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 298.0); }); testWidgets('align bottom', (WidgetTester tester) async { @@ -2796,14 +2796,14 @@ void main() { // Set the fontSize so that everything works out to whole numbers. child: const Text( text, - style: TextStyle(fontFamily: 'Ahem', fontSize: 20.0), + style: TextStyle(fontFamily: 'FlutterTest', fontSize: 20.0), ), ), ); // The label reduces the amount of space available for text, but the // bottom line is still in the same place. - expect(tester.getTopLeft(find.text(text)).dy, moreOrLessEquals(568.0, epsilon: .0001)); + expect(tester.getTopLeft(find.text(text)).dy, 568.0); }); }); }); @@ -3147,12 +3147,12 @@ void main() { // Overall height for this InputDecorator is 76dps: // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding // 8 - below the border padding - // 12 - [counter helper/error] (ahem font size 12dps) + // 12 - [counter helper/error] (font size 12dps) expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 76.0)); expect(tester.getTopLeft(find.text('text')).dy, 28.0); @@ -3203,7 +3203,7 @@ void main() { // Overall height for this InputDecorator is 40dps: // 12 - top padding - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, kMinInteractiveDimension)); // 40 bumped up to minimum. @@ -3564,7 +3564,7 @@ void main() { // Overall height for this InputDecorator is 32dps: // 8 - top padding - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 8 - bottom padding // // The only difference from normal layout for this case is that the @@ -3596,7 +3596,7 @@ void main() { // Overall height for this InputDecorator is 40dps: // 12 - top padding - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, kMinInteractiveDimension)); // 40 bumped up to minimum. @@ -3625,7 +3625,7 @@ void main() { // The overall height is 18dps. This is shorter than // kMinInteractiveDimension, but because isDense is true, the minimum is // ignored. - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 2 - total vertical padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 18.0)); @@ -3650,7 +3650,7 @@ void main() { // kMinInteractiveDimension, but because isCollapsed is true, the minimum is // ignored. There is no padding at all, because isCollapsed doesn't support // contentPadding. - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 16.0)); expect(tester.getSize(find.text('text')).height, 16.0); @@ -3672,7 +3672,7 @@ void main() { // The requested overall height is 18dps, however the minimum height is // kMinInteractiveDimension because neither isDense or isCollapsed are true. - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 2 - total vertical padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, kMinInteractiveDimension)); @@ -3696,7 +3696,7 @@ void main() { // Overall height for this InputDecorator is 16dps. There is no minimum // height when InputDecoration.collapsed is used. - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 16.0)); expect(tester.getSize(find.text('text')).height, 16.0); @@ -3728,7 +3728,7 @@ void main() { testWidgets('InputDecorator with baseStyle', (WidgetTester tester) async { // Setting the baseStyle of the InputDecoration and the style of the input // text child to a smaller font reduces the InputDecoration's vertical size. - const TextStyle style = TextStyle(fontFamily: 'Ahem', fontSize: 10.0); + const TextStyle style = TextStyle(fontSize: 10.0); await tester.pumpWidget( buildInputDecorator( useMaterial3: useMaterial3, @@ -3746,15 +3746,15 @@ void main() { // floating the layout is: // // 12 - top padding - // 7.5 - floating label (ahem font size 10dps * 0.75 = 7.5) + // 7.5 - floating label (font size 10dps * 0.75 = 7.5) // 4 - floating label / input text gap - // 10 - input text (ahem font size 10dps) + // 10 - input text (font size 10dps) // 12 - bottom padding // // When the label is not floating, it's vertically centered. // // 17.75 - top padding - // 10 - label (ahem font size 10dps) + // 10 - label (font size 10dps) // 17.75 - bottom padding (empty input text still appears here) expect(tester.getSize(find.byType(InputDecorator)), Size(800.0, useMaterial3 ? 50.0 : kMinInteractiveDimension)); // 45.5 bumped up to minimum. @@ -3790,12 +3790,12 @@ void main() { // Overall height for this InputDecorator is 76dps. When the label is // floating the layout is: // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding // 8 - below the border padding - // 12 - help/error/counter text (ahem font size 12dps) + // 12 - help/error/counter text (font size 12dps) // Label is floating because isEmpty is false. expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 76.0)); @@ -3825,7 +3825,7 @@ void main() { // Overall height for this InputDecorator is 56dps. Layout is: // 20 - top padding - // 16 - label (ahem font size 16dps) + // 16 - label (font size 16dps) // 20 - bottom padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 56.0)); expect(tester.getTopLeft(find.text('label')).dy, 20.0); @@ -3850,7 +3850,7 @@ void main() { // Overall height for this InputDecorator is 56dps. Layout is: // 20 - top padding - // 16 - label (ahem font size 16dps) + // 16 - label (font size 16dps) // 20 - bottom padding // expect(tester.widget(find.text('prefix')).style.color, prefixStyle.color); expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 56.0)); @@ -3901,7 +3901,7 @@ void main() { // Overall height for this InputDecorator is 56dps. Layout is: // 20 - top padding - // 16 - label (ahem font size 16dps) + // 16 - label (font size 16dps) // 20 - bottom padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 56.0)); expect(tester.getTopLeft(find.text('label')).dy, 20.0); @@ -3929,7 +3929,7 @@ void main() { // Overall height for this InputDecorator is 56dps. Layout is: // 16 - top padding - // 16 - label (ahem font size 16dps) + // 16 - label (font size 16dps) // 16 - bottom padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 48.0)); expect(tester.getTopLeft(find.text('label')).dy, 16.0); @@ -3939,13 +3939,13 @@ void main() { }); testWidgets('InputDecorationTheme style overrides', (WidgetTester tester) async { - const TextStyle defaultStyle = TextStyle(fontFamily: 'Ahem', fontSize: 16.0); + const TextStyle defaultStyle = TextStyle(fontSize: 16.0); final TextStyle labelStyle = defaultStyle.merge(const TextStyle(color: Colors.red)); final TextStyle hintStyle = defaultStyle.merge(const TextStyle(color: Colors.green)); final TextStyle prefixStyle = defaultStyle.merge(const TextStyle(color: Colors.blue)); final TextStyle suffixStyle = defaultStyle.merge(const TextStyle(color: Colors.purple)); - const TextStyle style12 = TextStyle(fontFamily: 'Ahem', fontSize: 12.0); + const TextStyle style12 = TextStyle(fontSize: 12.0); final TextStyle helperStyle = style12.merge(const TextStyle(color: Colors.orange)); final TextStyle counterStyle = style12.merge(const TextStyle(color: Colors.orange)); @@ -3981,12 +3981,12 @@ void main() { // Overall height for this InputDecorator is 76dps. Layout is: // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - prefix/hint/input/suffix text (ahem font size 16dps) + // 16 - prefix/hint/input/suffix text (font size 16dps) // 12 - bottom padding // 8 - below the border padding - // 12 - help/error/counter text (ahem font size 12dps) + // 12 - help/error/counter text (font size 12dps) expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 76.0)); expect(tester.getTopLeft(find.text('label')).dy, 20.0); expect(tester.getBottomLeft(find.text('label')).dy, 36.0); @@ -4005,14 +4005,14 @@ void main() { }); testWidgets('InputDecorationTheme style overrides (focused)', (WidgetTester tester) async { - const TextStyle defaultStyle = TextStyle(fontFamily: 'Ahem', fontSize: 16.0); + const TextStyle defaultStyle = TextStyle(fontSize: 16.0); final TextStyle labelStyle = defaultStyle.merge(const TextStyle(color: Colors.red)); final TextStyle floatingLabelStyle = defaultStyle.merge(const TextStyle(color: Colors.indigo)); final TextStyle hintStyle = defaultStyle.merge(const TextStyle(color: Colors.green)); final TextStyle prefixStyle = defaultStyle.merge(const TextStyle(color: Colors.blue)); final TextStyle suffixStyle = defaultStyle.merge(const TextStyle(color: Colors.purple)); - const TextStyle style12 = TextStyle(fontFamily: 'Ahem', fontSize: 12.0); + const TextStyle style12 = TextStyle(fontSize: 12.0); final TextStyle helperStyle = style12.merge(const TextStyle(color: Colors.orange)); final TextStyle counterStyle = style12.merge(const TextStyle(color: Colors.orange)); @@ -4049,12 +4049,12 @@ void main() { // Overall height for this InputDecorator is 76dps. Layout is: // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - prefix/hint/input/suffix text (ahem font size 16dps) + // 16 - prefix/hint/input/suffix text (font size 16dps) // 12 - bottom padding // 8 - below the border padding - // 12 - help/error/counter text (ahem font size 12dps) + // 12 - help/error/counter text (font size 12dps) expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 76.0)); expect(tester.getTopLeft(find.text('label')).dy, 12.0); expect(tester.getBottomLeft(find.text('label')).dy, 24.0); @@ -5031,9 +5031,9 @@ void main() { // Overall height for this InputDecorator is 56dps: // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding const double inputDecoratorHeight = 56.0; const double inputDecoratorWidth = 800.0; @@ -5136,9 +5136,9 @@ void main() { // Overall height for this InputDecorator is 56dps: // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding const double inputDecoratorHeight = 56.0; const double inputDecoratorWidth = 800.0; @@ -5228,9 +5228,9 @@ void main() { // Overall height for this InputDecorator is 56dps: // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding const double inputDecoratorHeight = 56.0; const double inputDecoratorWidth = 800.0; @@ -5568,7 +5568,7 @@ void main() { await tester.pumpAndSettle(); - // floatingLabelHeight = 12 (ahem font size 16dps * 0.75 = 12) + // floatingLabelHeight = 12 (font size 16dps * 0.75 = 12) // labelY = -floatingLabelHeight/2 + borderWidth/2 expect(tester.getTopLeft(find.text('label')).dy, -4.0); }); @@ -6133,7 +6133,7 @@ void main() { }); testWidgets('InputDecorationTheme floatingLabelStyle overrides label widget styles when the widget is a text widget (focused)', (WidgetTester tester) async { - const TextStyle style16 = TextStyle(fontFamily: 'Ahem', fontSize: 16.0); + const TextStyle style16 = TextStyle(fontSize: 16.0); final TextStyle floatingLabelStyle = style16.merge(const TextStyle(color: Colors.indigo)); // This test also verifies that the default InputDecorator provides a @@ -6160,9 +6160,9 @@ void main() { // Overall height for this InputDecorator is 56dps: // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 56.0)); expect(tester.getTopLeft(find.text('label')).dy, 12.0); @@ -6175,7 +6175,7 @@ void main() { }); testWidgets('InputDecorationTheme labelStyle overrides label widget styles when the widget is a text widget', (WidgetTester tester) async { - const TextStyle styleDefaultSize = TextStyle(fontFamily: 'Ahem', fontSize: 16.0); + const TextStyle styleDefaultSize = TextStyle(fontSize: 16.0); final TextStyle labelStyle = styleDefaultSize.merge(const TextStyle(color: Colors.purple)); // This test also verifies that the default InputDecorator provides a @@ -6201,9 +6201,9 @@ void main() { // Overall height for this InputDecorator is 56dps: // 12 - top padding - // 12 - floating label (ahem font size 16dps * 0.75 = 12) + // 12 - floating label (font size 16dps * 0.75 = 12) // 4 - floating label / input text gap - // 16 - input text (ahem font size 16dps) + // 16 - input text (font size 16dps) // 12 - bottom padding expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 56.0)); expect(tester.getTopLeft(find.text('label')).dy, 20.0); @@ -6234,7 +6234,7 @@ void main() { await tester.pumpWidget(buildFrame(false)); await tester.pumpAndSettle(); - // floatingLabelHeight = 12 (ahem font size 16dps * 0.75 = 12) + // floatingLabelHeight = 12 (font size 16dps * 0.75 = 12) // labelY = -floatingLabelHeight/2 + borderWidth/2 expect(tester.getTopLeft(find.text('label')).dy, -5.5); @@ -6246,7 +6246,6 @@ void main() { testWidgets('hint style overflow works', (WidgetTester tester) async { final String hintText = 'hint text' * 20; const TextStyle hintStyle = TextStyle( - fontFamily: 'Ahem', fontSize: 14.0, overflow: TextOverflow.fade, ); diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 0eeeb1e808f2..c03d253fd1c6 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -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(find.byType(RichText)).text.style!.fontFamily, 'Ahem'); + expect(tester.renderObject(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(find.byType(RichText)).text.style!.fontFamily, 'Ahem'); + expect(tester.renderObject(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(find.byType(RichText)).text.style!.fontFamily, 'Ahem'); + expect(tester.renderObject(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(find.byType(RichText)).text.style!.fontFamily, 'Ahem'); + expect(tester.renderObject(find.byType(RichText)).text.style!.fontFamily, 'FlutterTest'); expect(tester.getSize(find.byType(Tab)), const Size(14.0, 72.0)); }); diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 727769d09606..644ab62c7958 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -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); }); diff --git a/packages/flutter/test/material/theme_data_test.dart b/packages/flutter/test/material/theme_data_test.dart index d962e228e53f..faaa81dfb9ec 100644 --- a/packages/flutter/test/material/theme_data_test.dart +++ b/packages/flutter/test/material/theme_data_test.dart @@ -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')); diff --git a/packages/flutter/test/material/toggle_buttons_test.dart b/packages/flutter/test/material/toggle_buttons_test.dart index 92930963c981..0a04140a56ec 100644 --- a/packages/flutter/test/material/toggle_buttons_test.dart +++ b/packages/flutter/test/material/toggle_buttons_test.dart @@ -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 [false, true], children: const [ - 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 { diff --git a/packages/flutter/test/painting/text_painter_rtl_test.dart b/packages/flutter/test/painting/text_painter_rtl_test.dart index 916c8a94a465..16d16c1bd23d 100644 --- a/packages/flutter/test/painting/text_painter_rtl_test.dart +++ b/packages/flutter/test/painting/text_painter_rtl_test.dart @@ -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( 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( 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( 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( 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(); }); } diff --git a/packages/flutter/test/painting/text_painter_test.dart b/packages/flutter/test/painting/text_painter_test.dart index 9c890b4940a5..bc37c1f859e9 100644 --- a/packages/flutter/test/painting/text_painter_test.dart +++ b/packages/flutter/test/painting/text_painter_test.dart @@ -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; diff --git a/packages/flutter/test/rendering/editable_gesture_test.dart b/packages/flutter/test/rendering/editable_gesture_test.dart index 3b5a615a774a..c53b9ea01239 100644 --- a/packages/flutter/test/rendering/editable_gesture_test.dart +++ b/packages/flutter/test/rendering/editable_gesture_test.dart @@ -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(), diff --git a/packages/flutter/test/rendering/editable_test.dart b/packages/flutter/test/rendering/editable_test.dart index 25edc2ab1315..5cb7b5dc2d09 100644 --- a/packages/flutter/test/rendering/editable_test.dart +++ b/packages/flutter/test/rendering/editable_test.dart @@ -192,7 +192,7 @@ void main() { final TextSelectionDelegate delegate = _FakeEditableTextState(); final RenderEditable editable = RenderEditable( text: const TextSpan( - style: TextStyle(height: 1.0, fontSize: 10.0, fontFamily: 'Ahem'), + style: TextStyle(height: 1.0, fontSize: 10.0), text: '12345', ), startHandleLayerLink: LayerLink(), @@ -227,7 +227,6 @@ void main() { ' ╘═╦══ text ═══\n' ' ║ TextSpan:\n' ' ║ inherit: true\n' - ' ║ family: Ahem\n' ' ║ size: 10.0\n' ' ║ height: 1.0x\n' ' ║ "12345"\n' @@ -243,7 +242,7 @@ void main() { final TextSelectionDelegate delegate = _FakeEditableTextState(); final RenderEditable editable = RenderEditable( text: const TextSpan( - style: TextStyle(height: 1.0, fontSize: 10.0, fontFamily: 'Ahem'), + style: TextStyle(height: 1.0, fontSize: 10.0), text: 'A', ), startHandleLayerLink: LayerLink(), @@ -278,9 +277,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(), @@ -384,8 +381,8 @@ void main() { editable.text = const TextSpan( children: [ - TextSpan(text: 'abc', style: TextStyle(fontSize: 12, fontFamily: 'Ahem')), - TextSpan(text: 'def', style: TextStyle(fontSize: 10, fontFamily: 'Ahem')), + TextSpan(text: 'abc', style: TextStyle(fontSize: 12)), + TextSpan(text: 'def', style: TextStyle(fontSize: 10)), ], ); expect(editable.plainText, 'abcdef'); @@ -407,9 +404,7 @@ void main() { textSelectionDelegate: delegate, text: const TextSpan( text: '中文测试文本是否正确', - style: TextStyle( - height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', - ), + style: TextStyle(fontSize: 10.0, fontFamily: 'FlutterTest'), ), startHandleLayerLink: LayerLink(), endHandleLayerLink: LayerLink(), @@ -483,7 +478,7 @@ void main() { text: const TextSpan( text: 'test', style: TextStyle( - height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', + height: 1.0, fontSize: 10.0, ), ), startHandleLayerLink: LayerLink(), @@ -523,9 +518,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(), @@ -579,9 +572,7 @@ void main() { endHandleLayerLink: LayerLink(), text: const TextSpan( text: text, - style: TextStyle( - height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', - ), + style: TextStyle(height: 1.0, fontSize: 10.0), ), selection: const TextSelection.collapsed( offset: 4, @@ -663,9 +654,7 @@ void main() { endHandleLayerLink: LayerLink(), text: const TextSpan( text: text, - style: TextStyle( - height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', - ), + style: TextStyle(height: 1.0, fontSize: 10.0), ), selection: const TextSelection.collapsed( offset: 4, @@ -702,9 +691,7 @@ void main() { endHandleLayerLink: LayerLink(), text: const TextSpan( text: text, - style: TextStyle( - height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', - ), + style: TextStyle(height: 1.0, fontSize: 10.0), ), selection: const TextSelection.collapsed( offset: 4, @@ -741,9 +728,7 @@ void main() { endHandleLayerLink: LayerLink(), text: const TextSpan( text: text, - style: TextStyle( - height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', - ), + style: TextStyle(height: 1.0, fontSize: 10.0), ), selection: const TextSelection.collapsed( offset: 4, @@ -775,9 +760,7 @@ void main() { textSelectionDelegate: delegate, text: const TextSpan( text: text, - style: TextStyle( - height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', - ), + style: TextStyle(height: 1.0, fontSize: 10.0), ), startHandleLayerLink: LayerLink(), endHandleLayerLink: LayerLink(), @@ -797,7 +780,7 @@ void main() { final TextSelectionDelegate delegate = _FakeEditableTextState(); final RenderEditable editable = RenderEditable( text: const TextSpan( - style: TextStyle(height: 1.0, fontSize: 10.0, fontFamily: 'Ahem'), + style: TextStyle(height: 1.0, fontSize: 10.0), text: 'ABCDEFG', ), startHandleLayerLink: LayerLink(), @@ -836,7 +819,7 @@ void main() { final TextSelectionDelegate delegate = _FakeEditableTextState(); final RenderEditable editable = RenderEditable( text: const TextSpan( - style: TextStyle(height: 1.0, fontSize: 10.0, fontFamily: 'Ahem'), + style: TextStyle(height: 1.0, fontSize: 10.0), text: '12345', ), textDirection: TextDirection.ltr, @@ -964,8 +947,8 @@ void main() { }); test('more than 1 run on the same line', () { - const TextStyle tinyText = TextStyle(fontSize: 1, fontFamily: 'Ahem'); - const TextStyle normalText = TextStyle(fontSize: 10, fontFamily: 'Ahem'); + const TextStyle tinyText = TextStyle(fontSize: 1); + const TextStyle normalText = TextStyle(fontSize: 10); editable.text = TextSpan( children: [ const TextSpan(text: 'A', style: tinyText), @@ -996,7 +979,6 @@ void main() { style: TextStyle( height: 1.0, fontSize: 10.0, - fontFamily: 'Ahem', ), ), startHandleLayerLink: LayerLink(), @@ -1198,7 +1180,7 @@ void main() { final TextSelectionDelegate delegate = _FakeEditableTextState(); final RenderEditable editable = RenderEditable( text: const TextSpan( - style: TextStyle(height: 1.0, fontSize: 10.0, fontFamily: 'Ahem'), + style: TextStyle(height: 1.0, fontSize: 10.0), children: [ TextSpan(text: 'A'), TextSpan(text: 'B'), @@ -1240,7 +1222,7 @@ void main() { final TextSelectionDelegate delegate = _FakeEditableTextState(); final RenderEditable editable = RenderEditable( text: const TextSpan( - style: TextStyle(height: 1.0, fontSize: 10.0, fontFamily: 'Ahem'), + style: TextStyle(height: 1.0, fontSize: 10.0), children: [ TextSpan(text: 'A'), TextSpan(text: 'B\n'), @@ -1291,7 +1273,7 @@ void main() { final TextSelectionDelegate delegate = _FakeEditableTextState(); final RenderEditable editable = RenderEditable( text: const TextSpan( - style: TextStyle(height: 1.0, fontSize: 10.0, fontFamily: 'Ahem'), + style: TextStyle(height: 1.0, fontSize: 10.0), children: [ TextSpan(text: 'A'), TextSpan(text: 'B'), @@ -1345,9 +1327,7 @@ void main() { startHandleLayerLink: LayerLink(), endHandleLayerLink: LayerLink(), text: TextSpan( - style: const TextStyle( - height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', - ), + style: const TextStyle(height: 1.0, fontSize: 10.0), children: [ const TextSpan(text: 'test'), WidgetSpan(child: Container(width: 10, height: 10, color: Colors.blue)), @@ -1387,9 +1367,7 @@ void main() { startHandleLayerLink: LayerLink(), endHandleLayerLink: LayerLink(), text: TextSpan( - style: const TextStyle( - height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', - ), + style: const TextStyle(height: 1.0, fontSize: 10.0), children: [ const TextSpan(text: 'test'), WidgetSpan(child: Container(width: 10, height: 10, color: Colors.blue)), @@ -1431,9 +1409,7 @@ void main() { startHandleLayerLink: LayerLink(), endHandleLayerLink: LayerLink(), text: const TextSpan( - style: TextStyle( - height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', - ), + style: TextStyle(height: 1.0, fontSize: 10.0), children: [ TextSpan(text: 'test'), WidgetSpan(child: Text('b')), @@ -1481,9 +1457,7 @@ void main() { startHandleLayerLink: LayerLink(), endHandleLayerLink: LayerLink(), text: const TextSpan( - style: TextStyle( - height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', - ), + style: TextStyle(height: 1.0, fontSize: 10.0), children: [ TextSpan(text: 'test'), WidgetSpan(child: Text('b')), @@ -1538,9 +1512,7 @@ void main() { startHandleLayerLink: LayerLink(), endHandleLayerLink: LayerLink(), text: const TextSpan( - style: TextStyle( - height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', - ), + style: TextStyle(height: 1.0, fontSize: 10.0), children: [ TextSpan(text: 'test'), WidgetSpan(child: Text('a')), @@ -1596,9 +1568,7 @@ void main() { startHandleLayerLink: LayerLink(), endHandleLayerLink: LayerLink(), text: const TextSpan( - style: TextStyle( - height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', - ), + style: TextStyle(height: 1.0, fontSize: 10.0), children: [ TextSpan(text: 'test'), WidgetSpan(child: Text('a')), @@ -1631,7 +1601,7 @@ void main() { ]; final RenderEditable editable = RenderEditable( text: const TextSpan( - style: TextStyle(height: 1.0, fontSize: 10.0, fontFamily: 'Ahem'), + style: TextStyle(height: 1.0, fontSize: 10.0), children: [ TextSpan(text: 'test'), WidgetSpan(child: Text('a')), @@ -1705,7 +1675,7 @@ void main() { const BoxConstraints constraints = BoxConstraints(minWidth: 100, maxWidth: 500); final RenderEditable editable = RenderEditable( text: const TextSpan( - style: TextStyle(height: 1.0, fontSize: 10.0, fontFamily: 'Ahem'), + style: TextStyle(height: 1.0, fontSize: 10.0), text: 'A', ), startHandleLayerLink: LayerLink(), @@ -1743,9 +1713,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), ), maxLines: 3, startHandleLayerLink: LayerLink(), diff --git a/packages/flutter/test/rendering/paragraph_test.dart b/packages/flutter/test/rendering/paragraph_test.dart index b64de811240e..9525807473ca 100644 --- a/packages/flutter/test/rendering/paragraph_test.dart +++ b/packages/flutter/test/rendering/paragraph_test.dart @@ -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: [ 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: [ 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, ); diff --git a/packages/flutter/test/widgets/baseline_test.dart b/packages/flutter/test/widgets/baseline_test.dart index e3555a045256..707707fdc8fa 100644 --- a/packages/flutter/test/widgets/baseline_test.dart +++ b/packages/flutter/test/widgets/baseline_test.dart @@ -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(find.text('X')).size, const Size(100.0, 100.0)); expect( tester.renderObject(find.byType(Baseline)).size, - within(from: const Size(100.0, 200.0), distance: 0.001), + const Size(100.0, 200), ); }); diff --git a/packages/flutter/test/widgets/basic_test.dart b/packages/flutter/test/widgets/basic_test.dart index 8c885eb1ec1d..060cf6f33b9a 100644 --- a/packages/flutter/test/widgets/basic_test.dart +++ b/packages/flutter/test/widgets/basic_test.dart @@ -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: [ 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: [ 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, ); }); }); diff --git a/packages/flutter/test/widgets/default_colors_test.dart b/packages/flutter/test/widgets/default_colors_test.dart index c076577546e2..43f924bad3b2 100644 --- a/packages/flutter/test/widgets/default_colors_test.dart +++ b/packages/flutter/test/widgets/default_colors_test.dart @@ -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: // ######## // ######## diff --git a/packages/flutter/test/widgets/scrollable_fling_test.dart b/packages/flutter/test/widgets/scrollable_fling_test.dart index aaedfd47c891..3d521377007b 100644 --- a/packages/flutter/test/widgets/scrollable_fling_test.dart +++ b/packages/flutter/test/widgets/scrollable_fling_test.dart @@ -8,7 +8,6 @@ import 'package:flutter_test/flutter_test.dart'; const TextStyle testFont = TextStyle( color: Color(0xFF00FF00), - fontFamily: 'Ahem', ); Future pumpTest(WidgetTester tester, TargetPlatform platform) async { diff --git a/packages/flutter/test/widgets/selectable_text_test.dart b/packages/flutter/test/widgets/selectable_text_test.dart index 291671ecb813..780e34ae9bcf 100644 --- a/packages/flutter/test/widgets/selectable_text_test.dart +++ b/packages/flutter/test/widgets/selectable_text_test.dart @@ -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(); diff --git a/packages/flutter/test/widgets/semantics_tester_test.dart b/packages/flutter/test/widgets/semantics_tester_test.dart index d5d8d33de02d..c5a9de1763cb 100644 --- a/packages/flutter/test/widgets/semantics_tester_test.dart +++ b/packages/flutter/test/widgets/semantics_tester_test.dart @@ -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( diff --git a/packages/flutter/test/widgets/text_selection_test.dart b/packages/flutter/test/widgets/text_selection_test.dart index e05d6860bb8c..a3ed97fdad31 100644 --- a/packages/flutter/test/widgets/text_selection_test.dart +++ b/packages/flutter/test/widgets/text_selection_test.dart @@ -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(), diff --git a/packages/flutter/test/widgets/text_test.dart b/packages/flutter/test/widgets/text_test.dart index dc9e8ccd6221..603ba0319708 100644 --- a/packages/flutter/test/widgets/text_test.dart +++ b/packages/flutter/test/widgets/text_test.dart @@ -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( diff --git a/packages/flutter/test/widgets/wrap_test.dart b/packages/flutter/test/widgets/wrap_test.dart index c6e56a5876c6..70cd91dd139f 100644 --- a/packages/flutter/test/widgets/wrap_test.dart +++ b/packages/flutter/test/widgets/wrap_test.dart @@ -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(find.text('X')).size, const Size(100.0, 100.0)); expect( tester.renderObject(find.byType(Baseline)).size, - within(from: const Size(100.0, 200.0), distance: 0.001), + const Size(100.0, 200.0), ); });