Skip to content

Commit

Permalink
Merge branch 'bt/flutter-3.16.0' into bt/3.16.0-update-goldens
Browse files Browse the repository at this point in the history
  • Loading branch information
btrautmann committed Sep 10, 2024
2 parents e842df4 + 2305cd3 commit 9d1ed5a
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 65 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

- uses: subosito/flutter-action@v2
with:
flutter-version: '3.13.0'
flutter-version: '3.16.0'
channel: 'stable'
cache: true

Expand All @@ -27,6 +27,14 @@ jobs:
- name: Run tests
run: flutter test --no-pub --coverage --test-randomize-ordering-seed=random

- name: Upload failures
if: failure()
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: "golden_failures"
path: |
**/failures/**/*.png
- uses: codecov/codecov-action@v2
with:
files: coverage/lcov.info
Expand All @@ -39,7 +47,7 @@ jobs:

- uses: subosito/flutter-action@v2
with:
flutter-version: '3.13.0'
flutter-version: '3.16.0'
channel: 'stable'
cache: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/post_merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- uses: subosito/flutter-action@v2
with:
flutter-version: 3.13.0
flutter-version: '3.16.0'
cache: true

- name: Install Dependencies
Expand Down
51 changes: 19 additions & 32 deletions lib/src/alchemist_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ class AlchemistConfig extends Equatable {
/// The [enabled] flag determines whether or not these golden tests are
/// enabled. If set to `false`, these tests will not be generated or compared.
/// Otherwise the tests will function as normal.
/// {@endtemplate goldens_config_enabled}
/// {@endtemplate}
///
/// {@template goldens_config_file_path_resolver}
/// The [filePathResolver] can be used to customize the name and of the golden
/// file.
/// {@endtemplate goldens_config_file_path_resolver}
/// {@endtemplate}
///
/// {@template goldens_config_theme}
/// If a [theme] is provided, it will be assigned to the [MaterialApp] created
Expand All @@ -266,14 +266,14 @@ class AlchemistConfig extends Equatable {
/// **Note:** when [obscureText] is true, tests are always rendered
/// in the "Ahem" font family to ensure consistent results across platforms.
/// In other words, the font family of the [theme] will be ignored.
/// {@endtemplate goldens_config_theme}
/// {@endtemplate}
///
/// {@template goldens_config_render_shadows}
/// The [renderShadows] flag determines whether or not shadows are rendered in
/// golden tests.
/// If set to `false`, all shadows are replaced with solid color blocks.
/// {@endtemplate goldens_config_render_shadows}
/// {@endtemplate goldens_config}
/// {@endtemplate}
/// {@endtemplate}
abstract class GoldensConfig extends Equatable {
/// {@macro goldens_config}
const GoldensConfig({
Expand Down Expand Up @@ -379,24 +379,17 @@ abstract class GoldensConfig extends Equatable {
/// By default, [renderShadows] is set to true so platform golden images are a
/// more accurate representation of the tested widget.
///
/// {@endtemplate platform_goldens_config}
/// {@endtemplate}
class PlatformGoldensConfig extends GoldensConfig {
/// {@macro platform_goldens_config}
const PlatformGoldensConfig({
Set<HostPlatform>? platforms,
bool enabled = true,
bool obscureText = false,
bool renderShadows = true,
FilePathResolver? filePathResolver,
ThemeData? theme,
}) : _platforms = platforms,
super(
enabled: enabled,
obscureText: obscureText,
renderShadows: renderShadows,
filePathResolver: filePathResolver,
theme: theme,
);
super.enabled = true,
super.obscureText = false,
super.renderShadows = true,
super.filePathResolver,
super.theme,
}) : _platforms = platforms;

@override
String get environmentName => HostPlatform.current().operatingSystem;
Expand Down Expand Up @@ -474,22 +467,16 @@ class PlatformGoldensConfig extends GoldensConfig {
/// {@macro goldens_config_render_shadows}
/// By default, [renderShadows] is set to false to make CI tests more stable.
///
/// {@endtemplate ci_goldens_config}
/// {@endtemplate}
class CiGoldensConfig extends GoldensConfig {
/// {@macro ci_goldens_config}
const CiGoldensConfig({
bool enabled = true,
bool obscureText = true,
bool renderShadows = false,
FilePathResolver? filePathResolver,
ThemeData? theme,
}) : super(
enabled: enabled,
obscureText: obscureText,
renderShadows: renderShadows,
filePathResolver: filePathResolver,
theme: theme,
);
super.enabled = true,
super.obscureText = true,
super.renderShadows = false,
super.filePathResolver,
super.theme,
});

@override
String get environmentName => 'CI';
Expand Down
4 changes: 2 additions & 2 deletions lib/src/golden_test_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,12 @@ class FlutterGoldenTestAdapter extends GoldenTestAdapter {
class FlutterGoldenTestWrapper extends StatelessWidget {
/// {@macro _flutter_golden_test_wrapper}
const FlutterGoldenTestWrapper({
Key? key,
super.key,
this.globalConfigTheme,
this.variantConfigTheme,
this.obscureFont = false,
required this.child,
}) : super(key: key);
});

/// The theme provided by the global [AlchemistConfig], if any.
///
Expand Down
4 changes: 2 additions & 2 deletions lib/src/golden_test_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ typedef ColumnWidthBuilder = TableColumnWidth? Function(int columns);
class GoldenTestGroup extends StatelessWidget {
/// {@macro golden_test_group}
const GoldenTestGroup({
Key? key,
super.key,
this.columns,
this.columnWidthBuilder,
this.scenarioConstraints,
required this.children,
}) : super(key: key);
});

/// The number of columns in the grid.
///
Expand Down
18 changes: 8 additions & 10 deletions lib/src/golden_test_scenario.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,35 @@ WidgetBuilder _build(Widget build) => (context) => build;
class GoldenTestScenario extends StatelessWidget {
/// {@macro golden_test_scenario}
GoldenTestScenario({
Key? key,
super.key,
required this.name,
required Widget child,
this.constraints,
}) : builder = _build(child),
super(key: key);
}) : builder = _build(child);

/// Creates a [GoldenTestScenario] with a [builder] function that allows
/// access to the [BuildContext] of the widget.
const GoldenTestScenario.builder({
Key? key,
super.key,
required this.name,
required this.builder,
this.constraints,
}) : super(key: key);
});

/// Creates a [GoldenTestScenario] with a custom [textScaleFactor] that
/// applies a default scale of text to its child.
GoldenTestScenario.withTextScaleFactor({
Key? key,
super.key,
required this.name,
required double textScaleFactor,
required Widget child,
this.constraints,
}) : builder = _build(
}) : builder = _build(
_CustomTextScaleFactor(
textScaleFactor: textScaleFactor,
child: child,
),
),
super(key: key);
);

