Making TextPainter rounding hack disabled by default (#132094)

Migrate tests in flutter/flutter. Once the tests here and in `*_customer_testing` are migrated, the default value of the migration flag will be changed from false to true, making the rounding hack disabled by default.
This commit is contained in:
LongCatIsLooong 2023-08-09 17:30:52 -07:00 committed by GitHub
parent 118c2df776
commit 3f831b694f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 486 additions and 471 deletions

View File

@ -102,7 +102,7 @@ final String flutterTester = path.join(flutterRoot, 'bin', 'cache', 'artifacts',
/// The arguments to pass to `flutter test` (typically the local engine /// The arguments to pass to `flutter test` (typically the local engine
/// configuration) -- prefilled with the arguments passed to test.dart. /// configuration) -- prefilled with the arguments passed to test.dart.
final List<String> flutterTestArgs = <String>[]; final List<String> flutterTestArgs = <String>['--dart-define=SKPARAGRAPH_REMOVE_ROUNDING_HACK=true'];
/// Environment variables to override the local engine when running `pub test`, /// Environment variables to override the local engine when running `pub test`,
/// if such flags are provided to `test.dart`. /// if such flags are provided to `test.dart`.
@ -1309,8 +1309,8 @@ Future<void> _runFlutterDriverWebTest({
await runCommand( await runCommand(
flutter, flutter,
<String>[ <String>[
...flutterTestArgs,
'drive', 'drive',
...flutterTestArgs,
if (driver != null) '--driver=$driver', if (driver != null) '--driver=$driver',
'--target=$target', '--target=$target',
'--browser-name=chrome', '--browser-name=chrome',
@ -1584,8 +1584,8 @@ Future<void> _runGalleryE2eWebTest(String buildMode, { bool canvasKit = false })
await runCommand( await runCommand(
flutter, flutter,
<String>[ <String>[
...flutterTestArgs,
'drive', 'drive',
...flutterTestArgs,
if (canvasKit) if (canvasKit)
'--dart-define=FLUTTER_WEB_USE_SKIA=true', '--dart-define=FLUTTER_WEB_USE_SKIA=true',
if (!canvasKit) if (!canvasKit)
@ -1665,10 +1665,10 @@ Future<void> _runWebReleaseTest(String target, {
await runCommand( await runCommand(
flutter, flutter,
<String>[ <String>[
...flutterTestArgs,
'build', 'build',
'web', 'web',
'--release', '--release',
...flutterTestArgs,
...additionalArguments, ...additionalArguments,
'-t', '-t',
target, target,

View File

@ -105,7 +105,7 @@ void main() {
await tester.tap(find.text('Small')); await tester.tap(find.text('Small'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
Size textSize = tester.getSize(find.text('Text size')); Size textSize = tester.getSize(find.text('Text size'));
expect(textSize, equals(const Size(116.0, 13.0))); expect(textSize, equals(within(distance: 0.05, from: const Size(115.2, 13.0))));
// Set font scale back to the default. // Set font scale back to the default.
await tester.tap(find.byIcon(Icons.arrow_drop_down).at(1)); await tester.tap(find.byIcon(Icons.arrow_drop_down).at(1));

View File

@ -42,7 +42,7 @@ void main() {
final Finder extendedFABMaterialButton = find.byType(RawMaterialButton).at(3); final Finder extendedFABMaterialButton = find.byType(RawMaterialButton).at(3);
final RenderBox extendedFABRenderBox = tester.renderObject(extendedFABMaterialButton); final RenderBox extendedFABRenderBox = tester.renderObject(extendedFABMaterialButton);
expect(extendedFABRenderBox.size, const Size(111.0, 56.0)); expect(extendedFABRenderBox.size, within(distance: 0.01, from: const Size(110.3, 56.0)));
expect(getRawMaterialButtonWidget(extendedFABMaterialButton).fillColor, theme.colorScheme.primaryContainer); expect(getRawMaterialButtonWidget(extendedFABMaterialButton).fillColor, theme.colorScheme.primaryContainer);
expect(getRawMaterialButtonWidget(extendedFABMaterialButton).shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0))); expect(getRawMaterialButtonWidget(extendedFABMaterialButton).shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)));
}); });

View File

@ -29,7 +29,7 @@ void main() {
expect(find.text('About', findRichText: true), findsOneWidget); expect(find.text('About', findRichText: true), findsOneWidget);
expect( expect(
tester.getRect(findMenu('About')), tester.getRect(findMenu('About')),
equals(const Rect.fromLTRB(4.0, 48.0, 111.0, 208.0)), equals(const Rect.fromLTRB(4.0, 48.0, 110.5, 208.0)),
); );
expect(find.text('Save', findRichText: true), findsOneWidget); expect(find.text('Save', findRichText: true), findsOneWidget);
expect(find.text('Quit', findRichText: true), findsOneWidget); expect(find.text('Quit', findRichText: true), findsOneWidget);

View File

@ -513,7 +513,13 @@ class TextPainter {
_locale = locale, _locale = locale,
_strutStyle = strutStyle, _strutStyle = strutStyle,
_textWidthBasis = textWidthBasis, _textWidthBasis = textWidthBasis,
_textHeightBehavior = textHeightBehavior; _textHeightBehavior = textHeightBehavior,
assert(() {
if (const bool.fromEnvironment('SKPARAGRAPH_REMOVE_ROUNDING_HACK')) {
ui.ParagraphBuilder.setDisableRoundingHack(true);
}
return true;
}());
/// Computes the width of a configured [TextPainter]. /// Computes the width of a configured [TextPainter].
/// ///

View File

@ -344,11 +344,9 @@ void main() {
// regular font. However, when using the test font, "Cancel" becomes 2 lines which // regular font. However, when using the test font, "Cancel" becomes 2 lines which
// is why the height we're verifying for "Cancel" is larger than "OK". // is why the height we're verifying for "Cancel" is larger than "OK".
// TODO(yjbanov): https://github.com/flutter/flutter/issues/99933 if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
// A bug in the HTML renderer and/or Chrome 96+ causes a expect(tester.getSize(find.text('The Title')), equals(const Size(270.0, 132.0)));
// discrepancy in the paragraph height. }
const bool hasIssue99933 = kIsWeb && !bool.fromEnvironment('FLUTTER_WEB_USE_SKIA');
expect(tester.getSize(find.text('The Title')), equals(const Size(270.0, hasIssue99933 ? 133 : 132.0)));
expect(tester.getTopLeft(find.text('The Title')), equals(const Offset(265.0, 80.0 + 24.0))); expect(tester.getTopLeft(find.text('The Title')), equals(const Offset(265.0, 80.0 + 24.0)));
expect(tester.getSize(find.widgetWithText(CupertinoDialogAction, 'Cancel')), equals(const Size(310.0, 148.0))); expect(tester.getSize(find.widgetWithText(CupertinoDialogAction, 'Cancel')), equals(const Size(310.0, 148.0)));
expect(tester.getSize(find.widgetWithText(CupertinoDialogAction, 'OK')), equals(const Size(310.0, 98.0))); expect(tester.getSize(find.widgetWithText(CupertinoDialogAction, 'OK')), equals(const Size(310.0, 98.0)));

View File

@ -145,15 +145,15 @@ void main() {
// place. // place.
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).first), tester.getTopLeft(flying(tester, find.text('Page 1')).first),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 342.547737105096302912 : 342.33420100808144, 342.547737105096302912,
13.5, 13.5,
), ),
); );
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).last), tester.getTopLeft(flying(tester, find.text('Page 1')).last),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 342.547737105096302912 : 342.33420100808144, 342.547737105096302912,
13.5, 13.5,
), ),
); );
@ -172,15 +172,15 @@ void main() {
// Same as LTR but more to the right now. // Same as LTR but more to the right now.
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).first), tester.getTopLeft(flying(tester, find.text('Page 1')).first),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 357.912261979376353338 : 357.66579899191856, 357.912261979376353338,
13.5, 13.5,
), ),
); );
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).last), tester.getTopLeft(flying(tester, find.text('Page 1')).last),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 357.912261979376353338 : 357.66579899191856, 357.912261979376353338,
13.5, 13.5,
), ),
); );
@ -371,8 +371,8 @@ void main() {
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).first), tester.getTopLeft(flying(tester, find.text('Page 1')).first),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 342.547737105096302912 : 342.33420100808144, 342.547737105096302912,
13.5, 13.5,
), ),
); );
@ -384,8 +384,8 @@ void main() {
expect(topBackLabel.text.style!.color, const Color(0xff000306)); expect(topBackLabel.text.style!.color, const Color(0xff000306));
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).last), tester.getTopLeft(flying(tester, find.text('Page 1')).last),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 342.547737105096302912 : 342.33420100808144, 342.547737105096302912,
13.5, 13.5,
), ),
); );
@ -422,8 +422,8 @@ void main() {
expect(bottomMiddle.text.style!.color, const Color(0xff000306)); expect(bottomMiddle.text.style!.color, const Color(0xff000306));
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).first), tester.getTopLeft(flying(tester, find.text('Page 1')).first),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 357.912261979376353338 : 357.66579899191856, 357.912261979376353338,
13.5, 13.5,
), ),
); );
@ -435,8 +435,8 @@ void main() {
expect(topBackLabel.text.style!.color, const Color(0xff000306)); expect(topBackLabel.text.style!.color, const Color(0xff000306));
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).last), tester.getTopLeft(flying(tester, find.text('Page 1')).last),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 357.912261979376353338 : 357.66579899191856, 357.912261979376353338,
13.5, 13.5,
), ),
); );
@ -736,15 +736,15 @@ void main() {
); );
// Come in from the right and fade in. // Come in from the right and fade in.
checkOpacity(tester, backChevron, 0.0); checkOpacity(tester, backChevron, 0.0);
expect(tester.getTopLeft(backChevron), Offset( expect(tester.getTopLeft(backChevron), const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 87.2460581221158690823 : 88.04496401548386, 87.2460581221158690823,
7.0, 7.0,
)); ));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
checkOpacity(tester, backChevron, 0.09497911669313908); checkOpacity(tester, backChevron, 0.09497911669313908);
expect(tester.getTopLeft(backChevron), Offset( expect(tester.getTopLeft(backChevron), const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 30.8718595298545324113 : 31.055883467197418, 30.8718595298545324113,
7.0, 7.0,
)); ));
}); });
@ -784,8 +784,8 @@ void main() {
checkOpacity(tester, backChevron, 0.0); checkOpacity(tester, backChevron, 0.0);
expect( expect(
tester.getTopRight(backChevron), tester.getTopRight(backChevron),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 687.163941725296126606 : 685.9550359845161, 687.163941725296126606,
7.0, 7.0,
), ),
); );
@ -794,8 +794,8 @@ void main() {
checkOpacity(tester, backChevron, 0.09497911669313908); checkOpacity(tester, backChevron, 0.09497911669313908);
expect( expect(
tester.getTopRight(backChevron), tester.getTopRight(backChevron),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 743.538140317557690651 : 742.9441165328026, 743.538140317557690651,
7.0, 7.0,
), ),
); );
@ -899,8 +899,8 @@ void main() {
checkOpacity(tester, flying(tester, find.text('custom')), 0.9280824661254883); checkOpacity(tester, flying(tester, find.text('custom')), 0.9280824661254883);
expect( expect(
tester.getTopLeft(flying(tester, find.text('custom'))), tester.getTopLeft(flying(tester, find.text('custom'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 684.459999084472656250 : 684.0, 684.459999084472656250,
13.5, 13.5,
), ),
); );
@ -909,8 +909,8 @@ void main() {
checkOpacity(tester, flying(tester, find.text('custom')), 0.0); checkOpacity(tester, flying(tester, find.text('custom')), 0.0);
expect( expect(
tester.getTopLeft(flying(tester, find.text('custom'))), tester.getTopLeft(flying(tester, find.text('custom'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 684.459999084472656250 : 684.0, 684.459999084472656250,
13.5, 13.5,
), ),
); );
@ -941,8 +941,8 @@ void main() {
checkOpacity(tester, flying(tester, find.text('Page 1')), 0.7952219992876053); checkOpacity(tester, flying(tester, find.text('Page 1')), 0.7952219992876053);
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1'))), tester.getTopLeft(flying(tester, find.text('Page 1'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 41.3003370761871337891 : 41.71033692359924, 41.3003370761871337891,
13.5, 13.5,
), ),
); );
@ -951,8 +951,8 @@ void main() {
checkOpacity(tester, flying(tester, find.text('Page 1')), 0.0); checkOpacity(tester, flying(tester, find.text('Page 1')), 0.0);
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1'))), tester.getTopLeft(flying(tester, find.text('Page 1'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? -258.642192125320434570 : -258.2321922779083, -258.642192125320434570,
13.5, 13.5,
), ),
); );
@ -984,8 +984,8 @@ void main() {
checkOpacity(tester, flying(tester, find.text('Page 1')), 0.7952219992876053); checkOpacity(tester, flying(tester, find.text('Page 1')), 0.7952219992876053);
expect( expect(
tester.getTopRight(flying(tester, find.text('Page 1'))), tester.getTopRight(flying(tester, find.text('Page 1'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 758.699662923812866211 : 758.2896630764008, 758.699662923812866211,
13.5, 13.5,
), ),
); );
@ -995,8 +995,8 @@ void main() {
expect( expect(
tester.getTopRight(flying(tester, find.text('Page 1'))), tester.getTopRight(flying(tester, find.text('Page 1'))),
// >1000. It's now off the screen. // >1000. It's now off the screen.
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 1058.64219212532043457 : 1058.2321922779083, 1058.64219212532043457,
13.5, 13.5,
), ),
); );
@ -1021,15 +1021,15 @@ void main() {
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).first), tester.getTopLeft(flying(tester, find.text('Page 1')).first),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 16.9155227761479522997 : 16.926069676876068, 16.9155227761479522997,
52.73951627314091, 52.73951627314091,
), ),
); );
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).last), tester.getTopLeft(flying(tester, find.text('Page 1')).last),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 16.9155227761479522997 : 16.926069676876068, 16.9155227761479522997,
52.73951627314091, 52.73951627314091,
), ),
); );
@ -1040,15 +1040,15 @@ void main() {
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).first), tester.getTopLeft(flying(tester, find.text('Page 1')).first),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 43.6029094262710827934 : 43.92089730501175, 43.6029094262710827934,
22.49655644595623, 22.49655644595623,
), ),
); );
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).last), tester.getTopLeft(flying(tester, find.text('Page 1')).last),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 43.6029094262710827934 : 43.92089730501175, 43.6029094262710827934,
22.49655644595623, 22.49655644595623,
), ),
); );
@ -1072,15 +1072,15 @@ void main() {
checkOpacity(tester, flying(tester, find.text('Back')), 0.0); checkOpacity(tester, flying(tester, find.text('Back')), 0.0);
expect( expect(
tester.getTopLeft(flying(tester, find.text('A title too long to fit'))), tester.getTopLeft(flying(tester, find.text('A title too long to fit'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 16.9155227761479522997 : 16.926069676876068, 16.9155227761479522997,
52.73951627314091, 52.73951627314091,
), ),
); );
expect( expect(
tester.getTopLeft(flying(tester, find.text('Back'))), tester.getTopLeft(flying(tester, find.text('Back'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 16.9155227761479522997 : 16.926069676876068, 16.9155227761479522997,
52.73951627314091, 52.73951627314091,
), ),
); );
@ -1090,15 +1090,15 @@ void main() {
checkOpacity(tester, flying(tester, find.text('Back')), 0.4604858811944723); checkOpacity(tester, flying(tester, find.text('Back')), 0.4604858811944723);
expect( expect(
tester.getTopLeft(flying(tester, find.text('A title too long to fit'))), tester.getTopLeft(flying(tester, find.text('A title too long to fit'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 43.6029094262710827934 : 43.92089730501175, 43.6029094262710827934,
22.49655644595623, 22.49655644595623,
), ),
); );
expect( expect(
tester.getTopLeft(flying(tester, find.text('Back'))), tester.getTopLeft(flying(tester, find.text('Back'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 43.6029094262710827934 : 43.92089730501175, 43.6029094262710827934,
22.49655644595623, 22.49655644595623,
), ),
); );
@ -1156,8 +1156,8 @@ void main() {
checkOpacity(tester, flying(tester, find.text('Page 2')), 0.0); checkOpacity(tester, flying(tester, find.text('Page 2')), 0.0);
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 2'))), tester.getTopLeft(flying(tester, find.text('Page 2'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 739.940336465835571289 : 739.7103369235992, 739.940336465835571289,
13.5, 13.5,
), ),
); );
@ -1167,8 +1167,8 @@ void main() {
checkOpacity(tester, flying(tester, find.text('Page 2')), 0.29867843724787235); checkOpacity(tester, flying(tester, find.text('Page 2')), 0.29867843724787235);
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 2'))), tester.getTopLeft(flying(tester, find.text('Page 2'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 504.880443334579467773 : 504.65044379234314, 504.880443334579467773,
13.5, 13.5,
), ),
); );
@ -1212,8 +1212,8 @@ void main() {
checkOpacity(tester, flying(tester, find.text('Page 2')), 0.0); checkOpacity(tester, flying(tester, find.text('Page 2')), 0.0);
expect( expect(
tester.getTopRight(flying(tester, find.text('Page 2'))), tester.getTopRight(flying(tester, find.text('Page 2'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 60.0596635341644287109 : 60.28966307640076, 60.0596635341644287109,
13.5, 13.5,
), ),
); );
@ -1223,8 +1223,8 @@ void main() {
checkOpacity(tester, flying(tester, find.text('Page 2')), 0.29867843724787235); checkOpacity(tester, flying(tester, find.text('Page 2')), 0.29867843724787235);
expect( expect(
tester.getTopRight(flying(tester, find.text('Page 2'))), tester.getTopRight(flying(tester, find.text('Page 2'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 295.119556665420532227 : 295.34955620765686, 295.119556665420532227,
13.5, 13.5,
), ),
); );
@ -1350,8 +1350,8 @@ void main() {
// Page 2, which is the middle of the top route, start to fly back to the right. // Page 2, which is the middle of the top route, start to fly back to the right.
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 2'))), tester.getTopLeft(flying(tester, find.text('Page 2'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 353.810205429792404175 : 353.5802058875561, 353.810205429792404175,
13.5, 13.5,
), ),
); );
@ -1368,16 +1368,16 @@ void main() {
// Transition continues. // Transition continues.
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 2'))), tester.getTopLeft(flying(tester, find.text('Page 2'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 655.435583114624023438 : 655.2055835723877, 655.435583114624023438,
13.5, 13.5,
), ),
); );
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 2'))), tester.getTopLeft(flying(tester, find.text('Page 2'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 749.863556146621704102 : 749.6335566043854, 749.863556146621704102,
13.5, 13.5,
), ),
); );
@ -1421,8 +1421,8 @@ void main() {
// Page 2, which is the middle of the top route, start to fly back to the right. // Page 2, which is the middle of the top route, start to fly back to the right.
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 2'))), tester.getTopLeft(flying(tester, find.text('Page 2'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 353.810205429792404175 : 353.5802058875561, 353.810205429792404175,
13.5, 13.5,
), ),
); );
@ -1433,16 +1433,16 @@ void main() {
// Transition continues from the point we let off. // Transition continues from the point we let off.
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 2'))), tester.getTopLeft(flying(tester, find.text('Page 2'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 353.810205429792404175 : 353.5802058875561, 353.810205429792404175,
13.5, 13.5,
), ),
); );
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 2'))), tester.getTopLeft(flying(tester, find.text('Page 2'))),
Offset( const Offset(
ParagraphBuilder.shouldDisableRoundingHack ? 350.231143206357955933 : 350.0011436641216, 350.231143206357955933,
13.5, 13.5,
), ),
); );

