Skip to content

Commit

Permalink
Add golden_toolkit to sharezone_widgets (#900)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsreichardt authored Sep 6, 2023
1 parent 8ed9c69 commit f0b3b59
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/sharezone_widgets/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2022 Sharezone UG (haftungsbeschränkt)
# Licensed under the EUPL-1.2-or-later.
#
# You may obtain a copy of the Licence at:
# https://joinup.ec.europa.eu/software/page/eupl
#
# SPDX-License-Identifier: EUPL-1.2

tags:
# The tag "golden" is used by the "golden_toolkit" package.
#
# This will indicate that goldens are an expected test tag. All tests that use
# testGoldens() will automatically be given this tag. This allows you to
# easily target golden tests from the command line.
golden:
8 changes: 8 additions & 0 deletions lib/sharezone_widgets/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
golden_toolkit:
dependency: "direct dev"
description:
name: golden_toolkit
sha256: "8f74adab33154fe7b731395782797021f97d2edc52f7bfb85ff4f1b5c4a215f0"
url: "https://pub.dev"
source: hosted
version: "0.15.0"
http_parser:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions lib/sharezone_widgets/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
golden_toolkit: ^0.15.0
sharezone_lints:
path: ../sharezone_lints
46 changes: 46 additions & 0 deletions lib/sharezone_widgets/test_goldens/flutter_test_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2022 Sharezone UG (haftungsbeschränkt)
// Licensed under the EUPL-1.2-or-later.
//
// You may obtain a copy of the Licence at:
// https://joinup.ec.europa.eu/software/page/eupl
//
// SPDX-License-Identifier: EUPL-1.2

import 'dart:async';
import 'dart:io';
import 'dart:ui';

import 'package:golden_toolkit/golden_toolkit.dart';

Future<void> testExecutable(FutureOr<void> Function() testMain) async {
const Device phoneLandscape = Device(
name: 'phone_landscape',
size: Size(667, 375),
);

return GoldenToolkit.runWithConfiguration(
() async {
await loadAppFonts();
await testMain();
},
config: GoldenToolkitConfiguration(
// Due to slight differences in rendering across platforms, mostly around
// text, the tests will only be run on a macOS machine on Github Actions.
// This means that if you update the tests on a Linux or Windows machine
// the golden tests will not pass on Github Actions. Instead you are
// recommended to download the goldens directly from the failed Github
// Actions job, and use those inside of your branch.
//
// See
// https://github.com/flutter/flutter/issues/36667#issuecomment-521335243.
skipGoldenAssertion: () => !Platform.isMacOS,
defaultDevices: const [
Device.phone,
phoneLandscape,
Device.tabletLandscape,
Device.tabletPortrait,
Device.iphone11,
],
),
);
}

0 comments on commit f0b3b59

Please sign in to comment.