Skip to content

Commit

Permalink
Compatibility pass on flutter/widgets tests for JavaScript compilatio…
Browse files Browse the repository at this point in the history
…n. (8) (flutter#33377)
  • Loading branch information
jonahwilliams authored Jun 11, 2019
1 parent d9c1962 commit 9d724d4
Show file tree
Hide file tree
Showing 37 changed files with 102 additions and 92 deletions.
1 change: 1 addition & 0 deletions dev/bots/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ Future<void> _runWebTests() async {
'test/services/',
'test/painting/',
'test/scheduler/',
'test/widgets/',
'test/semantics/',
]);
}
Expand Down
7 changes: 7 additions & 0 deletions packages/flutter/lib/src/services/text_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import 'text_editing.dart';

export 'dart:ui' show TextAffinity;

// Whether we're compiled to JavaScript in a web browser.
const bool _kIsBrowser = identical(0, 0.0);

/// The type of information for which to optimize the text input control.
///
/// On Android, behavior may vary across device and keyboard provider.
Expand Down Expand Up @@ -825,6 +828,10 @@ class TextInput {

static bool _debugEnsureInputActionWorksOnPlatform(TextInputAction inputAction) {
assert(() {
if (_kIsBrowser) {
// TODO(flutterweb): what makes sense here?
return true;
}
if (Platform.isIOS) {
assert(
_iOSSupportedInputActions.contains(inputAction),
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/widgets/actions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,6 @@ void main() {

expect(description[0], equalsIgnoringHashCodes('dispatcher: ActionDispatcher#00000'));
expect(description[1], equals('actions: {[<\'bar\'>]: Closure: () => TestAction}'));
});
}, skip: isBrowser);
});
}
2 changes: 1 addition & 1 deletion packages/flutter/test/widgets/app_title_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ void main() {
await tester.pump();
expect(tester.widget<Title>(find.byType(Title)).title, 'en_US');
expect(tester.widget<Title>(find.byType(Title)).color, kTitleColor);
});
}, skip: isBrowser);

}
2 changes: 1 addition & 1 deletion packages/flutter/test/widgets/backdrop_filter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ void main() {
matchesGoldenFile('backdrop_filter_test.cull_rect.1.png'),
skip: !isLinux,
);
});
}, skip: isBrowser);
}
6 changes: 3 additions & 3 deletions packages/flutter/test/widgets/baseline_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void main() {
),
);
expect(tester.renderObject<RenderBox>(find.text('X')).size, const Size(100.0, 100.0));
});
}, skip: isBrowser);

testWidgets('Baseline - position test', (WidgetTester tester) async {
await tester.pumpWidget(
Expand All @@ -40,7 +40,7 @@ void main() {
expect(tester.renderObject<RenderBox>(find.text('X')).size, const Size(100.0, 100.0));
expect(tester.renderObject<RenderBox>(find.byType(Baseline)).size,
within<Size>(from: const Size(100.0, 200.0), distance: 0.001));
});
}, skip: isBrowser);

testWidgets('Chip caches baseline', (WidgetTester tester) async {
int calls = 0;
Expand All @@ -65,7 +65,7 @@ void main() {
tester.renderObject<RenderBaselineDetector>(find.byType(BaselineDetector)).dirty();
await tester.pump();
expect(calls, 2);
});
}, skip: isBrowser);

testWidgets('ListTile caches baseline', (WidgetTester tester) async {
int calls = 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/test/widgets/basic_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void main() {
expect(tester.hitTestOnBinding(const Offset(100.0, 300.0)), hits(renderPhysicalShape));
expect(tester.hitTestOnBinding(const Offset(100.0, 299.0)), doesNotHit(renderPhysicalShape));
expect(tester.hitTestOnBinding(const Offset(100.0, 301.0)), doesNotHit(renderPhysicalShape));
});
}, skip: isBrowser);

});

Expand Down Expand Up @@ -202,7 +202,7 @@ void main() {
tester.getTopLeft(find.byKey(key2)).dy,
closeTo(aboveBaseline1 - aboveBaseline2, .001),
);
});
}, skip: isBrowser);
});

test('UnconstrainedBox toString', () {
Expand Down
26 changes: 13 additions & 13 deletions packages/flutter/test/widgets/clip_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ void main() {
find.byType(RepaintBoundary).first,
matchesGoldenFile('clip.ClipRect.1.png'),
);
});
}, skip: isBrowser);

testWidgets('ClipRect save, overlay, and antialiasing', (WidgetTester tester) async {
await tester.pumpWidget(
Expand Down Expand Up @@ -398,7 +398,7 @@ void main() {
find.byType(RepaintBoundary).first,
matchesGoldenFile('clip.ClipRectOverlay.1.png'),
);
});
}, skip: isBrowser);