View File

@ -583,7 +583,7 @@ void main() {
tester.getTopLeft(find.text('Licenses')), tester.getTopLeft(find.text('Licenses')),
const Offset(16.0 + safeareaPadding, 14.0 + safeareaPadding), const Offset(16.0 + safeareaPadding, 14.0 + safeareaPadding),
); );
}); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgetsWithLeakTracking('LicensePage returns early if unmounted', (WidgetTester tester) async { testWidgetsWithLeakTracking('LicensePage returns early if unmounted', (WidgetTester tester) async {
final Completer<LicenseEntry> licenseCompleter = Completer<LicenseEntry>(); final Completer<LicenseEntry> licenseCompleter = Completer<LicenseEntry>();
@ -1578,7 +1578,9 @@ void main() {
// If the layout width is less than 840.0 pixels, nested layout is // If the layout width is less than 840.0 pixels, nested layout is
// used which positions license page title at the top center. // used which positions license page title at the top center.
Offset titleOffset = tester.getCenter(find.text(title)); Offset titleOffset = tester.getCenter(find.text(title));
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect(titleOffset, Offset(defaultSize.width / 2, 96.0)); expect(titleOffset, Offset(defaultSize.width / 2, 96.0));
}
expect(tester.getCenter(find.byType(ListView)), Offset(defaultSize.width / 2, 328.0)); expect(tester.getCenter(find.byType(ListView)), Offset(defaultSize.width / 2, 328.0));
// Configure a wide window to show the lateral UI. // Configure a wide window to show the lateral UI.
@ -1708,7 +1710,9 @@ void main() {
// If the layout width is less than 840.0 pixels, nested layout is // If the layout width is less than 840.0 pixels, nested layout is
// used which positions license page title at the top center. // used which positions license page title at the top center.
Offset titleOffset = tester.getCenter(find.text(title)); Offset titleOffset = tester.getCenter(find.text(title));
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect(titleOffset, Offset(defaultSize.width / 2, 96.0)); expect(titleOffset, Offset(defaultSize.width / 2, 96.0));
}
expect(tester.getCenter(find.byType(ListView)), Offset(defaultSize.width / 2, 328.0)); expect(tester.getCenter(find.byType(ListView)), Offset(defaultSize.width / 2, 328.0));
// Configure a wide window to show the lateral UI. // Configure a wide window to show the lateral UI.

View File

@ -84,7 +84,10 @@ void main() {
); );
// Test default chip size. // Test default chip size.
expect(tester.getSize(find.byType(ActionChip)), const Size(190.0, 48.0)); expect(
tester.getSize(find.byType(ActionChip)),
within<Size>(distance: 0.01, from: const Size(189.1, 48.0)),
);
// Test default label style. // Test default label style.
expect( expect(
getLabelStyle(tester, label).style.color!.value, getLabelStyle(tester, label).style.color!.value,
@ -155,7 +158,10 @@ void main() {
); );
// Test default chip size. // Test default chip size.
expect(tester.getSize(find.byType(ActionChip)), const Size(190.0, 48.0)); expect(
tester.getSize(find.byType(ActionChip)),
within<Size>(distance: 0.01, from: const Size(189.1, 48.0)),
);
// Test default label style. // Test default label style.
expect( expect(
getLabelStyle(tester, label).style.color!.value, getLabelStyle(tester, label).style.color!.value,

View File

@ -1280,7 +1280,9 @@ void main() {
// Test the expanded title is positioned correctly. // Test the expanded title is positioned correctly.
final Offset titleOffset = tester.getBottomLeft(expandedTitle); final Offset titleOffset = tester.getBottomLeft(expandedTitle);
expect(titleOffset.dx, 16.0); expect(titleOffset.dx, 16.0);
if (!kIsWeb || isCanvasKit) {
expect(titleOffset.dy, 96.0); expect(titleOffset.dy, 96.0);
}
_verifyTextNotClipped(expandedTitle, tester); _verifyTextNotClipped(expandedTitle, tester);
@ -5191,7 +5193,7 @@ void main() {
await tester.pumpWidget(buildAppBar(textScaleFactor: 3.0)); await tester.pumpWidget(buildAppBar(textScaleFactor: 3.0));
expect(tester.getRect(expandedTitle).height, 43.0); expect(tester.getRect(expandedTitle).height, 43.0);
_verifyTextNotClipped(expandedTitle, tester); _verifyTextNotClipped(expandedTitle, tester);
}); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgets('SliverAppBar.large expanded title has upper limit on text scaling', (WidgetTester tester) async { testWidgets('SliverAppBar.large expanded title has upper limit on text scaling', (WidgetTester tester) async {
const String title = 'Large AppBar'; const String title = 'Large AppBar';
@ -5221,22 +5223,15 @@ void main() {
await tester.pumpWidget(buildAppBar()); await tester.pumpWidget(buildAppBar());
// TODO(tahatesser): https://github.com/flutter/flutter/issues/99933
// A bug in the HTML renderer and/or Chrome 96+ causes a
// discrepancy in the paragraph height.
const bool hasIssue99933 = kIsWeb && !bool.fromEnvironment('FLUTTER_WEB_USE_SKIA');
final Finder expandedTitle = find.text(title).first; final Finder expandedTitle = find.text(title).first;
expect( expect(tester.getRect(expandedTitle).height, 36.0);
tester.getRect(expandedTitle).height,
closeTo( hasIssue99933 ? 37.0 : 36.0, 0.1),
);
await tester.pumpWidget(buildAppBar(textScaleFactor: 2.0)); await tester.pumpWidget(buildAppBar(textScaleFactor: 2.0));
expect(tester.getRect(expandedTitle).height, closeTo(48.0, 0.1)); expect(tester.getRect(expandedTitle).height, closeTo(48.0, 0.1));
await tester.pumpWidget(buildAppBar(textScaleFactor: 3.0)); await tester.pumpWidget(buildAppBar(textScaleFactor: 3.0));
expect(tester.getRect(expandedTitle).height, closeTo(48.0, 0.1)); expect(tester.getRect(expandedTitle).height, closeTo(48.0, 0.1));
}); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgets('SliverAppBar.medium expanded title position is adjusted with textScaleFactor', (WidgetTester tester) async { testWidgets('SliverAppBar.medium expanded title position is adjusted with textScaleFactor', (WidgetTester tester) async {
const String title = 'Medium AppBar'; const String title = 'Medium AppBar';
@ -5277,7 +5272,7 @@ void main() {
await tester.pumpWidget(buildAppBar(textScaleFactor: 3.0)); await tester.pumpWidget(buildAppBar(textScaleFactor: 3.0));
expect(tester.getBottomLeft(expandedTitle).dy, 107.0); expect(tester.getBottomLeft(expandedTitle).dy, 107.0);
_verifyTextNotClipped(expandedTitle, tester); _verifyTextNotClipped(expandedTitle, tester);
}); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgets('SliverAppBar.large expanded title position is adjusted with textScaleFactor', (WidgetTester tester) async { testWidgets('SliverAppBar.large expanded title position is adjusted with textScaleFactor', (WidgetTester tester) async {
const String title = 'Large AppBar'; const String title = 'Large AppBar';

View File

@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' as ui show ParagraphBuilder; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
@ -49,12 +48,12 @@ void main() {
expect(tester.getSize(find.byType(Badge)), const Size(24, 24)); // default Icon size expect(tester.getSize(find.byType(Badge)), const Size(24, 24)); // default Icon size
expect(tester.getTopLeft(find.byType(Badge)), Offset.zero); expect(tester.getTopLeft(find.byType(Badge)), Offset.zero);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect(tester.getTopLeft(find.text('0')), const Offset(16, -4)); expect(tester.getTopLeft(find.text('0')), const Offset(16, -4));
}
final RenderBox box = tester.renderObject(find.byType(Badge)); final RenderBox box = tester.renderObject(find.byType(Badge));
final RRect rrect = ui.ParagraphBuilder.shouldDisableRoundingHack final RRect rrect = RRect.fromLTRBR(12, -4, 31.5, 12, const Radius.circular(8));
? RRect.fromLTRBR(12, -4, 31.5, 12, const Radius.circular(8))
: RRect.fromLTRBR(12, -4, 32, 12, const Radius.circular(8));
expect(box, paints..rrect(rrect: rrect, color: theme.colorScheme.error)); expect(box, paints..rrect(rrect: rrect, color: theme.colorScheme.error));
}); });
@ -91,12 +90,12 @@ void main() {
expect(tester.getSize(find.byType(Badge)), const Size(24, 24)); // default Icon size expect(tester.getSize(find.byType(Badge)), const Size(24, 24)); // default Icon size
expect(tester.getTopLeft(find.byType(Badge)), Offset.zero); expect(tester.getTopLeft(find.byType(Badge)), Offset.zero);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect(tester.getTopLeft(find.text('0')), const Offset(0, -4)); expect(tester.getTopLeft(find.text('0')), const Offset(0, -4));
}
final RenderBox box = tester.renderObject(find.byType(Badge)); final RenderBox box = tester.renderObject(find.byType(Badge));
final RRect rrect = ui.ParagraphBuilder.shouldDisableRoundingHack final RRect rrect = RRect.fromLTRBR(-4, -4, 15.5, 12, const Radius.circular(8));
? RRect.fromLTRBR(-4, -4, 15.5, 12, const Radius.circular(8))
: RRect.fromLTRBR(-4, -4, 16, 12, const Radius.circular(8));
expect(box, paints..rrect(rrect: rrect, color: theme.colorScheme.error)); expect(box, paints..rrect(rrect: rrect, color: theme.colorScheme.error));
}); });
@ -143,7 +142,9 @@ void main() {
// x = alignment.start + padding.left // x = alignment.start + padding.left
// y = alignment.top // y = alignment.top
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect(tester.getTopLeft(find.text('0')), const Offset(16, -4)); expect(tester.getTopLeft(find.text('0')), const Offset(16, -4));
}
final RenderBox box = tester.renderObject(find.byType(Badge)); final RenderBox box = tester.renderObject(find.byType(Badge));
// '0'.width = 12 // '0'.width = 12
@ -151,9 +152,7 @@ void main() {
// T = alignment.top // T = alignment.top
// R = L + '0'.width + padding.width // R = L + '0'.width + padding.width
// B = T + largeSize, R = largeSize/2 // B = T + largeSize, R = largeSize/2
final RRect rrect = ui.ParagraphBuilder.shouldDisableRoundingHack final RRect rrect = RRect.fromLTRBR(12, -4, 31.5, 12, const Radius.circular(8));
? RRect.fromLTRBR(12, -4, 31.5, 12, const Radius.circular(8))
: RRect.fromLTRBR(12, -4, 32, 12, const Radius.circular(8));
expect(box, paints..rrect(rrect: rrect, color: theme.colorScheme.error)); expect(box, paints..rrect(rrect: rrect, color: theme.colorScheme.error));
await tester.pumpWidget(buildFrame(1000)); await tester.pumpWidget(buildFrame(1000));

View File

@ -600,7 +600,7 @@ void main() {
final Offset actionsTopLeft = tester.getTopLeft(find.byType(OverflowBar)); final Offset actionsTopLeft = tester.getTopLeft(find.byType(OverflowBar));
final Offset bannerTopLeft = tester.getTopLeft(find.byType(MaterialBanner)); final Offset bannerTopLeft = tester.getTopLeft(find.byType(MaterialBanner));
expect(actionsTopLeft.dx - 8, bannerTopLeft.dx); // actions OverflowBar is padded by 8 expect(actionsTopLeft.dx - 8, moreOrLessEquals(bannerTopLeft.dx)); // actions OverflowBar is padded by 8
}); });
testWidgetsWithLeakTracking('Single action laid out beside content but aligned to the trailing edge when presented by ScaffoldMessenger - RTL', (WidgetTester tester) async { testWidgetsWithLeakTracking('Single action laid out beside content but aligned to the trailing edge when presented by ScaffoldMessenger - RTL', (WidgetTester tester) async {
@ -640,7 +640,7 @@ void main() {
final Offset actionsTopLeft = tester.getTopLeft(find.byType(OverflowBar)); final Offset actionsTopLeft = tester.getTopLeft(find.byType(OverflowBar));
final Offset bannerTopLeft = tester.getTopLeft(find.byType(MaterialBanner)); final Offset bannerTopLeft = tester.getTopLeft(find.byType(MaterialBanner));
expect(actionsTopLeft.dx - 8, bannerTopLeft.dx); // actions OverflowBar is padded by 8 expect(actionsTopLeft.dx - 8, moreOrLessEquals(bannerTopLeft.dx)); // actions OverflowBar is padded by 8
}); });
testWidgetsWithLeakTracking('Actions laid out below content if forced override', (WidgetTester tester) async { testWidgetsWithLeakTracking('Actions laid out below content if forced override', (WidgetTester tester) async {

View File

@ -3499,7 +3499,7 @@ void main() {
expect(calledDelete, isFalse); expect(calledDelete, isFalse);
// Tap after end of the label. // Tap after end of the label.
await tester.tapAt(Offset(labelCenter.dx + (labelSize.width / 2), labelCenter.dy)); await tester.tapAt(Offset(labelCenter.dx + (labelSize.width / 2) + 0.01, labelCenter.dy));
await tester.pump(); await tester.pump();
expect(calledDelete, isTrue); expect(calledDelete, isTrue);
}); });

View File

@ -85,7 +85,10 @@ void main() {
); );
// Test default chip size. // Test default chip size.
expect(tester.getSize(find.byType(ChoiceChip)), const Size(190.0, 48.0)); expect(
tester.getSize(find.byType(ChoiceChip)),
within(distance: 0.01, from: const Size(189.1, 48.0)),
);
// Test default label style. // Test default label style.
expect( expect(
getLabelStyle(tester, label).style.color!.value, getLabelStyle(tester, label).style.color!.value,
@ -217,7 +220,10 @@ void main() {
); );
// Test default chip size. // Test default chip size.
expect(tester.getSize(find.byType(ChoiceChip)), const Size(190.0, 48.0)); expect(
tester.getSize(find.byType(ChoiceChip)),
within(distance: 0.01, from: const Size(189.1, 48.0)),
);
// Test default label style. // Test default label style.
expect( expect(
getLabelStyle(tester, label).style.color!.value, getLabelStyle(tester, label).style.color!.value,

View File

@ -330,7 +330,7 @@ void main() {
// We expect the left edge of the 'OK' button in the RTL // We expect the left edge of the 'OK' button in the RTL
// layout to match the gap between right edge of the 'OK' // layout to match the gap between right edge of the 'OK'
// button and the right edge of the 800 wide view. // button and the right edge of the 800 wide view.
expect(tester.getBottomLeft(find.text('OK')).dx, 800 - ltrOkRight); expect(tester.getBottomLeft(find.text('OK')).dx, moreOrLessEquals(800 - ltrOkRight));
}); });
group('Barrier dismissible', () { group('Barrier dismissible', () {
@ -876,11 +876,9 @@ void main() {
final Offset subHeaderTextTopLeft = tester.getTopLeft(subHeaderText); final Offset subHeaderTextTopLeft = tester.getTopLeft(subHeaderText);
final Offset dividerTopRight = tester.getTopRight(divider); final Offset dividerTopRight = tester.getTopRight(divider);
expect(subHeaderTextTopLeft.dx, dividerTopRight.dx + 24.0); expect(subHeaderTextTopLeft.dx, dividerTopRight.dx + 24.0);
// TODO(tahatesser): https://github.com/flutter/flutter/issues/99933 if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
// A bug in the HTML renderer and/or Chrome 96+ causes a expect(subHeaderTextTopLeft.dy, dialogTopLeft.dy + 16.0);
// discrepancy in the paragraph height. }
const bool hasIssue99933 = kIsWeb && !bool.fromEnvironment('FLUTTER_WEB_USE_SKIA');
expect(subHeaderTextTopLeft.dy, dialogTopLeft.dy + 16.0 - (hasIssue99933 ? 0.5 : 0.0));
// Test sub header icon position. // Test sub header icon position.
final Finder subHeaderIcon = find.byIcon(Icons.arrow_drop_down); final Finder subHeaderIcon = find.byIcon(Icons.arrow_drop_down);
@ -894,7 +892,9 @@ void main() {
final Offset calendarPageViewTopLeft = tester.getTopLeft(calendarPageView); final Offset calendarPageViewTopLeft = tester.getTopLeft(calendarPageView);
final Offset subHeaderTextBottomLeft = tester.getBottomLeft(subHeaderText); final Offset subHeaderTextBottomLeft = tester.getBottomLeft(subHeaderText);
expect(calendarPageViewTopLeft.dx, dividerTopRight.dx); expect(calendarPageViewTopLeft.dx, dividerTopRight.dx);
expect(calendarPageViewTopLeft.dy, subHeaderTextBottomLeft.dy + 16.0 - (hasIssue99933 ? 0.5 : 0.0)); if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect(calendarPageViewTopLeft.dy, subHeaderTextBottomLeft.dy + 16.0);
}
// Test month navigation icons position. // Test month navigation icons position.
final Finder previousMonthButton = find.widgetWithIcon(IconButton, Icons.chevron_left); final Finder previousMonthButton = find.widgetWithIcon(IconButton, Icons.chevron_left);
@ -954,11 +954,9 @@ void main() {
final Offset headerTextTextTopLeft = tester.getTopLeft(headerText); final Offset headerTextTextTopLeft = tester.getTopLeft(headerText);
final Offset helpTextBottomLeft = tester.getBottomLeft(helpText); final Offset helpTextBottomLeft = tester.getBottomLeft(helpText);
expect(headerTextTextTopLeft.dx, dialogTopLeft.dx + 24.0); expect(headerTextTextTopLeft.dx, dialogTopLeft.dx + 24.0);
// TODO(tahatesser): https://github.com/flutter/flutter/issues/99933 if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
// A bug in the HTML renderer and/or Chrome 96+ causes a expect(headerTextTextTopLeft.dy, helpTextBottomLeft.dy + 28.0);
// discrepancy in the paragraph height. }
const bool hasIssue99933 = kIsWeb && !bool.fromEnvironment('FLUTTER_WEB_USE_SKIA');
expect(headerTextTextTopLeft.dy, helpTextBottomLeft.dy + 28.0 - (hasIssue99933 ? 1.0 : 0.0));
// Test switch button position. // Test switch button position.
final Finder switchButtonM3 = find.widgetWithIcon(IconButton, Icons.edit_outlined); final Finder switchButtonM3 = find.widgetWithIcon(IconButton, Icons.edit_outlined);
@ -978,7 +976,9 @@ void main() {
final Offset subHeaderTextTopLeft = tester.getTopLeft(subHeaderText); final Offset subHeaderTextTopLeft = tester.getTopLeft(subHeaderText);
final Offset dividerBottomLeft = tester.getBottomLeft(divider); final Offset dividerBottomLeft = tester.getBottomLeft(divider);
expect(subHeaderTextTopLeft.dx, dialogTopLeft.dx + 24.0); expect(subHeaderTextTopLeft.dx, dialogTopLeft.dx + 24.0);
expect(subHeaderTextTopLeft.dy, dividerBottomLeft.dy + 16.0 - (hasIssue99933 ? 0.5 : 0.0)); if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect(subHeaderTextTopLeft.dy, dividerBottomLeft.dy + 16.0);
}
// Test sub header icon position. // Test sub header icon position.
final Finder subHeaderIcon = find.byIcon(Icons.arrow_drop_down); final Finder subHeaderIcon = find.byIcon(Icons.arrow_drop_down);
@ -1001,7 +1001,9 @@ void main() {
final Offset calendarPageViewTopLeft = tester.getTopLeft(calendarPageView); final Offset calendarPageViewTopLeft = tester.getTopLeft(calendarPageView);
final Offset subHeaderTextBottomLeft = tester.getBottomLeft(subHeaderText); final Offset subHeaderTextBottomLeft = tester.getBottomLeft(subHeaderText);
expect(calendarPageViewTopLeft.dx, dialogTopLeft.dx); expect(calendarPageViewTopLeft.dx, dialogTopLeft.dx);
expect(calendarPageViewTopLeft.dy, subHeaderTextBottomLeft.dy + 16.0 - (hasIssue99933 ? 0.5 : 0.0)); if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect(calendarPageViewTopLeft.dy, subHeaderTextBottomLeft.dy + 16.0);
}
// Test action buttons position. // Test action buttons position.
final Offset dialogBottomRight = tester.getBottomRight(find.byType(AnimatedContainer)); final Offset dialogBottomRight = tester.getBottomRight(find.byType(AnimatedContainer));

View File

@ -133,22 +133,21 @@ void main() {
final Offset entryButtonBottomLeft = tester.getBottomLeft( final Offset entryButtonBottomLeft = tester.getBottomLeft(
find.widgetWithIcon(IconButton, Icons.edit_outlined), find.widgetWithIcon(IconButton, Icons.edit_outlined),
); );
expect( expect(saveButtonBottomLeft.dx, moreOrLessEquals(711.6, epsilon: 1e-5));
saveButtonBottomLeft.dx, if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
ParagraphBuilder.shouldDisableRoundingHack ? moreOrLessEquals(711.6, epsilon: 1e-5) : (800 - 89.0),
);
expect(saveButtonBottomLeft.dy, helpTextTopLeft.dy); expect(saveButtonBottomLeft.dy, helpTextTopLeft.dy);
}
expect(entryButtonBottomLeft.dx, saveButtonBottomLeft.dx - 48.0); expect(entryButtonBottomLeft.dx, saveButtonBottomLeft.dx - 48.0);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect(entryButtonBottomLeft.dy, helpTextTopLeft.dy); expect(entryButtonBottomLeft.dy, helpTextTopLeft.dy);
}
// Test help text position. // Test help text position.
final Offset helpTextBottomLeft = tester.getBottomLeft(helpText); final Offset helpTextBottomLeft = tester.getBottomLeft(helpText);
expect(helpTextBottomLeft.dx, 72.0); expect(helpTextBottomLeft.dx, 72.0);
// TODO(tahatesser): https://github.com/flutter/flutter/issues/99933 if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
// A bug in the HTML renderer and/or Chrome 96+ causes a expect(helpTextBottomLeft.dy, closeButtonBottomRight.dy + 20.0);
// discrepancy in the paragraph height. }
const bool hasIssue99933 = kIsWeb && !bool.fromEnvironment('FLUTTER_WEB_USE_SKIA');
expect(helpTextBottomLeft.dy, closeButtonBottomRight.dy + 20.0 + (hasIssue99933 ? 1.0 : 0.0));
// Test the header position. // Test the header position.
final Offset firstDateHeaderTopLeft = tester.getTopLeft(firstDateHeaderText); final Offset firstDateHeaderTopLeft = tester.getTopLeft(firstDateHeaderText);

View File

@ -7,6 +7,7 @@
@Tags(<String>['reduced-test-set']) @Tags(<String>['reduced-test-set'])
library; library;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
@ -186,7 +187,9 @@ void main() {
find.descendant(of: find.byType(Dialog), matching: find.byType(Material)), find.descendant(of: find.byType(Dialog), matching: find.byType(Material)),
); );
expect(bottomLeft.dx, 480.0); expect(bottomLeft.dx, 480.0);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect(bottomLeft.dy, 124.0); expect(bottomLeft.dy, 124.0);
}
}); });
testWidgets('Material2 - Dialog alignment takes priority over theme', (WidgetTester tester) async { testWidgets('Material2 - Dialog alignment takes priority over theme', (WidgetTester tester) async {

View File

@ -5,7 +5,6 @@
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -146,8 +145,8 @@ void main() {
await tester.pumpWidget(buildTest(themeData, menuChildren, width: 200.0)); await tester.pumpWidget(buildTest(themeData, menuChildren, width: 200.0));
final Finder anchor = find.byType(TextField); final Finder anchor = find.byType(TextField);
final Size size = tester.getSize(anchor); final double width = tester.getSize(anchor).width;
expect(size, const Size(200.0, 56.0)); expect(width, 200.0);
await tester.tap(anchor); await tester.tap(anchor);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@ -156,8 +155,8 @@ void main() {
of: find.byType(SingleChildScrollView), of: find.byType(SingleChildScrollView),
matching: find.byType(Material), matching: find.byType(Material),
); );
final Size updatedMenuSize = tester.getSize(updatedMenu); final double updatedMenuWidth = tester.getSize(updatedMenu).width;
expect(updatedMenuSize, const Size(200.0, 304.0)); expect(updatedMenuWidth, 200.0);
}); });
testWidgets('Material3 - The width of the text field should always be the same as the menu view', testWidgets('Material3 - The width of the text field should always be the same as the menu view',
@ -177,12 +176,8 @@ void main() {
); );
final Finder textField = find.byType(TextField); final Finder textField = find.byType(TextField);
final Size anchorSize = tester.getSize(textField); final double anchorWidth = tester.getSize(textField).width;
if (kIsWeb && !isCanvasKit) { expect(anchorWidth, 195.0);
expect(anchorSize, const Size(195.0, 61.0));
} else {
expect(anchorSize, const Size(195.0, 60.0));
}
await tester.tap(find.byType(DropdownMenu<TestMenu>)); await tester.tap(find.byType(DropdownMenu<TestMenu>));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@ -191,20 +186,16 @@ void main() {
of: find.byType(SingleChildScrollView), of: find.byType(SingleChildScrollView),
matching: find.byType(Material), matching: find.byType(Material),
); );
final Size menuSize = tester.getSize(menuMaterial); final double menuWidth = tester.getSize(menuMaterial).width;
expect(menuSize, const Size(195.0, 304.0)); expect(menuWidth, 195.0);
// The text field should have same width as the menu // The text field should have same width as the menu
// when the width property is not null. // when the width property is not null.
await tester.pumpWidget(buildTest(themeData, menuChildren, width: 200.0)); await tester.pumpWidget(buildTest(themeData, menuChildren, width: 200.0));
final Finder anchor = find.byType(TextField); final Finder anchor = find.byType(TextField);
final Size size = tester.getSize(anchor); final double width = tester.getSize(anchor).width;
if (kIsWeb && !isCanvasKit) { expect(width, 200.0);
expect(size, const Size(200.0, 61.0));
} else {
expect(size, const Size(200.0, 60.0));
}
await tester.tap(anchor); await tester.tap(anchor);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@ -213,8 +204,8 @@ void main() {
of: find.byType(SingleChildScrollView), of: find.byType(SingleChildScrollView),
matching: find.byType(Material), matching: find.byType(Material),
); );
final Size updatedMenuSize = tester.getSize(updatedMenu); final double updatedMenuWidth = tester.getSize(updatedMenu).width;
expect(updatedMenuSize, const Size(200.0, 304.0)); expect(updatedMenuWidth, 200.0);
}); });
testWidgets('The width property can customize the width of the dropdown menu', (WidgetTester tester) async { testWidgets('The width property can customize the width of the dropdown menu', (WidgetTester tester) async {

View File

@ -3346,7 +3346,7 @@ void main() {
// Should be center-center aligned, the icon size is 24.0 pixels. // Should be center-center aligned, the icon size is 24.0 pixels.
expect( expect(
buttonBox.localToGlobal(Offset((buttonBox.size.width -24.0) / 2.0, buttonBox.size.height / 2.0)), buttonBox.localToGlobal(Offset((buttonBox.size.width -24.0) / 2.0, buttonBox.size.height / 2.0)),
selectedItemBox.localToGlobal(Offset(selectedItemBox.size.width / 2.0, selectedItemBox.size.height / 2.0)), offsetMoreOrLessEquals(selectedItemBox.localToGlobal(Offset(selectedItemBox.size.width / 2.0, selectedItemBox.size.height / 2.0))),
); );
// Open dropdown. // Open dropdown.
@ -3362,10 +3362,10 @@ void main() {
Offset(selectedItemBoxInMenu.size.width / 2.0, selectedItemBoxInMenu.size.height / 2.0) Offset(selectedItemBoxInMenu.size.width / 2.0, selectedItemBoxInMenu.size.height / 2.0)
); );
expect(center.dx, menuRect.topCenter.dx,); expect(center.dx, moreOrLessEquals(menuRect.topCenter.dx));
expect( expect(
center.dy, center.dy,
selectedItemBox.localToGlobal(Offset(selectedItemBox.size.width / 2.0, selectedItemBox.size.height / 2.0)).dy, moreOrLessEquals(selectedItemBox.localToGlobal(Offset(selectedItemBox.size.width / 2.0, selectedItemBox.size.height / 2.0)).dy),
); );
}); });

View File

@ -135,7 +135,10 @@ void main() {
); );
// Test default chip size. // Test default chip size.
expect(tester.getSize(find.byType(FilterChip)), const Size(190.0, 48.0)); expect(
tester.getSize(find.byType(FilterChip)),
within(distance: 0.001, from: const Size(189.1, 48.0)),
);
// Test default label style. // Test default label style.
expect( expect(
getLabelStyle(tester, label).style.color!.value, getLabelStyle(tester, label).style.color!.value,
@ -267,7 +270,10 @@ void main() {
); );
// Test default chip size. // Test default chip size.
expect(tester.getSize(find.byType(FilterChip)), const Size(190.0, 48.0)); expect(
tester.getSize(find.byType(FilterChip)),
within(distance: 0.001, from: const Size(189.1, 48.0)),
);
// Test default label style. // Test default label style.
expect( expect(
getLabelStyle(tester, 'filter chip').style.color!.value, getLabelStyle(tester, 'filter chip').style.color!.value,

View File

@ -7,8 +7,6 @@
@Tags(<String>['reduced-test-set']) @Tags(<String>['reduced-test-set'])
library; library;
import 'dart:ui' as ui show ParagraphBuilder;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
@ -473,9 +471,7 @@ void main() {
), ),
); );
final double textWidth = ui.ParagraphBuilder.shouldDisableRoundingHack final double textWidth = width;
? width
: (width / 1.5).floorToDouble() * 1.5;
// The title is scaled and transformed to be 1.5 times bigger, when the // The title is scaled and transformed to be 1.5 times bigger, when the
// FlexibleSpaceBar is fully expanded, thus we expect the width to be // FlexibleSpaceBar is fully expanded, thus we expect the width to be
// 1.5 times smaller than the full width. The height of the text is the same // 1.5 times smaller than the full width. The height of the text is the same
@ -544,9 +540,7 @@ void main() {
// bottom edge. // bottom edge.
const double bottomMargin = titleFontSize * (expandedTitleScale - 1); const double bottomMargin = titleFontSize * (expandedTitleScale - 1);
final double textWidth = ui.ParagraphBuilder.shouldDisableRoundingHack final double textWidth = collapsedWidth;
? collapsedWidth
: (collapsedWidth / 3).floorToDouble() * 3;
// The title is scaled and transformed to be 3 times bigger, when the // The title is scaled and transformed to be 3 times bigger, when the
// FlexibleSpaceBar is fully expanded, thus we expect the width to be // FlexibleSpaceBar is fully expanded, thus we expect the width to be
// 3 times smaller than the full width. The height of the text is the same // 3 times smaller than the full width. The height of the text is the same

View File

@ -5930,10 +5930,7 @@ testWidgets('OutlineInputBorder with BorderRadius.zero should draw a rectangular
} }
final Rect clipRect = arguments[0] as Rect; final Rect clipRect = arguments[0] as Rect;
// _kFinalLabelScale = 0.75 // _kFinalLabelScale = 0.75
final double width = ParagraphBuilder.shouldDisableRoundingHack expect(clipRect, rectMoreOrLessEquals(const Rect.fromLTWH(0, 0, 100 / 0.75, 16.0), epsilon: 1e-5));
? 100 / 0.75
: 133.0;
expect(clipRect, rectMoreOrLessEquals(Rect.fromLTWH(0, 0, width, 16.0), epsilon: 1e-5));
return true; return true;
}), }),
); );

