diff --git a/packages/integration_test/pubspec.yaml b/packages/integration_test/pubspec.yaml index 0fed29b84a..19abe2f7f8 100644 --- a/packages/integration_test/pubspec.yaml +++ b/packages/integration_test/pubspec.yaml @@ -38,6 +38,10 @@ dependencies: vector_math: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" webdriver: 3.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" +dev_dependencies: + flutter_goldens: + sdk: flutter + flutter: plugin: platforms: diff --git a/packages/integration_test/test/_goldens_io.dart b/packages/integration_test/test/_goldens_io.dart new file mode 100644 index 0000000000..d552235d69 --- /dev/null +++ b/packages/integration_test/test/_goldens_io.dart @@ -0,0 +1,5 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +export 'package:flutter_goldens/flutter_goldens.dart' show testExecutable; diff --git a/packages/integration_test/test/_goldens_web.dart b/packages/integration_test/test/_goldens_web.dart new file mode 100644 index 0000000000..a18d6a13d4 --- /dev/null +++ b/packages/integration_test/test/_goldens_web.dart @@ -0,0 +1,8 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +// package:flutter_goldens is not used as part of the test process for web. +Future testExecutable(FutureOr Function() testMain, {String? namePrefix}) async => testMain(); diff --git a/packages/integration_test/test/flutter_test_config.dart b/packages/integration_test/test/flutter_test_config.dart new file mode 100644 index 0000000000..f985a52917 --- /dev/null +++ b/packages/integration_test/test/flutter_test_config.dart @@ -0,0 +1,12 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import '_goldens_io.dart' if (dart.library.js_interop) '_goldens_web.dart' as flutter_goldens; + +Future testExecutable(FutureOr Function() testMain) { + // Enable golden file testing using Skia Gold. + return flutter_goldens.testExecutable(testMain, namePrefix: 'integration'); +} diff --git a/packages/integration_test/test/golden_screenshot_test.dart b/packages/integration_test/test/golden_screenshot_test.dart new file mode 100644 index 0000000000..3069159a25 --- /dev/null +++ b/packages/integration_test/test/golden_screenshot_test.dart @@ -0,0 +1,23 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +@Tags(['reduced-test-set']) +library; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('a screenshot of a Placeholder', (WidgetTester tester) async { + await tester.pumpWidget(const Placeholder()); + + await expectLater( + find.byType(Placeholder), + matchesGoldenFile('placeholder.png'), + ); + }); +}