-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from tsimbalar/feat-shadows
Introduce GoldenToolkitConfiguration.enableRealShadows
- Loading branch information
Showing
10 changed files
with
189 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+7.98 KB
...den_toolkit/test/goldens/enableRealShadows_honored_when_testGoldens_wrapped.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.21 KB
...toolkit/test/goldens/enableRealShadows_ignored_when_testGoldens_not_wrapped.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
class WidgetWithShadows extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
const borderRadius = BorderRadius.all(Radius.circular(10)); | ||
return Padding( | ||
padding: const EdgeInsets.all(30), | ||
child: Container( | ||
decoration: BoxDecoration( | ||
color: Colors.yellow, | ||
borderRadius: borderRadius, | ||
boxShadow: [ | ||
BoxShadow( | ||
offset: const Offset(10, 10), | ||
blurRadius: 16, | ||
color: Colors.black.withOpacity(0.3), | ||
) | ||
], | ||
), | ||
child: ClipRRect( | ||
borderRadius: borderRadius, | ||
child: Column( | ||
children: const [ | ||
Padding( | ||
padding: EdgeInsets.all(3), | ||
child: Text('this is the content'), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/golden_toolkit/test/shadows/flutter_test_config.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/// *************************************************** | ||
/// Copyright 2019-2020 eBay Inc. | ||
/// | ||
/// Use of this source code is governed by a BSD-style | ||
/// license that can be found in the LICENSE file or at | ||
/// https://opensource.org/licenses/BSD-3-Clause | ||
/// *************************************************** | ||
/// | ||
import 'dart:async'; | ||
import 'dart:io'; | ||
|
||
import 'package:golden_toolkit/golden_toolkit.dart'; | ||
|
||
Future<void> main(FutureOr<void> Function() testMain) async { | ||
return GoldenToolkit.runWithConfiguration( | ||
() async { | ||
await testMain(); | ||
}, | ||
config: GoldenToolkitConfiguration( | ||
// Currently, goldens are not generated/validated in CI for this repo. We have settled on the goldens for this package | ||
// being captured/validated by developers running on MacOSX. We may revisit this in the future if there is a reason to invest | ||
// in more sophistication | ||
skipGoldenAssertion: () => !Platform.isMacOS, | ||
// enableRealShadows can only work when "outside" of a `testGoldens` , for instance here at the root | ||
enableRealShadows: true, | ||
), | ||
); | ||
} |
Binary file added
BIN
+4.15 KB
packages/golden_toolkit/test/shadows/goldens/realShadows_disabled_locally.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.85 KB
packages/golden_toolkit/test/shadows/goldens/realShadows_enabled_globally.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/// *************************************************** | ||
/// Copyright 2019-2020 eBay Inc. | ||
/// | ||
/// Use of this source code is governed by a BSD-style | ||
/// license that can be found in the LICENSE file or at | ||
/// https://opensource.org/licenses/BSD-3-Clause | ||
/// *************************************************** | ||
/// | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:golden_toolkit/golden_toolkit.dart'; | ||
|
||
import '../sample_widgets.dart'; | ||
|
||
void main() { | ||
group('Shadows Tests', () { | ||
setUp(() { | ||
expect(debugDisableShadows, isTrue, | ||
reason: 'debugDisableShadows should always be true before test'); | ||
}); | ||
|
||
tearDown(() { | ||
expect(debugDisableShadows, isTrue, | ||
reason: 'debugDisableShadows should always be true after test'); | ||
}); | ||
|
||
testGoldens( | ||
'screenMatchesGolden method uses enableRealShadows from global configuration (flutter_test_config.dart)', | ||
(tester) async { | ||
await tester.pumpWidgetBuilder(WidgetWithShadows()); | ||
await screenMatchesGolden(tester, 'realShadows_enabled_globally'); | ||
|
||
expect(debugDisableShadows, isFalse, | ||
reason: 'debugDisableShadows should be false during test'); | ||
}); | ||
|
||
// wraping needs to happen outside of testGoldens | ||
GoldenToolkit.runWithConfiguration( | ||
() => { | ||
testGoldens( | ||
'screenMatchesGolden method can disable enableRealShadows temporarily', | ||
(tester) async { | ||
await tester.pumpWidgetBuilder(WidgetWithShadows()); | ||
await screenMatchesGolden(tester, 'realShadows_disabled_locally'); | ||
|
||
expect(debugDisableShadows, isTrue, | ||
reason: 'debugDisableShadows should be false during test'); | ||
}) | ||
}, | ||
config: GoldenToolkit.configuration.copyWith(enableRealShadows: false), | ||
); | ||
}); | ||
} |