flame_test library

Classes

DebugTextRenderer
Text formatter suitable for use in golden tests. This formatter renders words as rectangles.
FlameTester<T extends FlameGame<World>>
Customize this class with your specific FlameGame type T and a custom provider () -> T, plus some additional configurations including a game widget builder createGameWidget, a custom pumpWidget function and a custom gameSize.
GameTester<T extends Game>
Customize this class with your specific Game type T and a custom provider () -> T, plus some additional configurations including a game widget builder createGameWidget, a custom pumpWidget function and a custom gameSize.

Extensions

FlameFinds on CommonFinders
FlameGameExtension on Component

Properties

flameGame FlameTester<FlameGame<World>>
Default instance of Flame Tester to be used when you don't care about changing any configuration.
final

Functions

closeToAabb(Aabb2 expected, [double epsilon = 1e-15]) Matcher
Returns a matcher which checks if the argument is an axis-aligned bounding box sufficiently close (within distance epsilon) to expected. Example of usage:
closeToVector(Vector2 vector, [double epsilon = 1e-15]) Matcher
Returns a matcher which checks if the argument is a vector within distance epsilon of vector. For example:
createDragStartEvents({required Game game, int? pointerId, PointerDeviceKind? kind, Offset? globalPosition, Offset? localPosition}) → DragStartEvent
createDragUpdateEvents({required Game game, int? pointerId, PointerDeviceKind? kind, Offset? globalPosition, Offset? localPosition}) → DragUpdateEvent
createMouseMoveEvent({required Game game, int? pointerId, Vector2? position, Vector2? delta, Duration? timestamp}) → PointerMoveEvent
createTapDownEvents({required Game game, int? pointerId, PointerDeviceKind? kind, Offset? globalPosition, Offset? localPosition}) → TapDownEvent
createTapUpDetails({Offset? globalPosition, Offset? localPosition, PointerDeviceKind kind = PointerDeviceKind.mouse}) TapUpDetails
createTapUpEvents({required Game game, int? pointerId, PointerDeviceKind? kind, Offset? globalPosition, Offset? localPosition}) → TapUpEvent
expectDouble(double d1, double d2, {double epsilon = 0.01, String? reason}) → void
failsAssert([String? message]) Matcher
Matcher that can be used in a test that expects an assertion error.
generateImage() Future<Image>
initializeFlameGame() Future<FlameGame<World>>
initializeGame<T extends FlameGame<World>>(CreateFunction<T> create) Future<T>
testGolden(String testName, PrepareGameFunction testBody, {required String goldenFile, Vector2? size, FlameGame<World>? game, bool skip = false}) → void
Test that a game renders correctly.
testRandom(String name, void body(Random random), {int? seed, String? testOn, Timeout? timeout, dynamic skip, dynamic tags, Map<String, dynamic>? onPlatform, int? retry, int repeatCount = 1}) → void
This function is equivalent to test(name, body), except that it is better suited for randomized testing: it will create a Random generator and pass it to the test body, but also record the seed that was used for creating the random generator. Thus, if a test fails for a specific rare seed, it would be easy to reproduce this failure.
testWidgetsRandom(String description, TestWidgetsCallback callback, {int? seed, bool? skip, Timeout? timeout, bool semanticsEnabled = true, dynamic tags}) → void
This function is equivalent to testWidgets(name, body), except that it is better suited for randomized testing: it will create a Random generator and pass it to the test body, but also record the seed that was used for creating the random generator. Thus, if a test fails for a specific rare seed, it would be easy to reproduce this failure.
testWithFlameGame(String testName, AsyncGameFunction<FlameGame<World>> testBody, {Timeout? timeout, dynamic tags, dynamic skip, Map<String, dynamic>? onPlatform, int? retry}) Future<void>
Utility function for writing tests that require a FlameGame instance.
testWithGame<T extends FlameGame<World>>(String testName, CreateFunction<T> create, AsyncGameFunction<T> testBody, {Timeout? timeout, dynamic tags, dynamic skip, Map<String, dynamic>? onPlatform, int? retry}) Future<void>
Utility function for writing tests that require a custom game instance.

Typedefs

AsyncGameFunction<T extends Game> = Future<void> Function(T game)
AsyncVoidFunction = Future<void> Function()
CreateFunction<T> = T Function()
GameCreateFunction<T extends Game> = T Function()
GameWidgetCreateFunction<T extends Game> = GameWidget<T> Function(T game)
PumpWidgetFunction<T extends Game> = Future<void> Function(GameWidget<T>, WidgetTester tester)
TestWidgetsCallback = Future<void> Function(Random random, WidgetTester widgetTester)
VerifyFunction<T extends Game> = dynamic Function(T)
WidgetSetupFunction<T extends Game> = Future<void> Function(T, WidgetTester)
WidgetVerifyFunction<T extends Game> = Future<void> Function(T, WidgetTester)