fix(#231): Exposed `frameBindingPolicy` on the test runner when running tests which can affect how frames are painted and the speed of the test run, I've removed the default value which might be responsible for #231
This commit is contained in:
parent
66919d6539
commit
b73da409b3
|
@ -1,3 +1,6 @@
|
|||
## [3.0.0-rc.15] - 28/06/2022
|
||||
- Exposed `frameBindingPolicy` on the test runner when running tests which can affect how frames are painted and the speed of the test run, I've removed the default value which might be responsible for #231
|
||||
|
||||
## [3.0.0-rc.14] - 28/06/2022
|
||||
- Fix #237 - Ensure everything works on the web
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:flutter_gherkin/flutter_gherkin.dart';
|
|||
import 'package:flutter_simple_dependency_injection/injector.dart';
|
||||
import 'package:gherkin/gherkin.dart';
|
||||
|
||||
import 'hooks/attach_screenshot_after_step_hook.dart';
|
||||
import 'hooks/reset_app_hook.dart';
|
||||
import 'steps/expect_todos_step.dart';
|
||||
import 'steps/multiline_string_with_formatted_json.dart';
|
||||
|
@ -22,7 +23,7 @@ FlutterTestConfiguration gherkinTestConfiguration = FlutterTestConfiguration(
|
|||
],
|
||||
hooks: [
|
||||
ResetAppHook(),
|
||||
// AttachScreenshotAfterStepHook(),
|
||||
AttachScreenshotAfterStepHook(),
|
||||
],
|
||||
reporters: [
|
||||
StdoutReporter(MessageLevel.error)
|
||||
|
|
|
@ -12,11 +12,13 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner {
|
|||
required StartAppFn appMainFunction,
|
||||
required Timeout scenarioExecutionTimeout,
|
||||
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
|
||||
LiveTestWidgetsFlutterBindingFramePolicy? framePolicy,
|
||||
}) : super(
|
||||
configuration: configuration,
|
||||
appMainFunction: appMainFunction,
|
||||
scenarioExecutionTimeout: scenarioExecutionTimeout,
|
||||
appLifecyclePumpHandler: appLifecyclePumpHandler,
|
||||
framePolicy: framePolicy,
|
||||
);
|
||||
|
||||
@override
|
||||
|
@ -389,11 +391,13 @@ void executeTestSuite({
|
|||
required StartAppFn appMainFunction,
|
||||
Timeout scenarioExecutionTimeout = const Timeout(Duration(minutes: 10)),
|
||||
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
|
||||
LiveTestWidgetsFlutterBindingFramePolicy? framePolicy,
|
||||
}) {
|
||||
_CustomGherkinIntegrationTestRunner(
|
||||
configuration: configuration,
|
||||
appMainFunction: appMainFunction,
|
||||
appLifecyclePumpHandler: appLifecyclePumpHandler,
|
||||
scenarioExecutionTimeout: scenarioExecutionTimeout,
|
||||
framePolicy: framePolicy,
|
||||
).run();
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ packages:
|
|||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "3.0.0-rc.13"
|
||||
version: "3.0.0-rc.14"
|
||||
flutter_simple_dependency_injection:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -64,7 +64,7 @@ Future<void> writeGherkinReports(List<dynamic> reports) async {
|
|||
File file = File(
|
||||
'${integration_test_driver.testOutputsDirectory}/'
|
||||
'$filenamePrefix'
|
||||
'v${i + 1}.json',
|
||||
'-v${i + 1}.json',
|
||||
);
|
||||
|
||||
await file.writeAsString(json.encode(reportData));
|
||||
|
|
|
@ -25,11 +25,13 @@ class WidgetTesterAppDriverAdapter
|
|||
Duration? duration = const Duration(milliseconds: 100),
|
||||
Duration? timeout = const Duration(seconds: 30),
|
||||
}) async {
|
||||
return _implicitWait(
|
||||
final result = await _implicitWait(
|
||||
duration: duration,
|
||||
timeout: timeout,
|
||||
force: true,
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> _implicitWait({
|
||||
|
@ -39,11 +41,13 @@ class WidgetTesterAppDriverAdapter
|
|||
}) async {
|
||||
if (waitImplicitlyAfterAction || force == true) {
|
||||
try {
|
||||
return await nativeDriver.pumpAndSettle(
|
||||
final result = await nativeDriver.pumpAndSettle(
|
||||
duration ?? const Duration(milliseconds: 100),
|
||||
EnginePhase.sendSemanticsUpdate,
|
||||
timeout ?? const Duration(seconds: 30),
|
||||
);
|
||||
|
||||
return result;
|
||||
} catch (_) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -68,7 +72,7 @@ class WidgetTesterAppDriverAdapter
|
|||
}
|
||||
}
|
||||
|
||||
Future<List<int>> screenshotOnAndroid() {
|
||||
Future<List<int>> screenshotOnAndroid() async {
|
||||
RenderObject? renderObject = binding.renderViewElement?.renderObject;
|
||||
if (renderObject != null) {
|
||||
while (!renderObject!.isRepaintBoundary) {
|
||||
|
@ -76,9 +80,13 @@ class WidgetTesterAppDriverAdapter
|
|||
assert(renderObject != null);
|
||||
}
|
||||
|
||||
if (renderObject.debugNeedsPaint) {
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
}
|
||||
|
||||
final layer = renderObject.debugLayer as OffsetLayer;
|
||||
|
||||
return layer
|
||||
return await layer
|
||||
.toImage(renderObject.paintBounds)
|
||||
.then((value) => value.toByteData(format: ui.ImageByteFormat.png))
|
||||
.then((value) => value!.buffer.asUint8List());
|
||||
|
@ -105,7 +113,7 @@ class WidgetTesterAppDriverAdapter
|
|||
|
||||
return await screenshotOnAndroid();
|
||||
} else {
|
||||
return binding.takeScreenshot(name);
|
||||
return await binding.takeScreenshot(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,11 +34,13 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner {
|
|||
required StartAppFn appMainFunction,
|
||||
required Timeout scenarioExecutionTimeout,
|
||||
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
|
||||
LiveTestWidgetsFlutterBindingFramePolicy? framePolicy,
|
||||
}) : super(
|
||||
configuration: configuration,
|
||||
appMainFunction: appMainFunction,
|
||||
scenarioExecutionTimeout: scenarioExecutionTimeout,
|
||||
appLifecyclePumpHandler: appLifecyclePumpHandler,
|
||||
framePolicy: framePolicy,
|
||||
);
|
||||
|
||||
@override
|
||||
|
@ -54,12 +56,14 @@ void executeTestSuite({
|
|||
required StartAppFn appMainFunction,
|
||||
Timeout scenarioExecutionTimeout = const Timeout(const Duration(minutes: 10)),
|
||||
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
|
||||
LiveTestWidgetsFlutterBindingFramePolicy? framePolicy,
|
||||
}) {
|
||||
_CustomGherkinIntegrationTestRunner(
|
||||
configuration: configuration,
|
||||
appMainFunction: appMainFunction,
|
||||
appLifecyclePumpHandler: appLifecyclePumpHandler,
|
||||
scenarioExecutionTimeout: scenarioExecutionTimeout,
|
||||
framePolicy: framePolicy,
|
||||
).run();
|
||||
}
|
||||
''';
|
||||
|
|
|
@ -38,6 +38,7 @@ abstract class GherkinIntegrationTestRunner {
|
|||
final StartAppFn appMainFunction;
|
||||
final AppLifecyclePumpHandlerFn? appLifecyclePumpHandler;
|
||||
final Timeout scenarioExecutionTimeout;
|
||||
final LiveTestWidgetsFlutterBindingFramePolicy? framePolicy;
|
||||
final AggregatedReporter _reporter = AggregatedReporter();
|
||||
|
||||
late final Iterable<ExecutableStep>? _executableSteps;
|
||||
|
@ -47,7 +48,6 @@ abstract class GherkinIntegrationTestRunner {
|
|||
|
||||
AggregatedReporter get reporter => _reporter;
|
||||
Hook get hook => _hook!;
|
||||
LiveTestWidgetsFlutterBindingFramePolicy? get framePolicy => null;
|
||||
|
||||
/// A Gherkin test runner that uses [WidgetTester] to instrument the app under test.
|
||||
///
|
||||
|
@ -64,6 +64,7 @@ abstract class GherkinIntegrationTestRunner {
|
|||
required this.appMainFunction,
|
||||
required this.scenarioExecutionTimeout,
|
||||
this.appLifecyclePumpHandler,
|
||||
this.framePolicy,
|
||||
}) {
|
||||
configuration.prepare();
|
||||
_registerReporters(configuration.reporters);
|
||||
|
@ -79,8 +80,7 @@ abstract class GherkinIntegrationTestRunner {
|
|||
Future<void> run() async {
|
||||
_binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
_binding.framePolicy =
|
||||
framePolicy ?? LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive;
|
||||
_binding.framePolicy = framePolicy ?? _binding.framePolicy;
|
||||
|
||||
tearDownAll(
|
||||
() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: flutter_gherkin
|
||||
description: A Gherkin / Cucumber parser and test runner for Dart and Flutter
|
||||
version: 3.0.0-rc.14
|
||||
version: 3.0.0-rc.15
|
||||
homepage: https://github.com/jonsamwell/flutter_gherkin
|
||||
|
||||
environment:
|
||||
|
|
Loading…
Reference in New Issue