Skip to content

Commit

Permalink
temporary workaround for DevTools extension
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia committed Nov 13, 2023
1 parent 2eb539a commit 778b4ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/patrol/lib/src/binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ class PatrolBinding extends LiveTestWidgetsFlutterBinding {

final DevtoolsServiceExtensions _serviceExtensions;

/// Temporary workaround for DevTools extension changing this value and not
/// resetting it.
TargetPlatform? workaroundDebugDefaultTargetPlatformOverride;

@override
void initInstances() {
super.initInstances();
Expand Down
8 changes: 6 additions & 2 deletions packages/patrol/lib/src/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ void patrolTest(
PatrolBinding? patrolBinding;

automator = NativeAutomator(config: nativeAutomatorConfig);
patrolBinding = PatrolBinding.ensureInitialized(nativeAutomatorConfig)
..framePolicy = framePolicy;
final binding =
patrolBinding = PatrolBinding.ensureInitialized(nativeAutomatorConfig)
..framePolicy = framePolicy;

testWidgets(
description,
Expand Down Expand Up @@ -112,6 +113,9 @@ void patrolTest(
final waitSeconds = const int.fromEnvironment('PATROL_WAIT');
final waitDuration = Duration(seconds: waitSeconds);

debugDefaultTargetPlatformOverride =
binding.workaroundDebugDefaultTargetPlatformOverride;

if (waitDuration > Duration.zero) {
final stopwatch = Stopwatch()..start();
await Future.doWhile(() async {
Expand Down
5 changes: 4 additions & 1 deletion packages/patrol_cli/lib/src/test_bundler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ ${generateGroupsCode(testFilePaths).split('\n').map((e) => ' $e').join('\n')}
final contents = '''
// ignore_for_file: type=lint, invalid_use_of_internal_member
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/patrol.dart';
Expand All @@ -138,7 +139,9 @@ ${generateImports([testFilePath])}
Future<void> main() async {
final nativeAutomator = NativeAutomator(config: NativeAutomatorConfig());
await nativeAutomator.initialize();
PatrolBinding.ensureInitialized(NativeAutomatorConfig());
PatrolBinding.ensureInitialized(NativeAutomatorConfig())
..workaroundDebugDefaultTargetPlatformOverride =
debugDefaultTargetPlatformOverride;
// START: GENERATED TEST GROUPS
${generateGroupsCode([testFilePath]).split('\n').map((e) => ' $e').join('\n')}
Expand Down

0 comments on commit 778b4ed

Please sign in to comment.