forked from firka/flutter
@@ -746,18 +746,16 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
// TODO(gspencer): Update this test when the font metric bug is fixed to remove the anyOfs.
|
||||
// https://github.com/flutter/flutter/issues/12357
|
||||
expect(
|
||||
tester.getSize(find.text('Chip A')),
|
||||
anyOf(const Size(84.0, 14.0), const Size(83.0, 14.0)),
|
||||
const Size(84.0, 14.0),
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.text('Chip B')),
|
||||
anyOf(const Size(84.0, 14.0), const Size(83.0, 14.0)),
|
||||
const Size(84.0, 14.0),
|
||||
);
|
||||
expect(tester.getSize(find.byType(Chip).first), anyOf(const Size(132.0, 48.0), const Size(131.0, 48.0)));
|
||||
expect(tester.getSize(find.byType(Chip).last), anyOf(const Size(132.0, 48.0), const Size(131.0, 48.0)));
|
||||
expect(tester.getSize(find.byType(Chip).first), const Size(132.0, 48.0));
|
||||
expect(tester.getSize(find.byType(Chip).last), const Size(132.0, 48.0));
|
||||
|
||||
await tester.pumpWidget(
|
||||
wrapForChip(
|
||||
@@ -777,14 +775,10 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
// TODO(gspencer): Update this test when the font metric bug is fixed to remove the anyOfs.
|
||||
// https://github.com/flutter/flutter/issues/12357
|
||||
expect(tester.getSize(find.text('Chip A')), anyOf(const Size(252.0, 42.0), const Size(251.0, 42.0)));
|
||||
expect(tester.getSize(find.text('Chip B')), anyOf(const Size(252.0, 42.0), const Size(251.0, 42.0)));
|
||||
expect(tester.getSize(find.byType(Chip).first).width, anyOf(310.0, 311.0));
|
||||
expect(tester.getSize(find.byType(Chip).first).height, equals(50.0));
|
||||
expect(tester.getSize(find.byType(Chip).last).width, anyOf(310.0, 311.0));
|
||||
expect(tester.getSize(find.byType(Chip).last).height, equals(50.0));
|
||||
expect(tester.getSize(find.text('Chip A')), const Size(252.0, 42.0));
|
||||
expect(tester.getSize(find.text('Chip B')), const Size(252.0, 42.0));
|
||||
expect(tester.getSize(find.byType(Chip).first), const Size(310.0, 50.0));
|
||||
expect(tester.getSize(find.byType(Chip).last), const Size(310.0, 50.0));
|
||||
|
||||
// Check that individual text scales are taken into account.
|
||||
await tester.pumpWidget(
|
||||
@@ -804,13 +798,10 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
// TODO(gspencer): Update this test when the font metric bug is fixed to remove the anyOfs.
|
||||
// https://github.com/flutter/flutter/issues/12357
|
||||
expect(tester.getSize(find.text('Chip A')), anyOf(const Size(252.0, 42.0), const Size(251.0, 42.0)));
|
||||
expect(tester.getSize(find.text('Chip B')), anyOf(const Size(84.0, 14.0), const Size(83.0, 14.0)));
|
||||
expect(tester.getSize(find.byType(Chip).first).width, anyOf(318.0, 319.0));
|
||||
expect(tester.getSize(find.byType(Chip).first).height, equals(50.0));
|
||||
expect(tester.getSize(find.byType(Chip).last), anyOf(const Size(132.0, 48.0), const Size(131.0, 48.0)));
|
||||
expect(tester.getSize(find.text('Chip A')), const Size(252.0, 42.0));
|
||||
expect(tester.getSize(find.text('Chip B')), const Size(84.0, 14.0));
|
||||
expect(tester.getSize(find.byType(Chip).first), const Size(318.0, 50.0));
|
||||
expect(tester.getSize(find.byType(Chip).last), const Size(132.0, 48.0));
|
||||
});
|
||||
|
||||
testWidgets('Labels can be non-text widgets', (WidgetTester tester) async {
|
||||
@@ -833,17 +824,9 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
// TODO(gspencer): Update this test when the font metric bug is fixed to remove the anyOfs.
|
||||
// https://github.com/flutter/flutter/issues/12357
|
||||
expect(
|
||||
tester.getSize(find.byKey(keyA)),
|
||||
anyOf(const Size(84.0, 14.0), const Size(83.0, 14.0)),
|
||||
);
|
||||
expect(tester.getSize(find.byKey(keyA)), const Size(84.0, 14.0));
|
||||
expect(tester.getSize(find.byKey(keyB)), const Size(10.0, 10.0));
|
||||
expect(
|
||||
tester.getSize(find.byType(Chip).first),
|
||||
anyOf(const Size(132.0, 48.0), const Size(131.0, 48.0)),
|
||||
);
|
||||
expect(tester.getSize(find.byType(Chip).first), const Size(132.0, 48.0));
|
||||
expect(tester.getSize(find.byType(Chip).last), const Size(58.0, 48.0));
|
||||
});
|
||||
|
||||
|
||||
@@ -577,9 +577,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
skip: isBrowser, // https://github.com/flutter/flutter/issues/99786
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Destination spacing is correct - [labelType]=selected, [textScaleFactor]=3.0', (WidgetTester tester) async {
|
||||
// Padding at the top of the rail.
|
||||
@@ -671,9 +669,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
skip: isBrowser, // https://github.com/flutter/flutter/issues/99786
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Destination spacing is correct - [labelType]=selected, [textScaleFactor]=0.75', (WidgetTester tester) async {
|
||||
// Padding at the top of the rail.
|
||||
@@ -765,9 +761,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
skip: isBrowser, // https://github.com/flutter/flutter/issues/99786
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Destination spacing is correct - [labelType]=all, [textScaleFactor]=1.0 (default)', (WidgetTester tester) async {
|
||||
// Padding at the top of the rail.
|
||||
@@ -858,9 +852,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
skip: isBrowser, // https://github.com/flutter/flutter/issues/99786
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Destination spacing is correct - [labelType]=all, [textScaleFactor]=3.0', (WidgetTester tester) async {
|
||||
// Padding at the top of the rail.
|
||||
@@ -952,9 +944,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
skip: isBrowser, // https://github.com/flutter/flutter/issues/99786
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Destination spacing is correct - [labelType]=all, [textScaleFactor]=0.75', (WidgetTester tester) async {
|
||||
// Padding at the top of the rail.
|
||||
@@ -1046,9 +1036,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
skip: isBrowser, // https://github.com/flutter/flutter/issues/99786
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Destination spacing is correct for a compact rail - [preferredWidth]=56, [textScaleFactor]=1.0 (default)', (WidgetTester tester) async {
|
||||
// Padding at the top of the rail.
|
||||
|
||||
@@ -1010,10 +1010,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(tester.getSize(find.byType(OutlinedButton)), equals(const Size(88.0, 48.0)));
|
||||
// Scaled text rendering is different on Linux and Mac by one pixel.
|
||||
// TODO(gspencergoog): Figure out why this is, and fix it. https://github.com/flutter/flutter/issues/12357
|
||||
expect(tester.getSize(find.byType(Text)).width, isIn(<double>[54.0, 55.0]));
|
||||
expect(tester.getSize(find.byType(Text)).height, isIn(<double>[18.0, 19.0]));
|
||||
expect(tester.getSize(find.byType(Text)), const Size(55.0, 18.0));
|
||||
|
||||
// Set text scale large enough to expand text and button.
|
||||
await tester.pumpWidget(
|
||||
@@ -1035,13 +1032,9 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
// Scaled text rendering is different on Linux and Mac by one pixel.
|
||||
// TODO(gspencergoog): Figure out why this is, and fix it. https://github.com/flutter/flutter/issues/12357
|
||||
expect(tester.getSize(find.byType(OutlinedButton)).width, isIn(<double>[133.0, 134.0]));
|
||||
expect(tester.getSize(find.byType(OutlinedButton)).height, equals(48.0));
|
||||
expect(tester.getSize(find.byType(Text)).width, isIn(<double>[126.0, 127.0]));
|
||||
expect(tester.getSize(find.byType(Text)).height, equals(42.0));
|
||||
});
|
||||
expect(tester.getSize(find.byType(OutlinedButton)), const Size(134.0, 48.0));
|
||||
expect(tester.getSize(find.byType(Text)), const Size(126.0, 42.0));
|
||||
}, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/122066
|
||||
|
||||
testWidgets('OutlinedButton onPressed and onLongPress callbacks are distinctly recognized', (WidgetTester tester) async {
|
||||
bool didPressButton = false;
|
||||
|
||||
@@ -568,12 +568,8 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
// Scaled text rendering is different on Linux and Mac by one pixel.
|
||||
// TODO(gspencergoog): Figure out why this is, and fix it. https://github.com/flutter/flutter/issues/12357
|
||||
expect(tester.getSize(find.byType(TextButton)).width, isIn(<double>[70.0, 71.0]));
|
||||
expect(tester.getSize(find.byType(TextButton)).height, isIn(<double>[47.0, 48.0]));
|
||||
expect(tester.getSize(find.byType(Text)).width, isIn(<double>[54.0, 55.0]));
|
||||
expect(tester.getSize(find.byType(Text)).height, isIn(<double>[18.0, 19.0]));
|
||||
expect(tester.getSize(find.byType(TextButton)), const Size(71.0, 48.0));
|
||||
expect(tester.getSize(find.byType(Text)), const Size(55.0, 18.0));
|
||||
|
||||
// Set text scale large enough to expand text and button.
|
||||
await tester.pumpWidget(
|
||||
@@ -595,13 +591,9 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
// Scaled text rendering is different on Linux and Mac by one pixel.
|
||||
// TODO(gspencergoog): Figure out why this is, and fix it. https://github.com/flutter/flutter/issues/12357
|
||||
expect(tester.getSize(find.byType(TextButton)).width, isIn(<double>[133.0, 134.0]));
|
||||
expect(tester.getSize(find.byType(TextButton)).height, equals(48.0));
|
||||
expect(tester.getSize(find.byType(Text)).width, isIn(<double>[126.0, 127.0]));
|
||||
expect(tester.getSize(find.byType(Text)).height, equals(42.0));
|
||||
});
|
||||
expect(tester.getSize(find.byType(TextButton)), const Size(134.0, 48.0));
|
||||
expect(tester.getSize(find.byType(Text)), const Size(126.0, 42.0));
|
||||
}, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/61016
|
||||
|
||||
testWidgets('TextButton size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
|
||||
Widget buildFrame(MaterialTapTargetSize tapTargetSize, Key key) {
|
||||
|
||||
@@ -8,9 +8,6 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
const bool isCanvasKit =
|
||||
bool.fromEnvironment('FLUTTER_WEB_USE_SKIA');
|
||||
|
||||
void main() {
|
||||
test('TextPainter caret test', () {
|
||||
final TextPainter painter = TextPainter()
|
||||
@@ -818,25 +815,25 @@ void main() {
|
||||
expect(lines[2].hardBreak, true);
|
||||
expect(lines[3].hardBreak, true);
|
||||
|
||||
expect(lines[0].ascent, 11.199999809265137);
|
||||
expect(lines[1].ascent, 11.199999809265137);
|
||||
expect(lines[2].ascent, 11.199999809265137);
|
||||
expect(lines[3].ascent, 11.199999809265137);
|
||||
expect(lines[0].ascent, 10.5);
|
||||
expect(lines[1].ascent, 10.5);
|
||||
expect(lines[2].ascent, 10.5);
|
||||
expect(lines[3].ascent, 10.5);
|
||||
|
||||
expect(lines[0].descent, 2.799999952316284);
|
||||
expect(lines[1].descent, 2.799999952316284);
|
||||
expect(lines[2].descent, 2.799999952316284);
|
||||
expect(lines[3].descent, 2.799999952316284);
|
||||
expect(lines[0].descent, 3.5);
|
||||
expect(lines[1].descent, 3.5);
|
||||
expect(lines[2].descent, 3.5);
|
||||
expect(lines[3].descent, 3.5);
|
||||
|
||||
expect(lines[0].unscaledAscent, 11.199999809265137);
|
||||
expect(lines[1].unscaledAscent, 11.199999809265137);
|
||||
expect(lines[2].unscaledAscent, 11.199999809265137);
|
||||
expect(lines[3].unscaledAscent, 11.199999809265137);
|
||||
expect(lines[0].unscaledAscent, 10.5);
|
||||
expect(lines[1].unscaledAscent, 10.5);
|
||||
expect(lines[2].unscaledAscent, 10.5);
|
||||
expect(lines[3].unscaledAscent, 10.5);
|
||||
|
||||
expect(lines[0].baseline, 11.200000047683716);
|
||||
expect(lines[1].baseline, 25.200000047683716);
|
||||
expect(lines[2].baseline, 39.200000047683716);
|
||||
expect(lines[3].baseline, 53.200000047683716);
|
||||
expect(lines[0].baseline, 10.5);
|
||||
expect(lines[1].baseline, 24.5);
|
||||
expect(lines[2].baseline, 38.5);
|
||||
expect(lines[3].baseline, 52.5);
|
||||
|
||||
expect(lines[0].height, 14);
|
||||
expect(lines[1].height, 14);
|
||||
@@ -858,7 +855,7 @@ void main() {
|
||||
expect(lines[2].lineNumber, 2);
|
||||
expect(lines[3].lineNumber, 3);
|
||||
painter.dispose();
|
||||
}, skip: true); // https://github.com/flutter/flutter/issues/62819
|
||||
}, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/122066
|
||||
|
||||
test('TextPainter caret height and line height', () {
|
||||
final TextPainter painter = TextPainter()
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:ui' as ui show BoxHeightStyle, BoxWidthStyle, Paragraph, TextBox;
|
||||
|
||||
import 'package:flutter/foundation.dart' show isCanvasKit, kIsWeb;
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
@@ -12,7 +13,6 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'rendering_tester.dart';
|
||||
|
||||
const String _kText = "I polished up that handle so carefullee\nThat now I am the Ruler of the Queen's Navee!";
|
||||
const bool isCanvasKit = bool.fromEnvironment('FLUTTER_WEB_USE_SKIA');
|
||||
|
||||
// A subclass of RenderParagraph that returns an empty list in getBoxesForSelection
|
||||
// for a given TextSelection.
|
||||
@@ -148,7 +148,7 @@ void main() {
|
||||
final RenderParagraph paragraph = RenderParagraph(
|
||||
const TextSpan(
|
||||
text: 'First ',
|
||||
style: TextStyle(fontFamily: 'FlutterTest', fontSize: 10.0),
|
||||
style: TextStyle(fontSize: 10.0),
|
||||
children: <InlineSpan>[
|
||||
TextSpan(text: 'smallsecond ', style: TextStyle(fontSize: 5.0)),
|
||||
TextSpan(text: 'third fourth fifth'),
|
||||
@@ -187,7 +187,7 @@ void main() {
|
||||
expect(boxes[2], const TextBox.fromLTRBD(0.0, 10.0, 130.0, 20.0, TextDirection.ltr));
|
||||
// 'fifth':
|
||||
expect(boxes[3], const TextBox.fromLTRBD(0.0, 20.0, 50.0, 30.0, TextDirection.ltr));
|
||||
}, skip: !isLinux); // mac typography values can differ https://github.com/flutter/flutter/issues/12357
|
||||
}, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/61016
|
||||
|
||||
test('getBoxesForSelection test with boxHeightStyle and boxWidthStyle set to max', () {
|
||||
final RenderParagraph paragraph = RenderParagraph(
|
||||
@@ -414,10 +414,7 @@ void main() {
|
||||
textScaleFactor: 1.3,
|
||||
);
|
||||
paragraph.layout(const BoxConstraints());
|
||||
// anyOf is needed here because Linux and Mac have different text
|
||||
// rendering widths in tests.
|
||||
// TODO(gspencergoog): Figure out why this is, and fix it. https://github.com/flutter/flutter/issues/12357
|
||||
expect(paragraph.size.width, anyOf(79.0, 78.0));
|
||||
expect(paragraph.size.width, 78.0);
|
||||
expect(paragraph.size.height, 26.0);
|
||||
|
||||
// Test the sizes of nested spans.
|
||||
@@ -430,17 +427,14 @@ void main() {
|
||||
];
|
||||
expect(boxes.length, equals(4));
|
||||
|
||||
// anyOf is needed here and below because Linux and Mac have different text
|
||||
// rendering widths in tests.
|
||||
// TODO(gspencergoog): Figure out why this is, and fix it. https://github.com/flutter/flutter/issues/12357
|
||||
expect(boxes[0].toRect().width, anyOf(14.0, 13.0));
|
||||
expect(boxes[0].toRect().height, moreOrLessEquals(13.0, epsilon: 0.0001));
|
||||
expect(boxes[1].toRect().width, anyOf(27.0, 26.0));
|
||||
expect(boxes[1].toRect().height, moreOrLessEquals(26.0, epsilon: 0.0001));
|
||||
expect(boxes[2].toRect().width, anyOf(27.0, 26.0));
|
||||
expect(boxes[2].toRect().height, moreOrLessEquals(26.0, epsilon: 0.0001));
|
||||
expect(boxes[3].toRect().width, anyOf(14.0, 13.0));
|
||||
expect(boxes[3].toRect().height, moreOrLessEquals(13.0, epsilon: 0.0001));
|
||||
expect(boxes[0].toRect().width, 13.0);
|
||||
expect(boxes[0].toRect().height, 13.0);
|
||||
expect(boxes[1].toRect().width, 26.0);
|
||||
expect(boxes[1].toRect().height, 26.0);
|
||||
expect(boxes[2].toRect().width, 26.0);
|
||||
expect(boxes[2].toRect().height, 26.0);
|
||||
expect(boxes[3].toRect().width, 13.0);
|
||||
expect(boxes[3].toRect().height, 13.0);
|
||||
});
|
||||
|
||||
test('toStringDeep', () {
|
||||
|
||||
@@ -92,7 +92,7 @@ void main() {
|
||||
expect(text, isNotNull);
|
||||
expect(text.textScaleFactor, 1.3);
|
||||
final Size largeSize = tester.getSize(find.byType(RichText));
|
||||
expect(largeSize.width, anyOf(131.0, 130.0));
|
||||
expect(largeSize.width, 130.0);
|
||||
expect(largeSize.height, equals(26.0));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user