Skip to content
48 changes: 48 additions & 0 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ targets:
recipe: packages/packages
timeout: 60
properties:
dependencies: >-
[
{"dependency": "goldctl", "version": "git_revision:031e93819017b95c3f2dfe463189c7b8d02f2f83"}
]
Comment thread
Piinks marked this conversation as resolved.
add_recipes_cq: "true"
target_file: dart_unit_tests.yaml
channel: master
Expand All @@ -146,6 +150,10 @@ targets:
recipe: packages/packages
timeout: 60
properties:
dependencies: >-
[
{"dependency": "goldctl", "version": "git_revision:031e93819017b95c3f2dfe463189c7b8d02f2f83"}
]
target_file: dart_unit_tests.yaml
channel: master
version_file: flutter_master.version
Expand All @@ -155,6 +163,10 @@ targets:
recipe: packages/packages
timeout: 60
properties:
dependencies: >-
[
{"dependency": "goldctl", "version": "git_revision:031e93819017b95c3f2dfe463189c7b8d02f2f83"}
]
target_file: dart_unit_tests.yaml
channel: stable
version_file: flutter_stable.version
Expand All @@ -164,6 +176,10 @@ targets:
recipe: packages/packages
timeout: 60
properties:
dependencies: >-
[
{"dependency": "goldctl", "version": "git_revision:031e93819017b95c3f2dfe463189c7b8d02f2f83"}
]
target_file: dart_unit_tests.yaml
channel: stable
version_file: flutter_stable.version
Expand All @@ -173,6 +189,10 @@ targets:
recipe: packages/packages
timeout: 60
properties:
dependencies: >-
[
{"dependency": "goldctl", "version": "git_revision:031e93819017b95c3f2dfe463189c7b8d02f2f83"}
]
add_recipes_cq: "true"
target_file: web_dart_unit_tests.yaml
channel: master
Expand All @@ -183,6 +203,10 @@ targets:
recipe: packages/packages
timeout: 60
properties:
dependencies: >-
[
{"dependency": "goldctl", "version": "git_revision:031e93819017b95c3f2dfe463189c7b8d02f2f83"}
]
target_file: web_dart_unit_tests.yaml
channel: master
version_file: flutter_master.version
Expand All @@ -192,6 +216,10 @@ targets:
recipe: packages/packages
timeout: 60
properties:
dependencies: >-
[
{"dependency": "goldctl", "version": "git_revision:031e93819017b95c3f2dfe463189c7b8d02f2f83"}
]
target_file: web_dart_unit_tests.yaml
channel: stable
version_file: flutter_stable.version
Expand All @@ -201,6 +229,10 @@ targets:
recipe: packages/packages
timeout: 60
properties:
dependencies: >-
[
{"dependency": "goldctl", "version": "git_revision:031e93819017b95c3f2dfe463189c7b8d02f2f83"}
]
target_file: web_dart_unit_tests.yaml
channel: stable
version_file: flutter_stable.version
Expand All @@ -211,6 +243,10 @@ targets:
recipe: packages/packages
timeout: 60
properties:
dependencies: >-
[
{"dependency": "goldctl", "version": "git_revision:031e93819017b95c3f2dfe463189c7b8d02f2f83"}
]
add_recipes_cq: "true"
target_file: web_dart_unit_tests_wasm.yaml
channel: master
Expand All @@ -221,6 +257,10 @@ targets:
recipe: packages/packages
timeout: 60
properties:
dependencies: >-
[
{"dependency": "goldctl", "version": "git_revision:031e93819017b95c3f2dfe463189c7b8d02f2f83"}
]
target_file: web_dart_unit_tests_wasm.yaml
channel: master
version_file: flutter_master.version
Expand Down Expand Up @@ -951,6 +991,10 @@ targets:
recipe: packages/packages
timeout: 60
properties:
dependencies: >-
[
{"dependency": "goldctl", "version": "git_revision:031e93819017b95c3f2dfe463189c7b8d02f2f83"}
]
target_file: windows_dart_unit_tests.yaml
channel: master
version_file: flutter_master.version
Expand All @@ -960,6 +1004,10 @@ targets:
recipe: packages/packages
timeout: 60
properties:
dependencies: >-
[
{"dependency": "goldctl", "version": "git_revision:031e93819017b95c3f2dfe463189c7b8d02f2f83"}
]
target_file: windows_dart_unit_tests.yaml
channel: master
version_file: flutter_master.version
Expand Down
8 changes: 8 additions & 0 deletions .ci/scripts/analyze_flutter_goldens.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Copyright 2013 The Flutter Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -e

cd script/flutter_goldens
flutter analyze --fatal-infos
8 changes: 8 additions & 0 deletions .ci/scripts/flutter_goldens_format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Copyright 2013 The Flutter Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -e

cd script/flutter_goldens
dart format --set-exit-if-changed .
8 changes: 8 additions & 0 deletions .ci/scripts/flutter_goldens_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Copyright 2013 The Flutter Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -e

cd script/flutter_goldens
flutter test
3 changes: 3 additions & 0 deletions .ci/scripts/prepare_tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ git branch main origin/main

cd script/tool
dart pub get

