Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replay not saved during animations #2518

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions flutter/lib/src/replay/replay_recorder.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:developer';

import 'package:flutter/scheduler.dart';
import 'package:meta/meta.dart';

import '../screenshot/recorder.dart';
Expand All @@ -18,9 +17,7 @@ class ReplayScreenshotRecorder extends ScreenshotRecorder {
@override
@protected
Future<void> executeTask(void Function() task, Flow flow) {
// Schedule the task to run between frames, when the app is idle.
return options.bindingUtils.instance
?.scheduleTask<void>(task, Priority.idle, flow: flow) ??
Future.sync(task);
// Future() schedules the task to be executed asynchronously with TImer.run.
return Future(task);
}
}
7 changes: 5 additions & 2 deletions flutter/lib/src/screenshot/recorder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,11 @@ class ScreenshotRecorder {
}

@protected
Future<void> executeTask(void Function() task, Flow flow) =>
Future.sync(task);
Future<void> executeTask(void Function() task, Flow flow) {
// Future.sync() starts executing the function synchronously, until the
// first await, i.e. it's the same as if the code was executed directly.
return Future.sync(task);
}

List<WidgetFilterItem>? _obscureSync(_Capture<dynamic> capture) {
if (_maskingConfig != null) {
Expand Down
15 changes: 5 additions & 10 deletions flutter/test/screenshot/recorder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void main() async {
});

expect(
fixture.capture(),
fixture.capture,
throwsA(predicate(
(Exception e) => e.toString().contains('testing masking error'))));
});
Expand Down Expand Up @@ -130,23 +130,18 @@ class _Fixture {
ScreenshotRecorderConfig(width: width, height: height), options);
late final options = defaultTestOptions()
..bindingUtils = TestBindingWrapper();
final WidgetTester _tester;
final double? width;
final double? height;

_Fixture(this._tester, {this.width, this.height});
_Fixture({this.width, this.height});

static Future<_Fixture> create(WidgetTester tester,
{double? width, double? height}) async {
final fixture = _Fixture(tester, width: width, height: height);
final fixture = _Fixture(width: width, height: height);
await pumpTestElement(tester);
return fixture;
}

Future<String?> capture() async {
final future = sut.capture<String?>(
(Image image) => Future.value("${image.width}x${image.height}"));
await _tester.idle();
return future;
}
Future<String?> capture() => sut.capture<String?>(
(Image image) => Future.value("${image.width}x${image.height}"));
}
Loading