forked from glorylab/wave
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwave_test.dart
More file actions
58 lines (55 loc) · 1.57 KB
/
Copy pathwave_test.dart
File metadata and controls
58 lines (55 loc) · 1.57 KB
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
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:wave/wave.dart';
void main() {
group('Wave widget', () {
testWidgets('isLoop true (default)', (WidgetTester tester) async {
await tester.pumpWidget(getWaveWidget());
try {
/*
If isLoop is true,
animations will not stopped and therefore the pumpAndSettle() will throw error.
*/
await tester.pumpAndSettle();
} catch (e) {
expect(e, isFlutterError);
}
});
testWidgets('isLoop false', (WidgetTester tester) async {
int duration = 5000;
await tester.pumpWidget(getWaveWidget(duration: duration, isLoop: false));
int count = await tester.pumpAndSettle(const Duration(milliseconds: 1));
// Animations should be stopped after the specified duration.
expect(count, duration);
});
});
}
Widget getWaveWidget({int? duration, bool isLoop = true}) {
return MaterialApp(
home: Container(
child: WaveWidget(
backgroundColor: Colors.white,
config: CustomConfig(
blur: MaskFilter.blur(
BlurStyle.solid,
0.0,
),
colors: [
Colors.white54,
Colors.white30,
Colors.white,
],
durations: [21000, 18000, 5000],
heightPercentages: [0.26, 0.28, 0.31],
),
duration: duration,
isLoop: isLoop,
size: Size(
double.infinity,
double.infinity,
),
waveAmplitude: 5.0,
),
),
);
}