diff --git a/packages/flutter/test/widgets/text_test.dart b/packages/flutter/test/widgets/text_test.dart index 3115ef2cc2..4ec4e5681d 100644 --- a/packages/flutter/test/widgets/text_test.dart +++ b/packages/flutter/test/widgets/text_test.dart @@ -506,6 +506,13 @@ void main() { ); // The expected visual order of the text is: // hello world RIS OD you OD WOH YOB good bye + // There are five unique text areas, they are, in visual order but + // showing the logical text: + // [hello world][SIR][HOW DO you DO][BOY][good bye] + // The direction of each varies based on the first bit of that area. + // The presence of the bidi formatting characters in the text is a + // bit dubious, but that's what we do currently, and it's not really + // clear what the perfect behavior would be... final TestSemantics expectedSemantics = TestSemantics.root( children: [ TestSemantics.rootChild( @@ -513,33 +520,31 @@ void main() { children: [ TestSemantics( rect: const Rect.fromLTRB(-4.0, -4.0, 480.0, 18.0), - label: 'hello world ', - textDirection: TextDirection.ltr, // text direction is declared as LTR. + label: 'hello world${Unicode.RLE}${Unicode.RLO} ', + textDirection: TextDirection.ltr, + ), + TestSemantics( + rect: const Rect.fromLTRB(416.0, -4.0, 466.0, 18.0), + label: 'BOY', + textDirection: TextDirection.rtl, + actions: [SemanticsAction.longPress], + ), + TestSemantics( + rect: const Rect.fromLTRB(192.0, -4.0, 424.0, 18.0), + label: ' HOW DO${Unicode.PDF} you ${Unicode.RLO} DO ', + textDirection: TextDirection.rtl, ), TestSemantics( rect: const Rect.fromLTRB(150.0, -4.0, 200.0, 18.0), - label: 'RIS', - textDirection: TextDirection.rtl, // in the last string we switched to RTL using RLE. + label: 'SIR', + textDirection: TextDirection.rtl, actions: [SemanticsAction.tap], flags: [SemanticsFlag.isLink], ), - TestSemantics( - rect: const Rect.fromLTRB(192.0, -4.0, 424.0, 18.0), - label: ' OD you OD WOH ', // Still RTL. - textDirection: TextDirection.rtl, - ), - TestSemantics( - rect: const Rect.fromLTRB(416.0, -4.0, 466.0, 18.0), - label: 'YOB', - textDirection: TextDirection.rtl, // Still RTL. - actions: [ - SemanticsAction.longPress, - ], - ), TestSemantics( rect: const Rect.fromLTRB(472.0, -4.0, 606.0, 18.0), - label: ' good bye', - textDirection: TextDirection.rtl, // Begin as RTL but pop to LTR. + label: '${Unicode.PDF}${Unicode.PDF} good bye', + textDirection: TextDirection.rtl, ), ], ), @@ -554,7 +559,7 @@ void main() { ), ); semantics.dispose(); - }, skip: true); // https://github.com/flutter/flutter/issues/20891 + }, skip: isBrowser); // https://github.com/flutter/flutter/issues/62945 testWidgets('TapGesture recognizers contribute link semantics', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); @@ -862,7 +867,7 @@ void main() { final Size textSizeLongestLine = tester.getSize(find.byType(Text)); expect(textSizeLongestLine.width, equals(630.0)); expect(textSizeLongestLine.height, equals(fontHeight * 2)); - }, skip: isBrowser); // https://github.com/flutter/flutter/issues/44020 + }, skip: isBrowser); // https://github.com/flutter/flutter/issues/44020 testWidgets('textWidthBasis with textAlign still obeys parent alignment', (WidgetTester tester) async { await tester.pumpWidget( @@ -912,7 +917,7 @@ void main() { expect(tester.getSize(find.text('RIGHT ALIGNED, PARENT')).width, lessThan(width)); expect(tester.getSize(find.text('LEFT ALIGNED, LONGEST LINE')).width, lessThan(width)); expect(tester.getSize(find.text('RIGHT ALIGNED, LONGEST LINE')).width, equals(width)); - }, skip: isBrowser); // https://github.com/flutter/flutter/issues/44020 + }, skip: isBrowser); // https://github.com/flutter/flutter/issues/44020 testWidgets( 'textWidthBasis.longestLine confines the width of the paragraph ' @@ -944,7 +949,7 @@ void main() { throw 'paragraph.width (${paragraph.width}) >= 400'; return true; })); - }, skip: isBrowser); // https://github.com/flutter/flutter/issues/44020 + }, skip: isBrowser); // 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()); diff --git a/packages/flutter_test/lib/src/platform.dart b/packages/flutter_test/lib/src/platform.dart index c7f25d92d1..7731c9e22b 100644 --- a/packages/flutter_test/lib/src/platform.dart +++ b/packages/flutter_test/lib/src/platform.dart @@ -4,16 +4,23 @@ import 'dart:io'; -// Whether the current dart code is running in an environment that was compiled -// to JavaScript. -const bool _kIsCompiledToJavaScript = identical(0, 0.0); +/// Whether the test is running in a web browser compiled to JavaScript. +/// +/// See also: +/// +/// * [kIsWeb], the equivalent constant in the `foundation` library. +const bool isBrowser = identical(0, 0.0); /// Whether the test is running on the Windows operating system. /// -/// This does not include test compiled to JavaScript running in a browser on +/// This does not include tests compiled to JavaScript running in a browser on /// the Windows operating system. +/// +/// See also: +/// +/// * [isBrowser], which reports true for tests running in browsers. bool get isWindows { - if (_kIsCompiledToJavaScript) { + if (isBrowser) { return false; } return Platform.isWindows; @@ -21,10 +28,14 @@ bool get isWindows { /// Whether the test is running on the macOS operating system. /// -/// This does not include test compiled to JavaScript running in a browser on +/// This does not include tests compiled to JavaScript running in a browser on /// the macOS operating system. +/// +/// See also: +/// +/// * [isBrowser], which reports true for tests running in browsers. bool get isMacOS { - if (_kIsCompiledToJavaScript) { + if (isBrowser) { return false; } return Platform.isMacOS; @@ -32,16 +43,15 @@ bool get isMacOS { /// Whether the test is running on the Linux operating system. /// -/// This does not include test compiled to JavaScript running in a browser on +/// This does not include tests compiled to JavaScript running in a browser on /// the Linux operating system. +/// +/// See also: +/// +/// * [isBrowser], which reports true for tests running in browsers. bool get isLinux { - if (_kIsCompiledToJavaScript) { + if (isBrowser) { return false; } return Platform.isLinux; } - -/// Whether the test is running in a web browser compiled to JavaScript. -bool get isBrowser { - return _kIsCompiledToJavaScript; -}