Skip to content

Commit

Permalink
Merge pull request #124 from eBay/feature/fix-material-issue
Browse files Browse the repository at this point in the history
Feature/fix material issue
  • Loading branch information
coreysprague authored Oct 15, 2021
2 parents c37e52b + 50ed6ba commit 99c826d
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 22 deletions.
2 changes: 2 additions & 0 deletions packages/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ build/
ios/.generated/
ios/Flutter/Generated.xcconfig
ios/Runner/GeneratedPluginRegistrant.*

**lcov.info
6 changes: 6 additions & 0 deletions packages/golden_toolkit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.11.0

- migrate from pedantic -> flutter_lints
- resolved warning that could appear for consumers ```package:golden_toolkit has `uses-material-design: true` set but the primary pubspec contains `uses-material-design: false`. If the application needs material icons, then `uses-material-design` must be set to true```
- updated documentation to indicate that you no longer need to include an empty images folder to get fonts to render in goldens for packages that do not contain any images.

## 0.10.0

This release has a few updates & changes.
Expand Down
8 changes: 0 additions & 8 deletions packages/golden_toolkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,6 @@ At the moment, it is only possible to load a single .ttf file for a font family.

Additionally, in some instances, it is not possible to replace the "Ahem" font. There are specific places in the Flutter codebase, such as rendering the "debug banner" where no explicit font family is specified. In these instances, the engine will use Ahem in a test context, with no way to override the behavior.

Also note that at the moment for having the required files generated for font processing the pubspec.yaml should have an entry in the images section, make sure it has at least this:

```yaml
flutter:
assets:
- images/
```

### testGoldens()

It is possible to use golden assertions in any testWidgets() test. As the UI for a widget evolves, it is common to need to regenerate goldens to capture your new reference images. The easiest way to do this is via the command-line:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class _MyHomePageState extends State<_MyHomePage> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Icon(Icons.flutter_dash),
const Text(
'You have pushed the button this many times:',
),
Expand Down
2 changes: 1 addition & 1 deletion packages/golden_toolkit/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.10.0"
version: "0.11.0"
lints:
dependency: transitive
description:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
6 changes: 1 addition & 5 deletions packages/golden_toolkit/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: golden_toolkit
description: Common patterns for screenshot-based widget testing using Goldens.
version: 0.10.0
version: 0.11.0
homepage: https://github.com/eBay/flutter_glove_box/
repository: https://github.com/eBay/flutter_glove_box/tree/master/packages/golden_toolkit
issue_tracker: https://github.com/eBay/flutter_glove_box/issues
Expand All @@ -22,10 +22,6 @@ dev_dependencies:
test_api: ^0.4.2

flutter:
uses-material-design: true
assets:
# needed to trigger the FontManifest.json to be included
- images/
fonts:
- family: Roboto
fonts:
Expand Down
2 changes: 0 additions & 2 deletions packages/golden_toolkit/test/font_loading_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Future<void> main() async {
final golden = GoldenBuilder.column()
..addScenario('Material Fonts should work',
const Text('This is material text in "Roboto"'))
..addScenario(
'Material Icons should work', const Icon(Icons.phone_in_talk))
..addScenario(
'Fonts from packages should work',
const Text('This is a custom font',
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified packages/golden_toolkit/test/goldens/material_fonts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 18 additions & 6 deletions packages/golden_toolkit/test/material_app_wrapper_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,40 @@ void main() {
});

group('allow specification of TargetPlatform', () {
testGoldens('Android asset should display correctly', (tester) async {
testWidgets('Android asset should display correctly', (tester) async {
await tester.pumpWidgetBuilder(
Row(children: const [BackButtonIcon(), Text('Android')]),
Builder(
builder: (context) => Text(
Theme.of(context).platform == TargetPlatform.iOS
? 'iOS'
: 'Android',
),
),
wrapper: materialAppWrapper(
platform: TargetPlatform.android,
theme: ThemeData.light(),
),
surfaceSize: const Size(80, 40),
);
await screenMatchesGolden(tester, 'back_button_android');
expect(find.text('Android'), findsOneWidget);
});

testGoldens('iOS should display correctly', (tester) async {
testWidgets('iOS should display correctly', (tester) async {
await tester.pumpWidgetBuilder(
Row(children: const [BackButtonIcon(), Text('iOS')]),
Builder(
builder: (context) => Text(
Theme.of(context).platform == TargetPlatform.iOS
? 'iOS'
: 'Android',
),
),
surfaceSize: const Size(80, 40),
wrapper: materialAppWrapper(
platform: TargetPlatform.iOS,
theme: ThemeData.light(),
),
);
await screenMatchesGolden(tester, 'back_button_ios');
expect(find.text('iOS'), findsOneWidget);
});
});
});
Expand Down

0 comments on commit 99c826d

Please sign in to comment.