Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
amantoux committed May 6, 2024
1 parent 30daa18 commit d2fa537
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions packages/fleather/test/widgets/editor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,48 @@ void main() {
tester.view.viewInsets = FakeViewPadding.zero;
});

testWidgets('Keep selectiontoolbar with editor bounds', (tester) async {
final delta = Delta();
for (int i = 0; i < 30; i++) {
delta.insert('Test\n');
}
final scrollController = ScrollController();
final controller =
FleatherController(document: ParchmentDocument.fromDelta(delta));
final editor = MaterialApp(
home: Scaffold(
body: Column(
children: [
const SizedBox(width: 300, height: 150),
Expanded(
child: FleatherEditor(
controller: controller,
scrollController: scrollController,
),
),
],
),
),
);
await tester.pumpWidget(editor);
// Double tap to show toolbar
await tester.tapAt(
tester.getTopLeft(find.byType(RawEditor)) + const Offset(1, 1));
await tester.tapAt(
tester.getTopLeft(find.byType(RawEditor)) + const Offset(1, 1));
await tester.pumpAndSettle();
expect(find.byType(TextSelectionToolbar), findsOneWidget);
// Scroll extent is > 500, toolbar position should be around -400 if not
// capped
scrollController.jumpTo(scrollController.position.maxScrollExtent);
await tester.pumpAndSettle();
final renderToolbarTextButton =
tester.renderObject(find.byType(TextSelectionToolbarTextButton).first)
as RenderBox;
final toolbarTop = renderToolbarTextButton.localToGlobal(Offset.zero);
expect(toolbarTop.dy, greaterThan(90));
});

testWidgets('allows merging attribute theme data', (tester) async {
var delta = Delta()
..insert(
Expand Down

0 comments on commit d2fa537

Please sign in to comment.