-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
162 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter_animate/flutter_animate.dart'; | ||
|
||
import '../tester_extensions.dart'; | ||
|
||
void main() { | ||
testWidgets('BoxShadowEffect: core', (tester) async { | ||
BoxShadow? begin; | ||
BoxShadow end = const BoxShadow(blurRadius: 32, color: Colors.red); | ||
BorderRadius borderRadius = BorderRadius.circular(8); | ||
|
||
// uses a Placeholder instead of FlutterLogo because the latter apparently has its own DecoratedBox | ||
final animation = const Placeholder().animate().boxShadow( | ||
duration: 1000.ms, | ||
borderRadius: borderRadius, | ||
begin: begin, | ||
end: end, | ||
); | ||
|
||
// Check middle: | ||
await tester.pumpAnimation(animation, initialDelay: 500.ms); | ||
var expected = BoxShadow.lerp(begin, end, 0.5); | ||
tester.expectWidgetWithBool<DecoratedBox>( | ||
(o) => (o.decoration as BoxDecoration).boxShadow?.first == expected, | ||
true, | ||
'decoration.boxShadow @ 500ms', | ||
); | ||
tester.expectWidgetWithBool<DecoratedBox>( | ||
(o) => (o.decoration as BoxDecoration).borderRadius == borderRadius, | ||
true, | ||
'decoration.borderRadius @ 500ms', | ||
); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter_animate/flutter_animate.dart'; | ||
|
||
import '../tester_extensions.dart'; | ||
|
||
void main() { | ||
testWidgets('ColorEffect: core', (tester) async { | ||
BlendMode blend = BlendMode.colorDodge; | ||
Color begin = Colors.blue, end = Colors.red; | ||
|
||
final animation = const FlutterLogo().animate().color( | ||
duration: 1000.ms, | ||
blendMode: blend, | ||
begin: begin, | ||
end: end, | ||
); | ||
|
||
// Check begin: | ||
await tester.pumpAnimation(animation); | ||
tester.expectWidgetWithBool<ColorFiltered>( | ||
(o) => o.colorFilter == ColorFilter.mode(begin, blend), | ||
true, | ||
'colorFilter @ 0ms', | ||
); | ||
|
||
// Check end: | ||
await tester.pump(1000.ms); | ||
tester.expectWidgetWithBool<ColorFiltered>( | ||
(o) => o.colorFilter == ColorFilter.mode(end, blend), | ||
true, | ||
'colorFilter @ 1000ms', | ||
); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter_animate/flutter_animate.dart'; | ||
|
||
import '../tester_extensions.dart'; | ||
|
||
void main() { | ||
testWidgets('CrossfadeEffect: core', (tester) async { | ||
Widget beginChild = const FlutterLogo(), endChild = const Placeholder(); | ||
final anim = beginChild.animate().crossfade( | ||
duration: 1000.ms, | ||
delay: 0.ms, | ||
builder: (_) => endChild, | ||
); | ||
|
||
// At begin, expect beginChild is 100% opaque, endChild is 0% | ||
await tester.pumpAnimation(anim); | ||
tester.expectWidgetWithDouble<FadeTransition>( | ||
(o) => o.opacity.value, | ||
1, | ||
'beginChild opacity @ 0ms', | ||
findFirst: true, | ||
); | ||
tester.expectWidgetWithDouble<FadeTransition>( | ||
(o) => o.opacity.value, | ||
0, | ||
'endChild opacity @ 0ms', | ||
findFirst: false, | ||
); | ||
|
||
// At middle, expect beginChild is 50% opaque, endChild is 50% | ||
await tester.pump(500.ms); | ||
tester.expectWidgetWithDouble<FadeTransition>( | ||
(o) => o.opacity.value, | ||
0.5, | ||
'beginChild opacity @ 500ms', | ||
findFirst: true, | ||
); | ||
tester.expectWidgetWithDouble<FadeTransition>( | ||
(o) => o.opacity.value, | ||
0.5, | ||
'endChild opacity @ 500ms', | ||
findFirst: false, | ||
); | ||
|
||
// At end, expect beginChild is 0% opaque, endChild is 100% | ||
await tester.pump(500.ms); | ||
tester.expectWidgetWithDouble<FadeTransition>( | ||
(o) => o.opacity.value, | ||
0, | ||
'beginChild opacity @ 1000ms', | ||
findFirst: true, | ||
); | ||
tester.expectWidgetWithDouble<FadeTransition>( | ||
(o) => o.opacity.value, | ||
1, | ||
'endChild opacity @ 1000ms', | ||
findFirst: false, | ||
); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter_animate/flutter_animate.dart'; | ||
|
||
import '../tester_extensions.dart'; | ||
|
||
void main() { | ||
testWidgets('ElevationEffect: core', (tester) async { | ||
double begin = 4, end = 32; | ||
|
||
final animation = const FlutterLogo().animate().elevation( | ||
duration: 1000.ms, | ||
begin: begin, | ||
end: end, | ||
); | ||
|
||
// Check begin: | ||
await tester.pumpAnimation(animation); | ||
tester.expectWidgetWithBool<PhysicalModel>( | ||
(o) => o.elevation == begin, true, 'elevation @ 0ms'); | ||
|
||
// Check end: | ||
await tester.pump(1000.ms); | ||
tester.expectWidgetWithBool<PhysicalModel>( | ||
(o) => o.elevation == end, true, 'elevation @ 1000ms'); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
void main() { | ||
// TODO: expose FlipEffect.getTransformMatrix (name TBD) and use in test | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters