From 4ff2deafd4b9d9b8bf030db8b2163b49ecdccf10 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Thu, 13 Feb 2025 08:43:05 -0800 Subject: [PATCH] Enable `goldenFileComparator` fix for on-device integration tests. (#163157) Closes https://github.com/flutter/flutter/issues/143299. Closes https://github.com/flutter/flutter/issues/160043. A website update is work-in-progress here to add more context for users: . --- packages/flutter_tools/lib/src/test/flutter_platform.dart | 5 +++++ .../example/integration_test/matches_golden_test.dart | 3 --- .../integration_test/lib/src/vm_service_golden_client.dart | 2 -- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index d06ec1202cb..99b1fa9d79c 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -243,6 +243,11 @@ void main() { buffer.write(''' goldenFileComparator = LocalFileComparator(Uri.parse('$testUrl')); autoUpdateGoldenFiles = $updateGoldens; +'''); + } + if (integrationTest) { + buffer.write(''' + VmServiceProxyGoldenFileComparator.useIfRunningOnDevice(); '''); } if (testConfigFile != null) { diff --git a/packages/integration_test/example/integration_test/matches_golden_test.dart b/packages/integration_test/example/integration_test/matches_golden_test.dart index 72f0399da32..0172b971bd2 100644 --- a/packages/integration_test/example/integration_test/matches_golden_test.dart +++ b/packages/integration_test/example/integration_test/matches_golden_test.dart @@ -24,9 +24,6 @@ import 'package:integration_test_example/main.dart' as app; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - // TODO(matanlurey): Make this automatic as part of the bootstrap. - VmServiceProxyGoldenFileComparator.useIfRunningOnDevice(); - testWidgets('can use matchesGoldenFile with integration_test', (WidgetTester tester) async { // Build our app and trigger a frame. app.main(); diff --git a/packages/integration_test/lib/src/vm_service_golden_client.dart b/packages/integration_test/lib/src/vm_service_golden_client.dart index 3c73f9c10de..8e8b0299e8e 100644 --- a/packages/integration_test/lib/src/vm_service_golden_client.dart +++ b/packages/integration_test/lib/src/vm_service_golden_client.dart @@ -12,7 +12,6 @@ import 'dart:io' as io; import 'package:flutter/foundation.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:meta/meta.dart'; /// Compares image pixels against a golden image file on the host system. /// @@ -65,7 +64,6 @@ import 'package:meta/meta.dart'; /// See also: /// /// * [matchesGoldenFile], the function that invokes the comparator. -@experimental final class VmServiceProxyGoldenFileComparator extends GoldenFileComparator { VmServiceProxyGoldenFileComparator._() : _postEvent = dev.postEvent { dev.registerExtension(_kServiceName, (_, Map parameters) {