View File

@ -156,22 +156,24 @@ void main() {
await tester.pumpWidget(buildFrame(isTwoLine: true, textScaleFactor: 4.0)); await tester.pumpWidget(buildFrame(isTwoLine: true, textScaleFactor: 4.0));
testChildren(); testChildren();
testHorizontalGeometry(); testHorizontalGeometry();
// TODO(tahatesser): https://github.com/flutter/flutter/issues/99933 if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
// A bug in the HTML renderer and/or Chrome 96+ causes a testVerticalGeometry(192.0);
// discrepancy in the paragraph height. }
const bool hasIssue99933 = kIsWeb && !bool.fromEnvironment('FLUTTER_WEB_USE_SKIA');
testVerticalGeometry(hasIssue99933 ? 193 : 192.0);
// Make sure that the height of a large subtitle is taken into account. // Make sure that the height of a large subtitle is taken into account.
await tester.pumpWidget(buildFrame(isTwoLine: true, textScaleFactor: 0.5, subtitleScaleFactor: 4.0)); await tester.pumpWidget(buildFrame(isTwoLine: true, textScaleFactor: 0.5, subtitleScaleFactor: 4.0));
testChildren(); testChildren();
testHorizontalGeometry(); testHorizontalGeometry();
testVerticalGeometry(hasIssue99933 ? 109 : 108.0); if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
testVerticalGeometry(108.0);
}
await tester.pumpWidget(buildFrame(isThreeLine: true, textScaleFactor: 4.0)); await tester.pumpWidget(buildFrame(isThreeLine: true, textScaleFactor: 4.0));
testChildren(); testChildren();
testHorizontalGeometry(); testHorizontalGeometry();
testVerticalGeometry(hasIssue99933 ? 193 : 192.0); if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
testVerticalGeometry(192.0);
}
}); });
testWidgetsWithLeakTracking('ListTile geometry (RTL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('ListTile geometry (RTL)', (WidgetTester tester) async {
@ -504,13 +506,13 @@ void main() {
), ),
), ),
); );
// TODO(tahatesser): https://github.com/flutter/flutter/issues/99933
// A bug in the HTML renderer and/or Chrome 96+ causes a if (kIsWeb && !isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
// discrepancy in the paragraph height. return;
const bool hasIssue99933 = kIsWeb && !bool.fromEnvironment('FLUTTER_WEB_USE_SKIA'); }
const double height = hasIssue99933 ? 301.0 : 300; const double height = 300;
const double avatarTop = hasIssue99933 ? 130.5 : 130.0; const double avatarTop = 130.0;
const double placeholderTop = hasIssue99933 ? 138.5 : 138.0; const double placeholderTop = 138.0;
// LEFT TOP WIDTH HEIGHT // LEFT TOP WIDTH HEIGHT
expect(tester.getRect(find.byType(ListTile).at(0)), const Rect.fromLTWH( 0.0, 0.0, 800.0, height)); expect(tester.getRect(find.byType(ListTile).at(0)), const Rect.fromLTWH( 0.0, 0.0, 800.0, height));
expect(tester.getRect(find.byType(CircleAvatar).at(0)), const Rect.fromLTWH( 16.0, avatarTop, 40.0, 40.0)); expect(tester.getRect(find.byType(CircleAvatar).at(0)), const Rect.fromLTWH( 16.0, avatarTop, 40.0, 40.0));

