Add "excluding" optional parameter to TargetPlatformVariant to communicate cases where test should be ran everywhere but specific platforms (#106216)
added "excluding" optional parameter to targetPlatforms.all Co-authored-by: Anthony Oleinik <oleina@google.com>
This commit is contained in:
parent
8ff691178c
commit
a494a12bb0
@ -47,7 +47,7 @@ void main() {
|
||||
|
||||
expect(topBeforeScroll.dy, equals(0.0));
|
||||
expect(topAfterScroll.dy, equals(0.0));
|
||||
}, variant: TargetPlatformVariant(TargetPlatform.values.where((TargetPlatform value) => value != TargetPlatform.fuchsia).toSet()));
|
||||
}, variant: TargetPlatformVariant.all(excluding: <TargetPlatform>{ TargetPlatform.fuchsia }));
|
||||
|
||||
testWidgets('FlexibleSpaceBar collapse mode pin', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
@ -85,7 +85,7 @@ void main() {
|
||||
|
||||
expect(topBeforeScroll.dy, equals(0.0));
|
||||
expect(topAfterScroll.dy, equals(-100.0));
|
||||
}, variant: TargetPlatformVariant(TargetPlatform.values.where((TargetPlatform value) => value != TargetPlatform.fuchsia).toSet()));
|
||||
}, variant: TargetPlatformVariant.all(excluding: <TargetPlatform>{ TargetPlatform.fuchsia }));
|
||||
|
||||
testWidgets('FlexibleSpaceBar collapse mode parallax', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
@ -123,7 +123,7 @@ void main() {
|
||||
expect(topBeforeScroll.dy, equals(0.0));
|
||||
expect(topAfterScroll.dy, lessThan(10.0));
|
||||
expect(topAfterScroll.dy, greaterThan(-50.0));
|
||||
}, variant: TargetPlatformVariant(TargetPlatform.values.where((TargetPlatform value) => value != TargetPlatform.fuchsia).toSet()));
|
||||
}, variant: TargetPlatformVariant.all(excluding: <TargetPlatform>{ TargetPlatform.fuchsia }));
|
||||
}
|
||||
|
||||
Future<void> slowDrag(WidgetTester tester, Key widget, Offset offset) async {
|
||||
|
@ -234,7 +234,7 @@ void main() {
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
expect(tester.hasRunningAnimations, false);
|
||||
}
|
||||
}, variant: TargetPlatformVariant(TargetPlatform.values.toSet()..remove(TargetPlatform.iOS)));
|
||||
}, variant: TargetPlatformVariant.all(excluding: <TargetPlatform>{ TargetPlatform.iOS }));
|
||||
|
||||
testWidgets('Cursor does not animate on Android', (WidgetTester tester) async {
|
||||
final Color defaultCursorColor = Color(ThemeData.fallback().colorScheme.primary.value);
|
||||
|
@ -138,7 +138,7 @@ void main() {
|
||||
|
||||
group('Common text editing shortcuts: ',
|
||||
() {
|
||||
final TargetPlatformVariant allExceptApple = TargetPlatformVariant(TargetPlatform.values.toSet()..removeAll(<TargetPlatform>[TargetPlatform.macOS, TargetPlatform.iOS]));
|
||||
final TargetPlatformVariant allExceptApple = TargetPlatformVariant.all(excluding: <TargetPlatform>{TargetPlatform.macOS, TargetPlatform.iOS});
|
||||
|
||||
group('backspace', () {
|
||||
const LogicalKeyboardKey trigger = LogicalKeyboardKey.backspace;
|
||||
@ -1813,7 +1813,7 @@ void main() {
|
||||
}, skip: kIsWeb); // [intended] on web these keys are handled by the browser.
|
||||
|
||||
group('Web does not accept', () {
|
||||
final TargetPlatformVariant allExceptApple = TargetPlatformVariant(TargetPlatform.values.toSet()..removeAll(<TargetPlatform>[TargetPlatform.macOS, TargetPlatform.iOS]));
|
||||
final TargetPlatformVariant allExceptApple = TargetPlatformVariant.all(excluding: <TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS });
|
||||
const TargetPlatformVariant appleOnly = TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.macOS, TargetPlatform.iOS });
|
||||
group('macOS shortcuts', () {
|
||||
|
||||
|
@ -254,8 +254,11 @@ class TargetPlatformVariant extends TestVariant<TargetPlatform> {
|
||||
const TargetPlatformVariant(this.values);
|
||||
|
||||
/// Creates a [TargetPlatformVariant] that tests all values from
|
||||
/// the [TargetPlatform] enum.
|
||||
TargetPlatformVariant.all() : values = TargetPlatform.values.toSet();
|
||||
/// the [TargetPlatform] enum. If [excluding] is provided, will test all platforms
|
||||
/// except those in [excluding].
|
||||
TargetPlatformVariant.all({
|
||||
Set<TargetPlatform> excluding = const <TargetPlatform>{},
|
||||
}) : values = TargetPlatform.values.toSet()..removeAll(excluding);
|
||||
|
||||
/// Creates a [TargetPlatformVariant] that includes platforms that are
|
||||
/// considered desktop platforms.
|
||||
|
@ -720,13 +720,29 @@ void main() {
|
||||
expect(defaultTargetPlatform, equals(TargetPlatform.iOS));
|
||||
}, variant: TargetPlatformVariant.only(TargetPlatform.iOS));
|
||||
|
||||
testWidgets('TargetPlatformVariant.all tests run all variants', (WidgetTester tester) async {
|
||||
if (debugDefaultTargetPlatformOverride == null) {
|
||||
expect(numberOfVariationsRun, equals(TargetPlatform.values.length));
|
||||
} else {
|
||||
numberOfVariationsRun += 1;
|
||||
}
|
||||
}, variant: TargetPlatformVariant.all());
|
||||
group('all', () {
|
||||
testWidgets('TargetPlatformVariant.all tests run all variants', (WidgetTester tester) async {
|
||||
if (debugDefaultTargetPlatformOverride == null) {
|
||||
expect(numberOfVariationsRun, equals(TargetPlatform.values.length));
|
||||
} else {
|
||||
numberOfVariationsRun += 1;
|
||||
}
|
||||
}, variant: TargetPlatformVariant.all());
|
||||
|
||||
const Set<TargetPlatform> excludePlatforms = <TargetPlatform>{ TargetPlatform.android, TargetPlatform.linux };
|
||||
testWidgets('TargetPlatformVariant.all, excluding runs an all variants except those provided in excluding', (WidgetTester tester) async {
|
||||
if (debugDefaultTargetPlatformOverride == null) {
|
||||
expect(numberOfVariationsRun, equals(TargetPlatform.values.length - excludePlatforms.length));
|
||||
expect(
|
||||
excludePlatforms,
|
||||
isNot(contains(debugDefaultTargetPlatformOverride)),
|
||||
reason: 'this test should not run on any platform in excludePlatforms'
|
||||
);
|
||||
} else {
|
||||
numberOfVariationsRun += 1;
|
||||
}
|
||||
}, variant: TargetPlatformVariant.all(excluding: excludePlatforms));
|
||||
});
|
||||
|
||||
testWidgets('TargetPlatformVariant.desktop + mobile contains all TargetPlatform values', (WidgetTester tester) async {
|
||||
final TargetPlatformVariant all = TargetPlatformVariant.all();
|
||||
|
Loading…
x
Reference in New Issue
Block a user