testWidgets('ClipRRect painting', (WidgetTester tester) async {
await tester.pumpWidget(
Expand Down Expand Up @@ -447,7 +447,7 @@ void main() {
find.byType(RepaintBoundary).first,
matchesGoldenFile('clip.ClipRRect.1.png'),
);
});
}, skip: isBrowser);

testWidgets('ClipOval painting', (WidgetTester tester) async {
await tester.pumpWidget(
Expand Down Expand Up @@ -490,7 +490,7 @@ void main() {
find.byType(RepaintBoundary).first,
matchesGoldenFile('clip.ClipOval.1.png'),
);
});
}, skip: isBrowser);

testWidgets('ClipPath painting', (WidgetTester tester) async {
await tester.pumpWidget(
Expand Down Expand Up @@ -538,7 +538,7 @@ void main() {
find.byType(RepaintBoundary).first,
matchesGoldenFile('clip.ClipPath.1.png'),
);
});
}, skip: isBrowser);

Center genPhysicalModel(Clip clipBehavior) {
return Center(
Expand Down Expand Up @@ -583,15 +583,15 @@ void main() {
find.byType(RepaintBoundary).first,
matchesGoldenFile('clip.PhysicalModel.antiAlias.1.png'),
);
});
}, skip: isBrowser);

testWidgets('PhysicalModel painting with Clip.hardEdge', (WidgetTester tester) async {
await tester.pumpWidget(genPhysicalModel(Clip.hardEdge));
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile('clip.PhysicalModel.hardEdge.1.png'),
);
});
}, skip: isBrowser);

// There will be bleeding edges on the rect edges, but there shouldn't be any bleeding edges on the
// round corners.
Expand All @@ -601,7 +601,7 @@ void main() {
find.byType(RepaintBoundary).first,
matchesGoldenFile('clip.PhysicalModel.antiAliasWithSaveLayer.png'),
);
});
}, skip: isBrowser);

testWidgets('Default PhysicalModel painting', (WidgetTester tester) async {
await tester.pumpWidget(
Expand Down Expand Up @@ -643,7 +643,7 @@ void main() {
find.byType(RepaintBoundary).first,
matchesGoldenFile('clip.PhysicalModel.default.1.png'),
);
});
}, skip: isBrowser);

Center genPhysicalShape(Clip clipBehavior) {
return Center(
Expand Down Expand Up @@ -692,23 +692,23 @@ void main() {
find.byType(RepaintBoundary).first,
matchesGoldenFile('clip.PhysicalShape.antiAlias.1.png'),
);
});
}, skip: isBrowser);

testWidgets('PhysicalShape painting with Clip.hardEdge', (WidgetTester tester) async {
await tester.pumpWidget(genPhysicalShape(Clip.hardEdge));
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile('clip.PhysicalShape.hardEdge.1.png'),
);
});
}, skip: isBrowser);

testWidgets('PhysicalShape painting with Clip.antiAliasWithSaveLayer', (WidgetTester tester) async {
await tester.pumpWidget(genPhysicalShape(Clip.antiAliasWithSaveLayer));
await expectLater(
find.byType(RepaintBoundary).first,
matchesGoldenFile('clip.PhysicalShape.antiAliasWithSaveLayer.png'),
);
});
}, skip: isBrowser);

testWidgets('PhysicalShape painting', (WidgetTester tester) async {
await tester.pumpWidget(
Expand Down Expand Up @@ -754,7 +754,7 @@ void main() {
find.byType(RepaintBoundary).first,
matchesGoldenFile('clip.PhysicalShape.default.1.png'),
);
});
}, skip: isBrowser);

testWidgets('ClipPath.shape', (WidgetTester tester) async {
final List<String> logs = <String>[];
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/widgets/custom_painter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ void _defineTests() {
);
expect(semantics, hasSemantics(expectedSemantics, ignoreRect: true, ignoreTransform: true));
semantics.dispose();
});
}, skip: isBrowser);

group('diffing', () {
testWidgets('complains about duplicate keys', (WidgetTester tester) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void main() {
expect(find.text('Item 1'), findsOneWidget);
expect(find.text('Item 21'), findsOneWidget);
expect(find.text('Item 31'), findsOneWidget);
});
}, skip: isBrowser);

testWidgets('Can be dragged down when not full height', (WidgetTester tester) async {
await tester.pumpWidget(_boilerplate(null));
Expand All @@ -114,7 +114,7 @@ void main() {
expect(find.text('Item 1'), findsOneWidget);
expect(find.text('Item 21'), findsNothing);
expect(find.text('Item 36'), findsNothing);
});
}, skip: isBrowser);