View File

@ -411,10 +411,8 @@ void main() {
await tester.longPress(find.text(label)); await tester.longPress(find.text(label));
expect(find.text(label), findsNWidgets(2)); expect(find.text(label), findsNWidgets(2));
if (kIsWeb && !isCanvasKit) { if (!kIsWeb || isCanvasKit) {
expect(tester.getSize(find.text(label).last), const Size(15.0, 21.0)); expect(tester.getSize(find.text(label).last), const Size(14.25, 20.0));
} else {
expect(tester.getSize(find.text(label).last), const Size(15.0, 20.0));
} }
// The duration is needed to ensure the tooltip disappears. // The duration is needed to ensure the tooltip disappears.
await tester.pumpAndSettle(const Duration(seconds: 2)); await tester.pumpAndSettle(const Duration(seconds: 2));
@ -423,10 +421,8 @@ void main() {
expect(find.text(label), findsOneWidget); expect(find.text(label), findsOneWidget);
await tester.longPress(find.text(label)); await tester.longPress(find.text(label));
if (kIsWeb && !isCanvasKit) { if (!kIsWeb || isCanvasKit) {
expect(tester.getSize(find.text(label).last), const Size(57.0, 81.0)); expect(tester.getSize(find.text(label).last), const Size(56.25, 80.0));
} else {
expect(tester.getSize(find.text(label).last), const Size(57.0, 80.0));
} }
}); });
@ -831,7 +827,7 @@ void main() {
color: const Color(0x0a000000), color: const Color(0x0a000000),
) )
); );
}); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgetsWithLeakTracking('Material3 - Navigation indicator ripple golden test', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - Navigation indicator ripple golden test', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/117420. // This is a regression test for https://github.com/flutter/flutter/issues/117420.

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' as ui show ParagraphBuilder;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -544,6 +542,7 @@ void main() {
// The second destination is below the first with some spacing. // The second destination is below the first with some spacing.
nextDestinationY += destinationHeightWithLabel + destinationSpacing; nextDestinationY += destinationHeightWithLabel + destinationSpacing;
final RenderBox secondIconRenderBox = _iconRenderBox(tester, Icons.bookmark_border); final RenderBox secondIconRenderBox = _iconRenderBox(tester, Icons.bookmark_border);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
secondIconRenderBox.localToGlobal(Offset.zero), secondIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -553,10 +552,12 @@ void main() {
), ),
), ),
); );
}
// The third destination is below the second with some spacing. // The third destination is below the second with some spacing.
nextDestinationY += destinationHeight + destinationSpacing; nextDestinationY += destinationHeight + destinationSpacing;
final RenderBox thirdIconRenderBox = _iconRenderBox(tester, Icons.star_border); final RenderBox thirdIconRenderBox = _iconRenderBox(tester, Icons.star_border);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
thirdIconRenderBox.localToGlobal(Offset.zero), thirdIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -566,10 +567,12 @@ void main() {
), ),
), ),
); );
}
// The fourth destination is below the third with some spacing. // The fourth destination is below the third with some spacing.
nextDestinationY += destinationHeight + destinationSpacing; nextDestinationY += destinationHeight + destinationSpacing;
final RenderBox fourthIconRenderBox = _iconRenderBox(tester, Icons.hotel); final RenderBox fourthIconRenderBox = _iconRenderBox(tester, Icons.hotel);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
fourthIconRenderBox.localToGlobal(Offset.zero), fourthIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -579,13 +582,14 @@ void main() {
), ),
), ),
); );
}
}); });
testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=selected, [textScaleFactor]=3.0', (WidgetTester tester) async { testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=selected, [textScaleFactor]=3.0', (WidgetTester tester) async {
// Padding at the top of the rail. // Padding at the top of the rail.
const double topPadding = 8.0; const double topPadding = 8.0;
// Width of a destination. // Width of a destination.
final double destinationWidth = ui.ParagraphBuilder.shouldDisableRoundingHack ? 125.5 : 126.0; const double destinationWidth = 125.5;
// Height of a destination indicator with icon. // Height of a destination indicator with icon.
const double destinationHeight = 32.0; const double destinationHeight = 32.0;
// Space between the indicator and label. // Space between the indicator and label.
@ -636,6 +640,7 @@ void main() {
// The second destination is below the first with some spacing. // The second destination is below the first with some spacing.
nextDestinationY += destinationHeightWithLabel + destinationSpacing; nextDestinationY += destinationHeightWithLabel + destinationSpacing;
final RenderBox secondIconRenderBox = _iconRenderBox(tester, Icons.bookmark_border); final RenderBox secondIconRenderBox = _iconRenderBox(tester, Icons.bookmark_border);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
secondIconRenderBox.localToGlobal(Offset.zero), secondIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -645,10 +650,12 @@ void main() {
), ),
), ),
); );
}
// The third destination is below the second with some spacing. // The third destination is below the second with some spacing.
nextDestinationY += destinationHeight + destinationSpacing; nextDestinationY += destinationHeight + destinationSpacing;
final RenderBox thirdIconRenderBox = _iconRenderBox(tester, Icons.star_border); final RenderBox thirdIconRenderBox = _iconRenderBox(tester, Icons.star_border);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
thirdIconRenderBox.localToGlobal(Offset.zero), thirdIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -658,10 +665,12 @@ void main() {
), ),
), ),
); );
}
// The fourth destination is below the third with some spacing. // The fourth destination is below the third with some spacing.
nextDestinationY += destinationHeight + destinationSpacing; nextDestinationY += destinationHeight + destinationSpacing;
final RenderBox fourthIconRenderBox = _iconRenderBox(tester, Icons.hotel); final RenderBox fourthIconRenderBox = _iconRenderBox(tester, Icons.hotel);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
fourthIconRenderBox.localToGlobal(Offset.zero), fourthIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -671,6 +680,7 @@ void main() {
), ),
), ),
); );
}
}); });
testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=selected, [textScaleFactor]=0.75', (WidgetTester tester) async { testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=selected, [textScaleFactor]=0.75', (WidgetTester tester) async {
@ -728,6 +738,7 @@ void main() {
// The second destination is below the first with some spacing. // The second destination is below the first with some spacing.
nextDestinationY += destinationHeightWithLabel + destinationSpacing; nextDestinationY += destinationHeightWithLabel + destinationSpacing;
final RenderBox secondIconRenderBox = _iconRenderBox(tester, Icons.bookmark_border); final RenderBox secondIconRenderBox = _iconRenderBox(tester, Icons.bookmark_border);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
secondIconRenderBox.localToGlobal(Offset.zero), secondIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -737,10 +748,12 @@ void main() {
), ),
), ),
); );
}
// The third destination is below the second with some spacing. // The third destination is below the second with some spacing.
nextDestinationY += destinationHeight + destinationSpacing; nextDestinationY += destinationHeight + destinationSpacing;
final RenderBox thirdIconRenderBox = _iconRenderBox(tester, Icons.star_border); final RenderBox thirdIconRenderBox = _iconRenderBox(tester, Icons.star_border);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
thirdIconRenderBox.localToGlobal(Offset.zero), thirdIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -750,10 +763,12 @@ void main() {
), ),
), ),
); );
}
// The fourth destination is below the third with some spacing. // The fourth destination is below the third with some spacing.
nextDestinationY += destinationHeight + destinationSpacing; nextDestinationY += destinationHeight + destinationSpacing;
final RenderBox fourthIconRenderBox = _iconRenderBox(tester, Icons.hotel); final RenderBox fourthIconRenderBox = _iconRenderBox(tester, Icons.hotel);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
fourthIconRenderBox.localToGlobal(Offset.zero), fourthIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -763,6 +778,7 @@ void main() {
), ),
), ),
); );
}
}); });
testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=all, [textScaleFactor]=1.0 (default)', (WidgetTester tester) async { testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=all, [textScaleFactor]=1.0 (default)', (WidgetTester tester) async {
@ -819,6 +835,7 @@ void main() {
// The second destination is below the first with some spacing. // The second destination is below the first with some spacing.
nextDestinationY += destinationHeightWithLabel + destinationSpacing; nextDestinationY += destinationHeightWithLabel + destinationSpacing;
final RenderBox secondIconRenderBox = _iconRenderBox(tester, Icons.bookmark_border); final RenderBox secondIconRenderBox = _iconRenderBox(tester, Icons.bookmark_border);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
secondIconRenderBox.localToGlobal(Offset.zero), secondIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -828,10 +845,12 @@ void main() {
), ),
), ),
); );
}
// The third destination is below the second with some spacing. // The third destination is below the second with some spacing.
nextDestinationY += destinationHeightWithLabel + destinationSpacing; nextDestinationY += destinationHeightWithLabel + destinationSpacing;
final RenderBox thirdIconRenderBox = _iconRenderBox(tester, Icons.star_border); final RenderBox thirdIconRenderBox = _iconRenderBox(tester, Icons.star_border);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
thirdIconRenderBox.localToGlobal(Offset.zero), thirdIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -841,10 +860,12 @@ void main() {
), ),
), ),
); );
}
// The fourth destination is below the third with some spacing. // The fourth destination is below the third with some spacing.
nextDestinationY += destinationHeightWithLabel + destinationSpacing; nextDestinationY += destinationHeightWithLabel + destinationSpacing;
final RenderBox fourthIconRenderBox = _iconRenderBox(tester, Icons.hotel); final RenderBox fourthIconRenderBox = _iconRenderBox(tester, Icons.hotel);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
fourthIconRenderBox.localToGlobal(Offset.zero), fourthIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -854,13 +875,14 @@ void main() {
), ),
), ),
); );
}
}); });
testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=all, [textScaleFactor]=3.0', (WidgetTester tester) async { testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=all, [textScaleFactor]=3.0', (WidgetTester tester) async {
// Padding at the top of the rail. // Padding at the top of the rail.
const double topPadding = 8.0; const double topPadding = 8.0;
// Width of a destination. // Width of a destination.
final double destinationWidth = ui.ParagraphBuilder.shouldDisableRoundingHack ? 125.5 : 126.0; const double destinationWidth = 125.5;
// Height of a destination indicator with icon. // Height of a destination indicator with icon.
const double destinationHeight = 32.0; const double destinationHeight = 32.0;
// Space between the indicator and label. // Space between the indicator and label.
@ -911,6 +933,7 @@ void main() {
// The second destination is below the first with some spacing. // The second destination is below the first with some spacing.
nextDestinationY += destinationHeightWithLabel + destinationSpacing; nextDestinationY += destinationHeightWithLabel + destinationSpacing;
final RenderBox secondIconRenderBox = _iconRenderBox(tester, Icons.bookmark_border); final RenderBox secondIconRenderBox = _iconRenderBox(tester, Icons.bookmark_border);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
secondIconRenderBox.localToGlobal(Offset.zero), secondIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -920,10 +943,12 @@ void main() {
), ),
), ),
); );
}
// The third destination is below the second with some spacing. // The third destination is below the second with some spacing.
nextDestinationY += destinationHeightWithLabel + destinationSpacing; nextDestinationY += destinationHeightWithLabel + destinationSpacing;
final RenderBox thirdIconRenderBox = _iconRenderBox(tester, Icons.star_border); final RenderBox thirdIconRenderBox = _iconRenderBox(tester, Icons.star_border);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
thirdIconRenderBox.localToGlobal(Offset.zero), thirdIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -933,10 +958,12 @@ void main() {
), ),
), ),
); );
}
// The fourth destination is below the third with some spacing. // The fourth destination is below the third with some spacing.
nextDestinationY += destinationHeightWithLabel + destinationSpacing; nextDestinationY += destinationHeightWithLabel + destinationSpacing;
final RenderBox fourthIconRenderBox = _iconRenderBox(tester, Icons.hotel); final RenderBox fourthIconRenderBox = _iconRenderBox(tester, Icons.hotel);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
fourthIconRenderBox.localToGlobal(Offset.zero), fourthIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -946,6 +973,7 @@ void main() {
), ),
), ),
); );
}
}); });
testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=all, [textScaleFactor]=0.75', (WidgetTester tester) async { testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=all, [textScaleFactor]=0.75', (WidgetTester tester) async {
@ -1003,6 +1031,7 @@ void main() {
// The second destination is below the first with some spacing. // The second destination is below the first with some spacing.
nextDestinationY += destinationHeightWithLabel + destinationSpacing; nextDestinationY += destinationHeightWithLabel + destinationSpacing;
final RenderBox secondIconRenderBox = _iconRenderBox(tester, Icons.bookmark_border); final RenderBox secondIconRenderBox = _iconRenderBox(tester, Icons.bookmark_border);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
secondIconRenderBox.localToGlobal(Offset.zero), secondIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -1012,10 +1041,12 @@ void main() {
), ),
), ),
); );
}
// The third destination is below the second with some spacing. // The third destination is below the second with some spacing.
nextDestinationY += destinationHeightWithLabel + destinationSpacing; nextDestinationY += destinationHeightWithLabel + destinationSpacing;
final RenderBox thirdIconRenderBox = _iconRenderBox(tester, Icons.star_border); final RenderBox thirdIconRenderBox = _iconRenderBox(tester, Icons.star_border);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
thirdIconRenderBox.localToGlobal(Offset.zero), thirdIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -1025,10 +1056,12 @@ void main() {
), ),
), ),
); );
}
// The fourth destination is below the third with some spacing. // The fourth destination is below the third with some spacing.
nextDestinationY += destinationHeightWithLabel + destinationSpacing; nextDestinationY += destinationHeightWithLabel + destinationSpacing;
final RenderBox fourthIconRenderBox = _iconRenderBox(tester, Icons.hotel); final RenderBox fourthIconRenderBox = _iconRenderBox(tester, Icons.hotel);
if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
expect( expect(
fourthIconRenderBox.localToGlobal(Offset.zero), fourthIconRenderBox.localToGlobal(Offset.zero),
equals( equals(
@ -1038,6 +1071,7 @@ void main() {
), ),
), ),
); );
}
}); });
testWidgetsWithLeakTracking('Destination spacing is correct for a compact rail - [preferredWidth]=56, [textScaleFactor]=1.0 (default)', (WidgetTester tester) async { testWidgetsWithLeakTracking('Destination spacing is correct for a compact rail - [preferredWidth]=56, [textScaleFactor]=1.0 (default)', (WidgetTester tester) async {
@ -2790,7 +2824,7 @@ void main() {
color: const Color(0xffe8def8), color: const Color(0xffe8def8),
), ),
); );
}); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgetsWithLeakTracking('NavigationRail indicator renders ripple - extended', (WidgetTester tester) async { testWidgetsWithLeakTracking('NavigationRail indicator renders ripple - extended', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/117126 // This is a regression test for https://github.com/flutter/flutter/issues/117126
@ -3123,7 +3157,7 @@ void main() {
color: const Color(0xffe8def8), color: const Color(0xffe8def8),
), ),
); );
}); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgetsWithLeakTracking('NavigationRail indicator scale transform', (WidgetTester tester) async { testWidgetsWithLeakTracking('NavigationRail indicator scale transform', (WidgetTester tester) async {
int selectedIndex = 0; int selectedIndex = 0;
@ -3371,7 +3405,7 @@ void main() {
), ),
), ),
); );
}); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=none (default), [textScaleFactor]=3.0', (WidgetTester tester) async { testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=none (default), [textScaleFactor]=3.0', (WidgetTester tester) async {
// Since the rail is icon only, its destinations should not be affected by // Since the rail is icon only, its destinations should not be affected by
@ -3441,7 +3475,7 @@ void main() {
), ),
), ),
); );
}); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=none (default), [textScaleFactor]=0.75', (WidgetTester tester) async { testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=none (default), [textScaleFactor]=0.75', (WidgetTester tester) async {
// Since the rail is icon only, its destinations should not be affected by // Since the rail is icon only, its destinations should not be affected by
@ -3511,7 +3545,7 @@ void main() {
), ),
), ),
); );
}); }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=selected, [textScaleFactor]=1.0 (default)', (WidgetTester tester) async { testWidgetsWithLeakTracking('Destination spacing is correct - [labelType]=selected, [textScaleFactor]=1.0 (default)', (WidgetTester tester) async {
await _pumpNavigationRail( await _pumpNavigationRail(

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' as ui show ParagraphBuilder;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -1068,10 +1066,7 @@ void main() {
); );
expect(tester.getSize(find.byType(OutlinedButton)), equals(const Size(88.0, 48.0))); expect(tester.getSize(find.byType(OutlinedButton)), equals(const Size(88.0, 48.0)));
expect(tester.getSize(find.byType(Text)), Size( expect(tester.getSize(find.byType(Text)), const Size(52.5, 18.0));
ui.ParagraphBuilder.shouldDisableRoundingHack ? 52.5 : 53.0,
18.0,
));
// Set text scale large enough to expand text and button. // Set text scale large enough to expand text and button.
await tester.pumpWidget( await tester.pumpWidget(

View File

@ -2788,11 +2788,9 @@ void main() {
await expectLater(find.byType(MaterialApp), matchesGoldenFile('m3_snack_bar.scaffold.nested.png')); await expectLater(find.byType(MaterialApp), matchesGoldenFile('m3_snack_bar.scaffold.nested.png'));
final Offset snackBarTopRight = tester.getTopRight(find.byType(SnackBar)); final Offset snackBarTopRight = tester.getTopRight(find.byType(SnackBar));
// TODO(bleroux): https://github.com/flutter/flutter/issues/99933 if (!kIsWeb || isCanvasKit) { // https://github.com/flutter/flutter/issues/99933
// A bug in the HTML renderer and/or Chrome 96+ causes a expect(snackBarTopRight.dy, 465.0);
// discrepancy in the paragraph height. }
const bool hasIssue99933 = kIsWeb && !bool.fromEnvironment('FLUTTER_WEB_USE_SKIA');
expect(snackBarTopRight.dy, hasIssue99933 ? 464.0 : 465.0);
}); });