/// The name of the scenario.
///
Expand Down Expand Up @@ -121,7 +119,7 @@ class _CustomTextScaleFactor extends StatelessWidget {
Widget build(BuildContext context) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaleFactor: textScaleFactor,
textScaler: TextScaler.linear(textScaleFactor),
),
child: child,
);
Expand Down
6 changes: 3 additions & 3 deletions lib/src/golden_test_scenario_constraints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import 'package:flutter/material.dart';
class GoldenTestScenarioConstraints extends InheritedWidget {
/// {@macro golden_test_scenario_constraints}
const GoldenTestScenarioConstraints({
Key? key,
required Widget child,
super.key,
required super.child,
required this.constraints,
}) : super(key: key, child: child);
});

/// The constraints to apply to the scenario's child.
final BoxConstraints? constraints;
Expand Down
3 changes: 2 additions & 1 deletion lib/src/utilities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ extension GoldenTestThemeDataExtensions on ThemeData {
static const obscuredTextFontFamily = 'Ahem';

/// Strips all text packages from this theme's [ThemeData.textTheme] for use
/// in golden tests using [GoldenTestTextStyleExtensions.stripAlchemistPackage].
/// in golden tests using
/// [GoldenTestTextStyleExtensions.stripAlchemistPackage].
///
/// Only used internally and should not be used by consumers.
@protected
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ homepage: https://github.com/Betterment/alchemist
repository: https://github.com/Betterment/alchemist

environment:
sdk: ">=3.0.1 <4.0.0"
flutter: ">=3.13.0"
sdk: ">=3.2.0 <4.0.0"
flutter: ">=3.16.0"

dependencies:
equatable: ^2.0.3
Expand Down
1 change: 1 addition & 0 deletions test/flutter_test_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Future<void> testExecutable(FutureOr<void> Function() testMain) async {
return AlchemistConfig.runWithConfig(
config: AlchemistConfig(
theme: ThemeData(
useMaterial3: false,
textTheme: const TextTheme().apply(fontFamily: 'Roboto'),
),
platformGoldensConfig:
Expand Down
4 changes: 1 addition & 3 deletions test/smoke_tests/composited_transform_smoke_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

class _SmokeTest extends StatelessWidget {
_SmokeTest({Key? key})
: _link = LayerLink(),
super(key: key);
_SmokeTest({super.key}) : _link = LayerLink();

final LayerLink _link;

Expand Down
2 changes: 1 addition & 1 deletion test/smoke_tests/dropdown_smoke_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

class TestDropdownButton extends StatelessWidget {
const TestDropdownButton({Key? key}) : super(key: key);
const TestDropdownButton({super.key});

@override
Widget build(BuildContext context) => Center(
Expand Down
2 changes: 1 addition & 1 deletion test/smoke_tests/render_object_smoke_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void main() {
}

class _CustomExampleRenderObject extends LeafRenderObjectWidget {
const _CustomExampleRenderObject({Key? key}) : super(key: key);
const _CustomExampleRenderObject();

@override
_CustomExampleRenderBox createRenderObject(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion test/smoke_tests/timer_button_smoke_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

class TimerButton extends StatelessWidget {
const TimerButton({Key? key}) : super(key: key);
const TimerButton({super.key});

@override
Widget build(BuildContext context) {
Expand Down
6 changes: 3 additions & 3 deletions test/src/golden_test_scenario_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ void main() {
expect(
mediaQuery,
isA<MediaQueryData>().having(
(m) => m.textScaleFactor,
'textScaleFactor',
2.0,
(m) => m.textScaler,
'textScaler',
const TextScaler.linear(2),
),
);
},
Expand Down
2 changes: 1 addition & 1 deletion test/src/utilities_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void main() {
printLogs,
[
'''
No widgets found that match finder: zero widgets with text "does not exist" (ignoring offstage widgets).
No widgets found that match finder: Found 0 widgets with text "does not exist": [].
No gestures will be performed.
If this is intentional, consider not calling this method
Expand Down

0 comments on commit 9d1ed5a

Please sign in to comment.