Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
23 changes: 23 additions & 0 deletions packages/cupertino_ui/test/goldens/goldens_test.dart
Comment thread
stuartmorgan-g marked this conversation as resolved.
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call for now. I'll plan to remove this when we are ready to attempt to publish the first pre-release version.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks. Let me double check with Stuart before merging this.

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);
}
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/foundation.dart';
import 'package:flutter/material.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:
* 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