Skip to content

Commit

Permalink
Add test for text line
Browse files Browse the repository at this point in the history
  • Loading branch information
Amir-P committed Jul 19, 2023
1 parent 486f4a7 commit a45e30e
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions packages/fleather/test/rendering/editable_text_line_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,42 @@ import 'package:flutter_test/flutter_test.dart';
import 'rendering_tools.dart';

void main() {
TestRenderingFlutterBinding.ensureInitialized();
late final CursorController cursorController;

setUpAll(() {
TestRenderingFlutterBinding.ensureInitialized();
cursorController = CursorController(
showCursor: ValueNotifier(false),
style:
const CursorStyle(color: Colors.blue, backgroundColor: Colors.blue),
tickerProvider: FakeTickerProvider());
});

group('$RenderEditableTextLine', () {
test('Body lays out with loose constraint', () {
final lineNode = LineNode();
final rootNode = RootNode();
rootNode.addFirst(lineNode);
final renderBox = RenderEditableTextLine(
node: lineNode,
padding: EdgeInsets.zero,
textDirection: TextDirection.ltr,
cursorController: cursorController,
selection: const TextSelection.collapsed(offset: 0),
selectionColor: Colors.blue,
enableInteractiveSelection: false,
hasFocus: false,
inlineCodeTheme: InlineCodeThemeData(style: const TextStyle()));
renderBox.body = RenderParagraphProxy(
textStyle: const TextStyle(),
textScaleFactor: 1,
textDirection: TextDirection.ltr,
textWidthBasis: TextWidthBasis.parent);
layout(renderBox);
expect(renderBox.body?.constraints.isTight, equals(false));
});

test('Background color', () {
final cursorController = CursorController(
showCursor: ValueNotifier(false),
style: const CursorStyle(
color: Colors.blue, backgroundColor: Colors.blue),
tickerProvider: FakeTickerProvider());
final lineNode = LineNode()
..insert(0, 'some text', ParchmentStyle.fromJson({'bg': 0xffff0000}));
final rootNode = RootNode();
Expand Down Expand Up @@ -55,11 +83,6 @@ void main() {
});

test('inline code', () {
final cursorController = CursorController(
showCursor: ValueNotifier(false),
style: const CursorStyle(
color: Colors.blue, backgroundColor: Colors.blue),
tickerProvider: FakeTickerProvider());
final lineNode = LineNode()
..insert(0, 'some text', ParchmentStyle.fromJson({'c': true}));
final rootNode = RootNode();
Expand Down

0 comments on commit a45e30e

Please sign in to comment.