testWidgets('Can be dragged down when list is shorter than full height', (WidgetTester tester) async {
await tester.pumpWidget(_boilerplate(null, itemCount: 30, initialChildSize: .25));
Expand All @@ -131,7 +131,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('Item 1').hitTestable(), findsOneWidget);
expect(find.text('Item 29').hitTestable(), findsNothing);
});
}, skip: isBrowser);

testWidgets('Can be dragged up and cover its container and scroll in single motion, and then dragged back down', (WidgetTester tester) async {
int taps = 0;
Expand Down Expand Up @@ -160,7 +160,7 @@ void main() {
expect(find.text('Item 1'), findsOneWidget);
expect(find.text('Item 18'), findsOneWidget);
expect(find.text('Item 36'), findsNothing);
});
}, skip: isBrowser);

testWidgets('Can be flung up gently', (WidgetTester tester) async {
int taps = 0;
Expand All @@ -183,7 +183,7 @@ void main() {
expect(find.text('Item 21'), findsOneWidget);
expect(find.text('Item 36'), findsOneWidget);
expect(find.text('Item 70'), findsNothing);
});
}, skip: isBrowser);

testWidgets('Can be flung up', (WidgetTester tester) async {
int taps = 0;
Expand All @@ -204,7 +204,7 @@ void main() {
expect(find.text('Item 1'), findsNothing);
expect(find.text('Item 21'), findsNothing);
expect(find.text('Item 70'), findsOneWidget);
});
}, skip: isBrowser);

testWidgets('Can be flung down when not full height', (WidgetTester tester) async {
await tester.pumpWidget(_boilerplate(null));
Expand All @@ -217,7 +217,7 @@ void main() {
expect(find.text('Item 1'), findsOneWidget);
expect(find.text('Item 21'), findsNothing);
expect(find.text('Item 36'), findsNothing);
});
}, skip: isBrowser);

testWidgets('Can be flung up and then back down', (WidgetTester tester) async {
int taps = 0;
Expand Down Expand Up @@ -256,7 +256,7 @@ void main() {
expect(find.text('Item 1'), findsOneWidget);
expect(find.text('Item 21'), findsNothing);
expect(find.text('Item 70'), findsNothing);
});
}, skip: isBrowser);

debugDefaultTargetPlatformOverride = null;
});
Expand Down
3 changes: 1 addition & 2 deletions packages/flutter/test/widgets/draggable_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2085,8 +2085,7 @@ void main() {
],
), ignoreTransform: true, ignoreRect: true));
semantics.dispose();
});

}, skip: isBrowser);
}

Future<void> _testLongPressDraggableHapticFeedback({ WidgetTester tester, bool hapticFeedbackOnStart, int expectedHapticFeedbackCount }) async {
Expand Down
10 changes: 5 additions & 5 deletions packages/flutter/test/widgets/editable_text_cursor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ void main() {
await tester.pumpAndSettle();

expect(controller.selection.baseOffset, 10);
});
}, skip: isBrowser);

testWidgets('Updating the floating cursor correctly moves the cursor', (WidgetTester tester) async {
const String text = 'hello world this is fun and cool and awesome!';
Expand Down Expand Up @@ -501,7 +501,7 @@ void main() {
await tester.pumpAndSettle();
// The cursor has been set.
expect(controller.selection.baseOffset, 10);
});
}, skip: isBrowser);

// Regression test for https://github.com/flutter/flutter/pull/30475.
testWidgets('Trying to select with the floating cursor does not crash', (WidgetTester tester) async {
Expand Down Expand Up @@ -567,7 +567,7 @@ void main() {
offset: const Offset(-250, 20)));
editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.End));
await tester.pumpAndSettle();
});
}, skip: isBrowser);

testWidgets('autofocus sets cursor to the end of text', (WidgetTester tester) async {
const String text = 'hello world';
Expand Down Expand Up @@ -599,7 +599,7 @@ void main() {
expect(focusNode.hasFocus, true);
expect(controller.selection.isCollapsed, true);
expect(controller.selection.baseOffset, text.length);
});
}, skip: isBrowser);

testWidgets('Floating cursor is painted on iOS', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
Expand Down Expand Up @@ -687,7 +687,7 @@ void main() {
editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.End));
await tester.pumpAndSettle();
debugDefaultTargetPlatformOverride = null;
});
}, skip: isBrowser);

testWidgets('cursor layout iOS', (WidgetTester tester) async {
final GlobalKey<EditableTextState> editableTextKey = GlobalKey<EditableTextState>();
Expand Down
Loading

0 comments on commit 9d724d4

Please sign in to comment.