cd ../flutter_goldens
flutter pub get
2 changes: 2 additions & 0 deletions .ci/targets/analyze.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ tasks:
infra_step: true # Note infra steps failing prevents "always" from running.
- name: analyze repo tools
script: .ci/scripts/analyze_repo_tools.sh
- name: analyze flutter_goldens
script: .ci/scripts/analyze_flutter_goldens.sh
- name: download Dart deps
script: .ci/scripts/tool_runner.sh
args: ["fetch-deps"]
Expand Down
4 changes: 4 additions & 0 deletions .ci/targets/repo_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ tasks:
script: .ci/scripts/plugin_tools_tests.sh
- name: tool format
script: .ci/scripts/plugin_tools_format.sh
- name: flutter_goldens unit tests
script: .ci/scripts/flutter_goldens_tests.sh
- name: flutter_goldens format
script: .ci/scripts/flutter_goldens_format.sh
- name: format
script: .ci/scripts/tool_runner.sh
# Skip Swift formatting on Linux builders.
Expand Down
2 changes: 2 additions & 0 deletions .ci/targets/repo_tools_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ tasks:
infra_step: true # Note infra steps failing prevents "always" from running.
- name: tool unit tests
script: .ci/scripts/plugin_tools_tests.sh
- name: flutter_goldens unit tests
script: .ci/scripts/flutter_goldens_tests.sh
5 changes: 4 additions & 1 deletion packages/cupertino_ui/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: cupertino_ui
description: The official Flutter Cupertino Design Library, implementing the iOS design system.
version: 0.0.1
version: 0.0.2
publish_to: none
repository: https://github.com/flutter/packages/tree/main/packages/cupertino_ui
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A%20cupertino%22

Expand All @@ -13,6 +14,8 @@ dependencies:
sdk: flutter

dev_dependencies:
flutter_goldens:
path: ../../script/flutter_goldens
flutter_test:
sdk: flutter

Expand Down
14 changes: 14 additions & 0 deletions packages/cupertino_ui/test/flutter_test_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2013 The Flutter Authors
// 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<void> testExecutable(FutureOr<void> Function() testMain) {
// Enable golden file testing using Skia Gold.
return flutter_goldens.testExecutable(testMain, namePrefix: 'cupertino_ui');
}
23 changes: 23 additions & 0 deletions packages/cupertino_ui/test/goldens/goldens_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
testWidgets('Inconsequential golden test', (WidgetTester tester) async {
// The test validates the Flutter Gold integration. Any changes to the
// golden file can be approved at any time.
await tester.pumpWidget(
const CupertinoApp(home: Center(child: Text('Cupertino Goldens'))),
);

await tester.pumpAndSettle();
await expectLater(
find.byType(CupertinoApp),
matchesGoldenFile('inconsequential_golden_file.png'),
);
}, skip: kIsWeb);
}
5 changes: 5 additions & 0 deletions packages/cupertino_ui/test/goldens_io.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright 2013 The Flutter Authors
// 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;
11 changes: 11 additions & 0 deletions packages/cupertino_ui/test/goldens_web.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2013 The Flutter Authors
// 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<void> testExecutable(
FutureOr<void> Function() testMain, {
String? namePrefix,
}) async => testMain();
5 changes: 4 additions & 1 deletion packages/material_ui/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: material_ui
description: The official Flutter Material UI Library, implementing Google's Material Design design system.
version: 0.0.1
version: 0.0.2
publish_to: none
repository: https://github.com/flutter/packages/tree/main/packages/material_ui
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A%20material%20design%22

Expand All @@ -13,6 +14,8 @@ dependencies:
sdk: flutter

dev_dependencies:
flutter_goldens:
path: ../../script/flutter_goldens
flutter_test:
sdk: flutter

Expand Down
14 changes: 14 additions & 0 deletions packages/material_ui/test/flutter_test_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2013 The Flutter Authors
// 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<void> testExecutable(FutureOr<void> Function() testMain) {
// Enable golden file testing using Skia Gold.
return flutter_goldens.testExecutable(testMain, namePrefix: 'material_ui');
}
24 changes: 24 additions & 0 deletions packages/material_ui/test/goldens/goldens_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:material_ui/material_ui.dart';

void main() {
testWidgets('Inconsequential golden test', (WidgetTester tester) async {
// The test validates the Flutter Gold integration. Any changes to the
// golden file can be approved at any time.
await tester.pumpWidget(
RepaintBoundary(child: Container(color: const Color(0xAFF61145))),
);

await tester.pumpAndSettle();
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile('inconsequential_golden_file.png'),
);
}, skip: kIsWeb);
}
5 changes: 5 additions & 0 deletions packages/material_ui/test/goldens_io.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright 2013 The Flutter Authors
// 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;
11 changes: 11 additions & 0 deletions packages/material_ui/test/goldens_web.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2013 The Flutter Authors
// 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<void> testExecutable(
FutureOr<void> Function() testMain, {
String? namePrefix,
}) async => testMain();
11 changes: 11 additions & 0 deletions script/flutter_goldens/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This package is an internal implementation detail for our testing
infrastructure. It enables packages to use the Skia Gold
infrastructure for tracking golden image tests.

See also:
Comment thread
Piinks marked this conversation as resolved.
* https://skia.org/docs/dev/testing/skiagold/
* https://flutter-packages-gold.skia.org/
* [Writing a golden file test for package flutter]

[Writing a golden file test for package flutter]: https://github.com/flutter/flutter/blob/master/docs/contributing/testing/Writing-a-golden-file-test-for-package-flutter.md
Loading
Loading