|
@@ -1,107 +0,0 @@
|
1
|
|
-// Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file
|
2
|
|
-// for details. All rights reserved. Use of this source code is governed by a
|
3
|
|
-// BSD-style license that can be found in the LICENSE file.
|
4
|
|
-
|
5
|
|
-import 'package:flutter/material.dart';
|
6
|
|
-import 'package:flutter_test/flutter_test.dart';
|
7
|
|
-import 'package:zefyr/src/widgets/editable_box.dart';
|
8
|
|
-import 'package:zefyr/src/widgets/render_context.dart';
|
9
|
|
-import 'package:zefyr/zefyr.dart';
|
10
|
|
-
|
11
|
|
-void main() {
|
12
|
|
- group('ZefyrEditableTextScope', () {
|
13
|
|
- setUp(() {
|
14
|
|
- WidgetsFlutterBinding.ensureInitialized();
|
15
|
|
- });
|
16
|
|
-//
|
17
|
|
-// test('updateShouldNotify for rendering context changes', () {
|
18
|
|
-// var context = new ZefyrRenderContext();
|
19
|
|
-// var paragraph1 = createParagraph(context);
|
20
|
|
-// var paragraph2 = createParagraph(context);
|
21
|
|
-// context.addBox(paragraph1);
|
22
|
|
-// context.markDirty(paragraph1, false);
|
23
|
|
-// var widget1 = createScope(renderingContext: context);
|
24
|
|
-// var widget2 = createScope(renderingContext: context);
|
25
|
|
-//
|
26
|
|
-// expect(widget2.updateShouldNotify(widget1), isFalse);
|
27
|
|
-// context.addBox(paragraph2);
|
28
|
|
-// context.markDirty(paragraph2, false);
|
29
|
|
-// widget2 = createScope(renderingContext: context);
|
30
|
|
-// expect(widget2.updateShouldNotify(widget1), isTrue);
|
31
|
|
-// });
|
32
|
|
-//
|
33
|
|
-// test('updateShouldNotify for selection changes', () {
|
34
|
|
-// var context = new ZefyrRenderContext();
|
35
|
|
-// var selection = new TextSelection.collapsed(offset: 0);
|
36
|
|
-// var widget1 =
|
37
|
|
-// createScope(renderingContext: context, selection: selection);
|
38
|
|
-// var widget2 =
|
39
|
|
-// createScope(renderingContext: context, selection: selection);
|
40
|
|
-//
|
41
|
|
-// expect(widget2.updateShouldNotify(widget1), isFalse);
|
42
|
|
-// selection = new TextSelection.collapsed(offset: 1);
|
43
|
|
-// widget2 = createScope(renderingContext: context, selection: selection);
|
44
|
|
-// expect(widget2.updateShouldNotify(widget1), isTrue);
|
45
|
|
-// });
|
46
|
|
-//
|
47
|
|
-// test('updateShouldNotify for showCursor changes', () {
|
48
|
|
-// var context = new ZefyrRenderContext();
|
49
|
|
-// var showCursor = new ValueNotifier<bool>(true);
|
50
|
|
-// var widget1 =
|
51
|
|
-// createScope(renderingContext: context, showCursor: showCursor);
|
52
|
|
-// var widget2 =
|
53
|
|
-// createScope(renderingContext: context, showCursor: showCursor);
|
54
|
|
-//
|
55
|
|
-// expect(widget2.updateShouldNotify(widget1), isFalse);
|
56
|
|
-// showCursor = new ValueNotifier<bool>(true);
|
57
|
|
-// widget2 = createScope(renderingContext: context, showCursor: showCursor);
|
58
|
|
-// expect(widget2.updateShouldNotify(widget1), isTrue);
|
59
|
|
-// });
|
60
|
|
-//
|
61
|
|
-// test('updateShouldNotify for imageDelegate changes', () {
|
62
|
|
-// var context = new ZefyrRenderContext();
|
63
|
|
-// var delegate = new ZefyrDefaultImageDelegate();
|
64
|
|
-// var widget1 =
|
65
|
|
-// createScope(renderingContext: context, imageDelegate: delegate);
|
66
|
|
-// var widget2 =
|
67
|
|
-// createScope(renderingContext: context, imageDelegate: delegate);
|
68
|
|
-//
|
69
|
|
-// expect(widget2.updateShouldNotify(widget1), isFalse);
|
70
|
|
-// delegate = new ZefyrDefaultImageDelegate();
|
71
|
|
-// widget2 = createScope(renderingContext: context, imageDelegate: delegate);
|
72
|
|
-// expect(widget2.updateShouldNotify(widget1), isTrue);
|
73
|
|
-// });
|
74
|
|
- });
|
75
|
|
-}
|
76
|
|
-
|
77
|
|
-ZefyrScope createScope({
|
78
|
|
- @required ZefyrRenderContext renderingContext,
|
79
|
|
- TextSelection selection,
|
80
|
|
- ValueNotifier<bool> showCursor,
|
81
|
|
- ZefyrImageDelegate imageDelegate,
|
82
|
|
-}) {
|
83
|
|
-// return ZefyrScope.editable(
|
84
|
|
-// renderContext: renderingContext,
|
85
|
|
-// selection: selection,
|
86
|
|
-// showCursor: showCursor,
|
87
|
|
-// imageDelegate: imageDelegate,
|
88
|
|
-// child: null,
|
89
|
|
-// );
|
90
|
|
-}
|
91
|
|
-
|
92
|
|
-RenderEditableProxyBox createParagraph(ZefyrRenderContext context) {
|
93
|
|
- final doc = new NotusDocument();
|
94
|
|
- doc.insert(0, 'This House Is A Circus');
|
95
|
|
- final link = new LayerLink();
|
96
|
|
- final showCursor = new ValueNotifier<bool>(true);
|
97
|
|
- final selection = new TextSelection.collapsed(offset: 0);
|
98
|
|
- final selectionColor = Colors.blue;
|
99
|
|
- return new RenderEditableProxyBox(
|
100
|
|
- node: doc.root.children.first as LineNode,
|
101
|
|
- layerLink: link,
|
102
|
|
- renderContext: context,
|
103
|
|
- showCursor: showCursor,
|
104
|
|
- selection: selection,
|
105
|
|
- selectionColor: selectionColor,
|
106
|
|
- );
|
107
|
|
-}
|