Skip to content

Commit

Permalink
fix text tests on the web (flutter#44021)
Browse files Browse the repository at this point in the history
  • Loading branch information
yjbanov authored Nov 5, 2019
1 parent 7d03371 commit f6eb129
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dev/bots/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ const int kWebBatchSize = 20;
//
// TODO(yjbanov): we're getting rid of this blacklist as part of https://github.com/flutter/flutter/projects/60
const List<String> kWebTestFileBlacklist = <String>[
// This test doesn't compile because it depends on code outside the flutter package.
'test/examples/sector_layout_test.dart',
'test/widgets/text_test.dart',
'test/widgets/selectable_text_test.dart',
'test/widgets/color_filter_test.dart',
'test/widgets/editable_text_cursor_test.dart',
Expand Down
24 changes: 17 additions & 7 deletions packages/flutter/test/widgets/text_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:ui' as ui;

import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
Expand Down Expand Up @@ -59,7 +61,7 @@ void main() {
final Size largeSize = tester.getSize(find.byType(RichText));
expect(largeSize.width, 105.0);
expect(largeSize.height, equals(21.0));
}, skip: isBrowser);
});

testWidgets('Text respects textScaleFactor with explicit font size', (WidgetTester tester) async {
await tester.pumpWidget(const Center(
Expand Down Expand Up @@ -87,7 +89,7 @@ void main() {
final Size largeSize = tester.getSize(find.byType(RichText));
expect(largeSize.width, anyOf(131.0, 130.0));
expect(largeSize.height, equals(26.0));
}, skip: isBrowser);
});

testWidgets('Text throws a nice error message if there\'s no Directionality', (WidgetTester tester) async {
await tester.pumpWidget(const Text('Hello'));
Expand Down Expand Up @@ -157,7 +159,7 @@ void main() {
),
);
expect(tester.takeException(), null);
});
}, skip: isBrowser); // TODO(yjbanov): https://github.com/flutter/flutter/issues/42086

testWidgets('semanticsLabel can override text label', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
Expand Down Expand Up @@ -411,7 +413,7 @@ void main() {
),
);
semantics.dispose();
}, skip: isBrowser);
});


testWidgets('recognizers split semantic node - bidi', (WidgetTester tester) async {
Expand Down Expand Up @@ -602,7 +604,7 @@ void main() {
),
);
semantics.dispose();
}, skip: isBrowser);
}, skip: isBrowser); // TODO(yjbanov): https://github.com/flutter/flutter/issues/42086

testWidgets('inline widgets semantic nodes scale', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
Expand Down Expand Up @@ -682,7 +684,7 @@ void main() {
),
);
semantics.dispose();
}, skip: isBrowser);
}, skip: isBrowser); // TODO(yjbanov): https://github.com/flutter/flutter/issues/42086

testWidgets('Overflow is clipping correctly - short text with overflow: clip', (WidgetTester tester) async {
await _pumpTextWidget(
Expand Down Expand Up @@ -797,7 +799,15 @@ void main() {
final Size textSizeLongestLine = tester.getSize(find.byType(Text));
expect(textSizeLongestLine.width, equals(630.0));
expect(textSizeLongestLine.height, equals(fontHeight * 2));
}, skip: isBrowser);
}, skip: isBrowser); // TODO(yjbanov): https://github.com/flutter/flutter/issues/44020

testWidgets('Paragraph.getBoxesForRange returns nothing when selection range is zero length', (WidgetTester tester) async {
final ui.ParagraphBuilder builder = ui.ParagraphBuilder(ui.ParagraphStyle());
builder.addText('hello');
final ui.Paragraph paragraph = builder.build();
paragraph.layout(const ui.ParagraphConstraints(width: 1000));
expect(paragraph.getBoxesForRange(2, 2), isEmpty);
});
}

Future<void> _pumpTextWidget({ WidgetTester tester, String text, TextOverflow overflow }) {
Expand Down

0 comments on commit f6eb129

Please sign in to comment.