From d2fa537b1ba18df57889a70bd4135c41817e9fe7 Mon Sep 17 00:00:00 2001 From: Alan Mantoux Date: Mon, 6 May 2024 19:53:21 +0200 Subject: [PATCH] Test --- .../fleather/test/widgets/editor_test.dart | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/packages/fleather/test/widgets/editor_test.dart b/packages/fleather/test/widgets/editor_test.dart index 9cd055f3..64d0b51b 100644 --- a/packages/fleather/test/widgets/editor_test.dart +++ b/packages/fleather/test/widgets/editor_test.dart @@ -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(