-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontroller_test.dart
66 lines (53 loc) · 1.52 KB
/
controller_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:simple_map/simple_map.dart';
class MockCanvas extends Mock implements Canvas {
@override
void drawCircle(Offset? c, double? radius, Paint? paint) {
super.noSuchMethod(Invocation.method(#drawCircle, [c, radius, paint]));
}
}
void main() {
final animation = AnimationController(
duration: const Duration(milliseconds: 100),
vsync: const TestVSync(),
);
final options = SimpleMapOptions();
test('test addPoint & clear', () {
final controller = SimpleMapController();
controller.addPoint(SimpleMapPoint(lat: 0, lng: 0));
expect(controller.points?.length, 1);
controller.clear();
expect(controller.points?.length, 0);
});
test('test render', () async {
final controller = SimpleMapController(
points: [
SimpleMapPoint(
lat: 0,
lng: 0,
color: Color(0xFFFFFFFF),
)
],
);
final canvas = MockCanvas();
final size = Size.square(100);
controller.configure(
options: options,
animation: animation,
);
controller.render(canvas, size);
verify(canvas.drawCircle(any, any, any)).called(2);
controller.addPoint(
SimpleMapPoint(
lat: 0,
lng: 0,
color: Color(0xFFFFFFFF),
state: SimpleMapPointState.active,
),
);
controller.render(canvas, size);
verify(canvas.drawCircle(any, any, any)).called(3);
});
}