Skip to content

Commit

Permalink
test: added tests for undo and redo in load sketch (#69)
Browse files Browse the repository at this point in the history
* test: added tests for undo and redo in load sketch

* removed import
  • Loading branch information
timcreatedit authored Sep 22, 2024
1 parent 54bec0b commit 6f9f778
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 86 deletions.
136 changes: 68 additions & 68 deletions coverage/lcov.info
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ DA:102,0
DA:103,3
DA:109,2
DA:114,2
DA:131,0
DA:131,3
DA:135,1
DA:136,1
DA:144,0
DA:150,0
DA:151,0
DA:164,0
DA:168,0
DA:172,0
DA:174,0
DA:144,1
DA:150,2
DA:151,1
DA:164,1
DA:168,3
DA:172,1
DA:174,1
DA:179,0
DA:180,0
DA:181,0
Expand Down Expand Up @@ -101,41 +101,41 @@ DA:283,0
DA:285,0
DA:286,0
DA:288,0
DA:293,0
DA:295,0
DA:296,0
DA:299,0
DA:293,1
DA:295,4
DA:296,1
DA:299,3
DA:300,0
DA:301,0
DA:303,0
DA:304,0
DA:305,0
DA:308,0
DA:310,0
DA:311,0
DA:312,0
DA:313,0
DA:314,0
DA:315,0
DA:316,0
DA:320,0
DA:321,0
DA:326,0
DA:328,0
DA:329,0
DA:310,2
DA:311,3
DA:312,1
DA:313,1
DA:314,2
DA:315,2
DA:316,5
DA:320,3
DA:321,4
DA:326,1
DA:328,4
DA:329,2
DA:330,0
DA:335,0
DA:336,0
DA:337,0
DA:335,2
DA:336,5
DA:337,1
DA:339,0
DA:340,0
DA:341,0
DA:347,0
DA:349,0
DA:351,0
DA:352,0
DA:353,0
DA:356,0
DA:347,1
DA:349,4
DA:351,2
DA:352,2
DA:353,6
DA:356,7
DA:358,0
DA:359,0
DA:362,0
Expand All @@ -151,18 +151,18 @@ DA:386,0
DA:388,0
DA:389,0
DA:392,0
DA:396,0
DA:397,0
DA:398,0
DA:399,0
DA:400,0
DA:402,0
DA:403,0
DA:404,0
DA:405,0
DA:406,0
DA:407,0
DA:408,0
DA:396,1
DA:397,2
DA:398,2
DA:399,1
DA:400,2
DA:402,6
DA:403,3
DA:404,2
DA:405,2
DA:406,1
DA:407,1
DA:408,1
DA:414,0
DA:415,0
DA:416,0
Expand All @@ -172,24 +172,24 @@ DA:419,0
DA:420,0
DA:421,0
DA:424,0
DA:429,0
DA:430,0
DA:429,1
DA:430,3
DA:432,0
DA:433,0
DA:434,0
DA:435,0
DA:436,0
DA:437,0
DA:441,0
DA:442,0
DA:443,0
DA:445,0
DA:446,0
DA:447,0
DA:448,0
DA:450,0
DA:434,1
DA:435,2
DA:436,2
DA:437,2
DA:441,1
DA:442,2
DA:443,2
DA:445,3
DA:446,1
DA:447,2
DA:448,2
DA:450,1
LF:154
LH:17
LH:76
end_of_record
SF:lib/src/view/scribble.dart
DA:19,1
Expand Down Expand Up @@ -242,16 +242,16 @@ SF:lib/src/view/state/scribble.state.dart
DA:108,0
DA:109,0
DA:110,2
DA:114,4
DA:114,8
DA:118,0
DA:119,0
DA:120,0
DA:121,0
DA:122,0
DA:127,1
DA:128,1
DA:129,1
DA:130,1
DA:127,2
DA:128,2
DA:129,2
DA:130,2
DA:131,0
DA:133,0
DA:138,0
Expand Down Expand Up @@ -335,7 +335,7 @@ LF:15
LH:15
end_of_record
SF:lib/src/domain/model/point/point.dart
DA:18,3
DA:18,4
DA:21,2
LF:2
LH:2
Expand Down Expand Up @@ -376,9 +376,9 @@ LF:12
LH:7
end_of_record
SF:lib/src/view/painting/point_to_offset_x.dart
DA:8,0
DA:8,4
LF:1
LH:0
LH:1
end_of_record
SF:lib/src/view/painting/sketch_line_path_mixin.dart
DA:20,0
Expand Down
36 changes: 18 additions & 18 deletions packages/value_notifier_tools/coverage/lcov.info
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ DA:28,2
LF:1
LH:1
end_of_record
SF:lib/src/where_value_notifier/where_value_notifier_from_parent.dart
DA:13,1
DA:17,2
DA:18,3
DA:27,1
DA:29,2
DA:32,1
DA:33,3
DA:36,1
DA:38,2
DA:41,1
DA:43,3
DA:44,1
DA:52,1
DA:53,1
LF:14
LH:14
end_of_record
SF:lib/src/history_value_notifier/history_value_notifier.dart
DA:17,1
LF:1
Expand Down Expand Up @@ -84,21 +102,3 @@ DA:135,1
LF:45
LH:45
end_of_record
SF:lib/src/where_value_notifier/where_value_notifier_from_parent.dart
DA:13,1
DA:17,2
DA:18,3
DA:27,1
DA:29,2
DA:32,1
DA:33,3
DA:36,1
DA:38,2
DA:41,1
DA:43,3
DA:44,1
DA:52,1
DA:53,1
LF:14
LH:14
end_of_record
47 changes: 47 additions & 0 deletions test/src/view/notifier/scribble_notifier_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:scribble/scribble.dart';
Expand Down Expand Up @@ -56,6 +57,52 @@ void main() {
});
});

group('setSketch', () {
test('is undoable by default if nothing happened before', () async {
expect(sut.canUndo, false);
expect(sut.canRedo, false);
sut.setSketch(sketch: emptySketch);
expect(sut.canUndo, true);
expect(sut.canRedo, false);
sut.undo();
expect(sut.currentSketch, sketch);
});

test('is undoable by default if something happened before', () async {
sut
..onPointerDown(const PointerDownEvent())
..onPointerUpdate(const PointerMoveEvent(position: Offset(100, 100)))
..onPointerUp(const PointerUpEvent(position: Offset(100, 100)));

final newSketch = sut.currentSketch;
expect(sut.canUndo, true);

sut.setSketch(sketch: emptySketch);
expect(sut.canUndo, true);
expect(sut.canRedo, false);
sut.undo();
expect(sut.currentSketch, newSketch);
});

test('is not undoable if set so', () async {
expect(sut.canUndo, false);
expect(sut.canRedo, false);
sut.setSketch(sketch: emptySketch, addToUndoHistory: false);
expect(sut.canUndo, false);
expect(sut.canRedo, false);
sut.undo();
expect(sut.currentSketch, emptySketch);
});

test('is not undoable if it changed nothing', () async {
expect(sut.canUndo, false);
expect(sut.canRedo, false);
sut.setSketch(sketch: sketch);
expect(sut.canUndo, false);
expect(sut.canRedo, false);
});
});

group("simplify", () {
test('calls simplifier method', () async {
sut.setSimplificationTolerance(2);
Expand Down

0 comments on commit 6f9f778

Please sign in to comment.