View File

@ -968,17 +968,23 @@ testWidgets('Stepper custom indexed controls test', (WidgetTester tester) async
const String continueStr = 'Continue'; const String continueStr = 'Continue';
const String cancelStr = 'Cancel'; const String cancelStr = 'Cancel';
const Rect continueButtonRect = Rect.fromLTRB(24.0, 212.0, 169.0, 260.0); const Rect continueButtonRect = Rect.fromLTRB(24.0, 212.0, 168.8, 260.0);
const Rect cancelButtonRect = Rect.fromLTRB(177.0, 212.0, 294.0, 260.0); const Rect cancelButtonRect = Rect.fromLTRB(176.8, 212.0, 293.4, 260.0);
expect(buttonMaterial(continueStr).color!.value, themeLight.colorScheme.primary.value); expect(buttonMaterial(continueStr).color!.value, themeLight.colorScheme.primary.value);
expect(buttonMaterial(continueStr).textStyle!.color!.value, 0xffffffff); expect(buttonMaterial(continueStr).textStyle!.color!.value, 0xffffffff);
expect(buttonMaterial(continueStr).shape, buttonShape); expect(buttonMaterial(continueStr).shape, buttonShape);
expect(tester.getRect(find.widgetWithText(TextButton, continueStr)), continueButtonRect); expect(
tester.getRect(find.widgetWithText(TextButton, continueStr)),
rectMoreOrLessEquals(continueButtonRect, epsilon: 0.001),
);
expect(buttonMaterial(cancelStr).color!.value, 0); expect(buttonMaterial(cancelStr).color!.value, 0);
expect(buttonMaterial(cancelStr).textStyle!.color!.value, 0x8a000000); expect(buttonMaterial(cancelStr).textStyle!.color!.value, 0x8a000000);
expect(buttonMaterial(cancelStr).shape, buttonShape); expect(buttonMaterial(cancelStr).shape, buttonShape);
expect(tester.getRect(find.widgetWithText(TextButton, cancelStr)), cancelButtonRect); expect(
tester.getRect(find.widgetWithText(TextButton, cancelStr)),
rectMoreOrLessEquals(cancelButtonRect, epsilon: 0.001),
);
final ThemeData themeDark = ThemeData.dark(useMaterial3: true); final ThemeData themeDark = ThemeData.dark(useMaterial3: true);
await tester.pumpWidget(buildFrame(themeDark)); await tester.pumpWidget(buildFrame(themeDark));
@ -987,12 +993,18 @@ testWidgets('Stepper custom indexed controls test', (WidgetTester tester) async
expect(buttonMaterial(continueStr).color!.value, 0); expect(buttonMaterial(continueStr).color!.value, 0);
expect(buttonMaterial(continueStr).textStyle!.color!.value, themeDark.colorScheme.onSurface.value); expect(buttonMaterial(continueStr).textStyle!.color!.value, themeDark.colorScheme.onSurface.value);
expect(buttonMaterial(continueStr).shape, buttonShape); expect(buttonMaterial(continueStr).shape, buttonShape);
expect(tester.getRect(find.widgetWithText(TextButton, continueStr)), continueButtonRect); expect(
tester.getRect(find.widgetWithText(TextButton, continueStr)),
rectMoreOrLessEquals(continueButtonRect, epsilon: 0.001),
);
expect(buttonMaterial(cancelStr).color!.value, 0); expect(buttonMaterial(cancelStr).color!.value, 0);
expect(buttonMaterial(cancelStr).textStyle!.color!.value, 0xb3ffffff); expect(buttonMaterial(cancelStr).textStyle!.color!.value, 0xb3ffffff);
expect(buttonMaterial(cancelStr).shape, buttonShape); expect(buttonMaterial(cancelStr).shape, buttonShape);
expect(tester.getRect(find.widgetWithText(TextButton, cancelStr)), cancelButtonRect); expect(
tester.getRect(find.widgetWithText(TextButton, cancelStr)),
rectMoreOrLessEquals(cancelButtonRect, epsilon: 0.001),
);
}); });
testWidgets('Material2 - Stepper disabled button styles', (WidgetTester tester) async { testWidgets('Material2 - Stepper disabled button styles', (WidgetTester tester) async {

View File

@ -7,8 +7,6 @@
@Tags(<String>['reduced-test-set']) @Tags(<String>['reduced-test-set'])
library; library;
import 'dart:ui' as ui show ParagraphBuilder;
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
@ -675,8 +673,8 @@ void main() {
..line( ..line(
color: theme.colorScheme.primary, color: theme.colorScheme.primary,
strokeWidth: indicatorWeight, strokeWidth: indicatorWeight,
p1: Offset(ui.ParagraphBuilder.shouldDisableRoundingHack ? 65.75 : 65.5, indicatorY), p1: const Offset(65.75, indicatorY),
p2: Offset(ui.ParagraphBuilder.shouldDisableRoundingHack ? 134.25 : 134.5, indicatorY), p2: const Offset(134.25, indicatorY),
), ),
); );
}); });

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' as ui show ParagraphBuilder;
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
@ -328,7 +326,10 @@ void main() {
MaterialApp(theme: theme, home: const Center(child: Material(child: Tab(text: 'x')))), MaterialApp(theme: theme, home: const Center(child: Material(child: Tab(text: 'x')))),
); );
expect(tester.renderObject<RenderParagraph>(find.byType(RichText)).text.style!.fontFamily, 'FlutterTest'); expect(tester.renderObject<RenderParagraph>(find.byType(RichText)).text.style!.fontFamily, 'FlutterTest');
expect(tester.getSize(find.byType(Tab)), material3 ? const Size(15.0, 46.0) : const Size(14.0, 46.0)); expect(
tester.getSize(find.byType(Tab)),
material3 ? const Size(14.25, 46.0) : const Size(14.0, 46.0),
);
}); });
testWidgets('Tab sizing - icon and text', (WidgetTester tester) async { testWidgets('Tab sizing - icon and text', (WidgetTester tester) async {
@ -338,7 +339,9 @@ void main() {
MaterialApp(theme: theme, home: const Center(child: Material(child: Tab(icon: SizedBox(width: 10.0, height: 10.0), text: 'x')))), MaterialApp(theme: theme, 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, 'FlutterTest'); expect(tester.renderObject<RenderParagraph>(find.byType(RichText)).text.style!.fontFamily, 'FlutterTest');
expect(tester.getSize(find.byType(Tab)), material3 ? const Size(15.0, 72.0) : const Size(14.0, 72.0)); expect(
tester.getSize(find.byType(Tab)),
material3 ? const Size(14.25, 72.0) : const Size(14.0, 72.0));
}); });
testWidgets('Tab sizing - icon, iconMargin and text', (WidgetTester tester) async { testWidgets('Tab sizing - icon, iconMargin and text', (WidgetTester tester) async {
@ -372,7 +375,9 @@ void main() {
MaterialApp(theme: theme, home: const Center(child: Material(child: Tab(icon: SizedBox(width: 10.0, height: 10.0), child: Text('x'))))), MaterialApp(theme: theme, 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, 'FlutterTest'); expect(tester.renderObject<RenderParagraph>(find.byType(RichText)).text.style!.fontFamily, 'FlutterTest');
expect(tester.getSize(find.byType(Tab)), material3 ? const Size(15.0, 72.0) : const Size(14.0, 72.0)); expect(
tester.getSize(find.byType(Tab)),
material3 ? const Size(14.25, 72.0) : const Size(14.0, 72.0));
}); });
testWidgets('Tab color - normal', (WidgetTester tester) async { testWidgets('Tab color - normal', (WidgetTester tester) async {
@ -488,22 +493,13 @@ void main() {
const double indicatorWeight = 3.0; const double indicatorWeight = 3.0;
final RRect rrect = ui.ParagraphBuilder.shouldDisableRoundingHack final RRect rrect = RRect.fromLTRBAndCorners(
? RRect.fromLTRBAndCorners(
64.75, 64.75,
tabBarBox.size.height - indicatorWeight, tabBarBox.size.height - indicatorWeight,
135.25, 135.25,
tabBarBox.size.height, tabBarBox.size.height,
topLeft: const Radius.circular(3.0), topLeft: const Radius.circular(3.0),
topRight: const Radius.circular(3.0), topRight: const Radius.circular(3.0),
)
: RRect.fromLTRBAndCorners(
64.5,
tabBarBox.size.height - indicatorWeight,
135.5,
tabBarBox.size.height,
topLeft: const Radius.circular(3.0),
topRight: const Radius.circular(3.0),
); );
expect( expect(
@ -2416,7 +2412,7 @@ void main() {
// that. Tabs are padded horizontally with kTabLabelPadding. // that. Tabs are padded horizontally with kTabLabelPadding.
final double tabRight = 800.0 - kTabLabelPadding.right; final double tabRight = 800.0 - kTabLabelPadding.right;
expect(tester.getTopRight(find.widgetWithText(Tab, 'TAB #19')).dx, tabRight); expect(tester.getTopRight(find.widgetWithText(Tab, 'TAB #19')).dx, moreOrLessEquals(tabRight));
}); });
testWidgets('TabBar with indicatorWeight, indicatorPadding (LTR)', (WidgetTester tester) async { testWidgets('TabBar with indicatorWeight, indicatorPadding (LTR)', (WidgetTester tester) async {
@ -6089,9 +6085,9 @@ void main() {
// Tabs should fill the width of the TabBar. // Tabs should fill the width of the TabBar.
double tabOneLeft = ((tabBar.width / 2) - tabOneRect.width) / 2; double tabOneLeft = ((tabBar.width / 2) - tabOneRect.width) / 2;
expect(tabOneRect.left, equals(tabOneLeft)); expect(tabOneRect.left, moreOrLessEquals(tabOneLeft));
double tabTwoRight = tabBar.width - ((tabBar.width / 2) - tabTwoRect.width) / 2; double tabTwoRight = tabBar.width - ((tabBar.width / 2) - tabTwoRect.width) / 2;
expect(tabTwoRect.right, equals(tabTwoRight)); expect(tabTwoRect.right, moreOrLessEquals(tabTwoRight));
// Test default TabAlignment when isScrollable is true. // Test default TabAlignment when isScrollable is true.
await tester.pumpWidget(buildFrame( await tester.pumpWidget(buildFrame(
@ -6106,9 +6102,9 @@ void main() {
// Tabs should be aligned to the start of the TabBar. // Tabs should be aligned to the start of the TabBar.
tabOneLeft = kTabLabelPadding.left + tabStartOffset; tabOneLeft = kTabLabelPadding.left + tabStartOffset;
expect(tabOneRect.left, equals(tabOneLeft)); expect(tabOneRect.left, moreOrLessEquals(tabOneLeft));
tabTwoRight = kTabLabelPadding.horizontal + tabStartOffset + tabOneRect.width + kTabLabelPadding.left + tabTwoRect.width; tabTwoRight = kTabLabelPadding.horizontal + tabStartOffset + tabOneRect.width + kTabLabelPadding.left + tabTwoRect.width;
expect(tabTwoRect.right, equals(tabTwoRight)); expect(tabTwoRect.right, moreOrLessEquals(tabTwoRight));
}); });
testWidgets('TabAlignment.fill only supports non-scrollable tab bar', (WidgetTester tester) async { testWidgets('TabAlignment.fill only supports non-scrollable tab bar', (WidgetTester tester) async {
@ -6181,9 +6177,9 @@ void main() {
// By defaults tabs should fill the width of the TabBar. // By defaults tabs should fill the width of the TabBar.
double tabOneLeft = ((availableWidth / 2) - tabOneRect.width) / 2; double tabOneLeft = ((availableWidth / 2) - tabOneRect.width) / 2;
expect(tabOneRect.left, equals(tabOneLeft)); expect(tabOneRect.left, moreOrLessEquals(tabOneLeft));
double tabTwoRight = availableWidth - ((availableWidth / 2) - tabTwoRect.width) / 2; double tabTwoRight = availableWidth - ((availableWidth / 2) - tabTwoRect.width) / 2;
expect(tabTwoRect.right, equals(tabTwoRight)); expect(tabTwoRect.right, moreOrLessEquals(tabTwoRight));
// Test TabAlignment.center when isScrollable is false. // Test TabAlignment.center when isScrollable is false.
await tester.pumpWidget(buildFrame( await tester.pumpWidget(buildFrame(
@ -6199,9 +6195,9 @@ void main() {
// Tabs should not fill the width of the TabBar. // Tabs should not fill the width of the TabBar.
tabOneLeft = kTabLabelPadding.left; tabOneLeft = kTabLabelPadding.left;
expect(tabOneRect.left, equals(tabOneLeft)); expect(tabOneRect.left, moreOrLessEquals(tabOneLeft));
tabTwoRight = kTabLabelPadding.horizontal + tabOneRect.width + kTabLabelPadding.left + tabTwoRect.width; tabTwoRight = kTabLabelPadding.horizontal + tabOneRect.width + kTabLabelPadding.left + tabTwoRect.width;
expect(tabTwoRect.right, equals(tabTwoRight)); expect(tabTwoRect.right, moreOrLessEquals(tabTwoRight));
}); });
testWidgets('Material3 - TabAlignment updates tabs alignment (scrollable TabBar)', (WidgetTester tester) async { testWidgets('Material3 - TabAlignment updates tabs alignment (scrollable TabBar)', (WidgetTester tester) async {
@ -6690,9 +6686,9 @@ void main() {
// By default tabs should fill the width of the TabBar. // By default tabs should fill the width of the TabBar.
double tabOneLeft = ((tabBar.width / 2) - tabOneRect.width) / 2; double tabOneLeft = ((tabBar.width / 2) - tabOneRect.width) / 2;
expect(tabOneRect.left, equals(tabOneLeft)); expect(tabOneRect.left, moreOrLessEquals(tabOneLeft));
double tabTwoRight = tabBar.width - ((tabBar.width / 2) - tabTwoRect.width) / 2; double tabTwoRight = tabBar.width - ((tabBar.width / 2) - tabTwoRect.width) / 2;
expect(tabTwoRect.right, equals(tabTwoRight)); expect(tabTwoRect.right, moreOrLessEquals(tabTwoRight));
// Test TabAlignment.center when isScrollable is false. // Test TabAlignment.center when isScrollable is false.
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -6706,9 +6702,9 @@ void main() {
// Tabs should not fill the width of the TabBar. // Tabs should not fill the width of the TabBar.
tabOneLeft = kTabLabelPadding.left; tabOneLeft = kTabLabelPadding.left;
expect(tabOneRect.left, equals(tabOneLeft)); expect(tabOneRect.left, moreOrLessEquals(tabOneLeft));
tabTwoRight = kTabLabelPadding.horizontal + tabOneRect.width + kTabLabelPadding.left + tabTwoRect.width; tabTwoRight = kTabLabelPadding.horizontal + tabOneRect.width + kTabLabelPadding.left + tabTwoRect.width;
expect(tabTwoRect.right, equals(tabTwoRight)); expect(tabTwoRect.right, moreOrLessEquals(tabTwoRight));
}); });
}); });
} }

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' as ui show ParagraphBuilder;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -620,12 +618,8 @@ void main() {
), ),
); );
final Size textButtonSize = ui.ParagraphBuilder.shouldDisableRoundingHack const Size textButtonSize = Size(68.5, 48.0);
? const Size(68.5, 48.0) const Size textSize = Size(52.5, 18.0);
: const Size(69.0, 48.0);
final Size textSize = ui.ParagraphBuilder.shouldDisableRoundingHack
? const Size(52.5, 18.0)
: const Size(53.0, 18.0);
expect(tester.getSize(find.byType(TextButton)), textButtonSize); expect(tester.getSize(find.byType(TextButton)), textButtonSize);
expect(tester.getSize(find.byType(Text)), textSize); expect(tester.getSize(find.byType(Text)), textSize);

View File

@ -969,7 +969,7 @@ void main() {
expect(tester.getTopLeft(find.text(selectTimeString)), equals(const Offset(154, 155))); expect(tester.getTopLeft(find.text(selectTimeString)), equals(const Offset(154, 155)));
expect(tester.getBottomRight(find.text(selectTimeString)), equals( expect(tester.getBottomRight(find.text(selectTimeString)), equals(
ParagraphBuilder.shouldDisableRoundingHack ? const Offset(280.5, 165) : const Offset(281, 165), const Offset(280.5, 165),
)); ));
expect(tester.getBottomRight(find.text(okString)).dx, 644); expect(tester.getBottomRight(find.text(okString)).dx, 644);
expect(tester.getBottomLeft(find.text(okString)).dx, 616); expect(tester.getBottomLeft(find.text(okString)).dx, 616);
@ -983,7 +983,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(tester.getTopLeft(find.text(selectTimeString)), equals( expect(tester.getTopLeft(find.text(selectTimeString)), equals(
ParagraphBuilder.shouldDisableRoundingHack ? const Offset(519.5, 155) : const Offset(519, 155), const Offset(519.5, 155),
)); ));
expect(tester.getBottomRight(find.text(selectTimeString)), equals(const Offset(646, 165))); expect(tester.getBottomRight(find.text(selectTimeString)), equals(const Offset(646, 165)));
expect(tester.getBottomLeft(find.text(okString)).dx, 156); expect(tester.getBottomLeft(find.text(okString)).dx, 156);
@ -1031,8 +1031,14 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(tester.getTopLeft(find.text(selectTimeString)), equals(const Offset(138, 129))); expect(tester.getTopLeft(find.text(selectTimeString)), equals(const Offset(138, 129)));
expect(tester.getBottomRight(find.text(selectTimeString)), equals(const Offset(295.0, 149.0))); expect(
expect(tester.getBottomLeft(find.text(okString)).dx, 615.5); tester.getBottomRight(find.text(selectTimeString)),
const Offset(294.75, 149.0),
);
expect(
tester.getBottomLeft(find.text(okString)).dx,
moreOrLessEquals(615.9, epsilon: 0.001),
);
expect(tester.getBottomRight(find.text(cancelString)).dx, 578); expect(tester.getBottomRight(find.text(cancelString)).dx, 578);
await tester.tap(find.text(okString)); await tester.tap(find.text(okString));
@ -1042,10 +1048,19 @@ void main() {
await tester.tap(find.text('X')); await tester.tap(find.text('X'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(tester.getTopLeft(find.text(selectTimeString)), equals(const Offset(505.0, 129.0))); expect(
tester.getTopLeft(find.text(selectTimeString)),
equals(const Offset(505.25, 129.0)),
);
expect(tester.getBottomRight(find.text(selectTimeString)), equals(const Offset(662, 149))); expect(tester.getBottomRight(find.text(selectTimeString)), equals(const Offset(662, 149)));
expect(tester.getBottomLeft(find.text(okString)).dx, 155.5); expect(
expect(tester.getBottomRight(find.text(okString)).dx, 184.5); tester.getBottomLeft(find.text(okString)).dx,
moreOrLessEquals(155.9, epsilon: 0.001),
);
expect(
tester.getBottomRight(find.text(okString)).dx,
moreOrLessEquals(184.1, epsilon: 0.001),
);
expect(tester.getBottomLeft(find.text(cancelString)).dx, 222); expect(tester.getBottomLeft(find.text(cancelString)).dx, 222);
await tester.tap(find.text(okString)); await tester.tap(find.text(okString));

View File

@ -1509,9 +1509,6 @@ void main() {
}); });
test('TextPainter line breaking does not round to integers', () { test('TextPainter line breaking does not round to integers', () {
if (!ui.ParagraphBuilder.shouldDisableRoundingHack) {
return;
}
const double fontSize = 1.25; const double fontSize = 1.25;
const String text = '12345'; const String text = '12345';
assert((fontSize * text.length).truncate() != fontSize * text.length); assert((fontSize * text.length).truncate() != fontSize * text.length);

View File

@ -71,25 +71,11 @@ void main() {
expect(find.text('hello, world'), findsOneWidget); expect(find.text('hello, world'), findsOneWidget);
expect(find.text('你好,世界'), findsOneWidget); expect(find.text('你好,世界'), findsOneWidget);
Offset topLeft = tester.getTopLeft(find.text('hello, world')); expect(tester.getTopLeft(find.text('hello, world')).dy, 298.0);
Offset topRight = tester.getTopRight(find.text('hello, world')); expect(tester.getBottomLeft(find.text('hello, world')).dy, 318.0);
Offset bottomLeft = tester.getBottomLeft(find.text('hello, world'));
Offset bottomRight = tester.getBottomRight(find.text('hello, world'));
expect(topLeft, const Offset(392.0, 298.0)); expect(tester.getTopLeft(find.text('你好,世界')).dy, 346.0);
expect(topRight, const Offset(562.0, 298.0)); expect(tester.getBottomLeft(find.text('你好,世界')).dy, 366.0);
expect(bottomLeft, const Offset(392.0, 318.0));
expect(bottomRight, const Offset(562.0, 318.0));
topLeft = tester.getTopLeft(find.text('你好,世界'));
topRight = tester.getTopRight(find.text('你好,世界'));
bottomLeft = tester.getBottomLeft(find.text('你好,世界'));
bottomRight = tester.getBottomRight(find.text('你好,世界'));
expect(topLeft, const Offset(392.0, 346.0));
expect(topRight, const Offset(463.0, 346.0));
expect(bottomLeft, const Offset(392.0, 366.0));
expect(bottomRight, const Offset(463.0, 366.0));
}); });
testWidgets('Text baseline with EN locale', (WidgetTester tester) async { testWidgets('Text baseline with EN locale', (WidgetTester tester) async {
@ -156,24 +142,10 @@ void main() {
expect(find.text('hello, world'), findsOneWidget); expect(find.text('hello, world'), findsOneWidget);
expect(find.text('你好,世界'), findsOneWidget); expect(find.text('你好,世界'), findsOneWidget);
Offset topLeft = tester.getTopLeft(find.text('hello, world')); expect(tester.getTopLeft(find.text('hello, world')).dy, 298.0);
Offset topRight = tester.getTopRight(find.text('hello, world')); expect(tester.getBottomLeft(find.text('hello, world')).dy, 318.0);
Offset bottomLeft = tester.getBottomLeft(find.text('hello, world'));
Offset bottomRight = tester.getBottomRight(find.text('hello, world'));
expect(topLeft, const Offset(392.0, 298.0)); expect(tester.getTopLeft(find.text('你好,世界')).dy, 346.0);
expect(topRight, const Offset(562.0, 298.0)); expect(tester.getBottomLeft(find.text('你好,世界')).dy, 366.0);
expect(bottomLeft, const Offset(392.0, 318.0));
expect(bottomRight, const Offset(562.0, 318.0));
topLeft = tester.getTopLeft(find.text('你好,世界'));
topRight = tester.getTopRight(find.text('你好,世界'));
bottomLeft = tester.getBottomLeft(find.text('你好,世界'));
bottomRight = tester.getBottomRight(find.text('你好,世界'));
expect(topLeft, const Offset(392.0, 346.0));
expect(topRight, const Offset(463.0, 346.0));
expect(bottomLeft, const Offset(392.0, 366.0));
expect(bottomRight, const Offset(463.0, 366.0));
}); });
} }