Skip to content

Commit

Permalink
Fix last tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amantoux committed Jun 20, 2024
1 parent 5da9fe5 commit d0d9a89
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions packages/fleather/test/widgets/editor_test.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:fleather/fleather.dart';
import 'package:fleather/src/services/spell_check_suggestions_toolbar.dart';
import 'package:fleather/src/widgets/keyboard_listener.dart';
import 'package:fleather/src/widgets/single_child_scroll_view.dart';
import 'package:fleather/src/widgets/text_selection.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
Expand Down Expand Up @@ -42,16 +41,16 @@ void main() {
final endpoint =
renderEditor.getEndpointsForSelection(renderEditor.selection);
expect(
tester
.getRect(find.byType(FleatherEditor))
.contains(renderEditor.localToGlobal(endpoint[0].point)),
tester.getRect(find.byType(FleatherEditor)).contains(
renderEditor.localToGlobal(endpoint[0].point) +
renderEditor.paintOffset),
isTrue);
tester.view.viewInsets = const FakeViewPadding(bottom: 200);
await tester.pump();
expect(
tester
.getRect(find.byType(FleatherEditor))
.contains(renderEditor.localToGlobal(endpoint[0].point)),
tester.getRect(find.byType(FleatherEditor)).contains(
renderEditor.localToGlobal(endpoint[0].point) +
renderEditor.paintOffset),
isTrue);
tester.view.viewInsets = FakeViewPadding.zero;
});
Expand All @@ -65,21 +64,22 @@ void main() {
..insert('\n');
final controller =
FleatherController(document: ParchmentDocument.fromDelta(delta));
final embedHeight =
(tester.view.physicalSize / tester.view.devicePixelRatio).height *
1.5;
final editor = MaterialApp(
home: Scaffold(
body: Column(
children: [
Expanded(
child: FleatherEditor(
controller: controller,
embedBuilder: (context, node) => SizedBox(
width: 100,
height:
(tester.view.physicalSize / tester.view.devicePixelRatio)
.height *
1.5,
child: FleatherEditor(
controller: controller,
embedBuilder: (context, node) => SizedBox(
width: 100,
height: embedHeight,
),
),
)),
),
],
),
),
Expand All @@ -89,18 +89,16 @@ void main() {
tester.getBottomRight(find.byType(RawEditor)) - const Offset(1, 1));
await tester.pumpAndSettle();

final scrollController = tester
.widget<FleatherSingleChildScrollView>(
find.byType(FleatherSingleChildScrollView))
.controller;
double scrollOffset = scrollController.offset;
final renderEditor =
tester.state<EditorState>(find.byType(RawEditor)).renderEditor;
var scrollOffset = -renderEditor.paintOffset.dy;
tester.view.viewInsets = const FakeViewPadding(bottom: 20);
await tester.pump();
expect(scrollController.offset > scrollOffset, isTrue);
scrollOffset = scrollController.offset;
expect(-renderEditor.paintOffset.dy > scrollOffset, isTrue);
scrollOffset = -renderEditor.paintOffset.dy;
tester.view.viewInsets = const FakeViewPadding(bottom: 40);
await tester.pump();
expect(scrollController.offset > scrollOffset, isTrue);
expect(-renderEditor.paintOffset.dy > scrollOffset, isTrue);
tester.view.viewInsets = FakeViewPadding.zero;
});

Expand Down

0 comments on commit d0d9a89

Please sign in to comment.