Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions test/emoji_picker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,58 @@ void main() {
// Check if the category been passed to the 'onEmojiSelected' callback
expect(_categorySelected, equals(Category.SMILEYS));
});

testWidgets('Clips overflow when constrained tighter than natural height', (
WidgetTester tester,
) async {
final _controller = TextEditingController();

// Constrain the picker far below the natural sum of the category bar
// and bottom action bar to force the inner Column to overflow (#256).
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(
child: SizedBox(
width: 300,
height: 30,
child: EmojiPicker(
textEditingController: _controller,
config: const Config(
height: 30,
categoryViewConfig: CategoryViewConfig(
recentTabBehavior: RecentTabBehavior.NONE,
),
),
),
),
),
),
),
);
await tester.pump();

// A RenderFlex overflow is reported in debug mode; drain it so the test
// can assert the overflow is clipped rather than left painting stripes.
final exception = tester.takeException();
expect(
exception == null || exception.toString().contains('overflowed'),
isTrue,
);

// The inner view Column is wrapped in a ClipRect that clips the
// overflow (#256). Match that specific ClipRect (the one whose direct
// child is the Column) rather than the incidental ClipRects the grid
// and scroll views introduce.
expect(
find.descendant(
of: find.byType(EmojiContainer),
matching: find.byWidgetPredicate(
(widget) => widget is ClipRect && widget.child is Column,
),
),
findsOneWidget,
);
});
});
}
Loading