ShaderMask on web for CupertinoContextMenu (#77864)
Now that ShaderMask works on web, enable it for CupertinoContextMenu and unskip relevant tests.
This commit is contained in:
parent
11c3c83c84
commit
216f9b59ee
@ -5,7 +5,6 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
import 'package:flutter/gestures.dart' show kMinFlingVelocity, kLongPressTimeout;
|
import 'package:flutter/gestures.dart' show kMinFlingVelocity, kLongPressTimeout;
|
||||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -511,22 +510,17 @@ class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin
|
|||||||
: _mask.value;
|
: _mask.value;
|
||||||
return Positioned.fromRect(
|
return Positioned.fromRect(
|
||||||
rect: _rect.value!,
|
rect: _rect.value!,
|
||||||
// TODO(justinmc): When ShaderMask is supported on web, remove this
|
child: ShaderMask(
|
||||||
// conditional and use ShaderMask everywhere.
|
key: _childGlobalKey,
|
||||||
// https://github.com/flutter/flutter/issues/52967.
|
shaderCallback: (Rect bounds) {
|
||||||
child: kIsWeb
|
return LinearGradient(
|
||||||
? Container(key: _childGlobalKey, child: widget.child)
|
begin: Alignment.topLeft,
|
||||||
: ShaderMask(
|
end: Alignment.bottomRight,
|
||||||
key: _childGlobalKey,
|
colors: <Color>[color, color],
|
||||||
shaderCallback: (Rect bounds) {
|
).createShader(bounds);
|
||||||
return LinearGradient(
|
},
|
||||||
begin: Alignment.topLeft,
|
child: widget.child,
|
||||||
end: Alignment.bottomRight,
|
),
|
||||||
colors: <Color>[color, color],
|
|
||||||
).createShader(bounds);
|
|
||||||
},
|
|
||||||
child: widget.child,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
final TestWidgetsFlutterBinding binding =
|
final TestWidgetsFlutterBinding binding =
|
||||||
@ -104,10 +103,7 @@ void main() {
|
|||||||
Rect decoyChildRect = tester.getRect(_findDecoyChild(child));
|
Rect decoyChildRect = tester.getRect(_findDecoyChild(child));
|
||||||
expect(childRect, equals(decoyChildRect));
|
expect(childRect, equals(decoyChildRect));
|
||||||
|
|
||||||
// TODO(justinmc): When ShaderMask is supported on web, remove this
|
expect(find.byType(ShaderMask), findsOneWidget);
|
||||||
// conditional and just check for ShaderMask.
|
|
||||||
// https://github.com/flutter/flutter/issues/52967.
|
|
||||||
expect(find.byType(ShaderMask), kIsWeb ? findsNothing : findsOneWidget);
|
|
||||||
|
|
||||||
// After a small delay, the _DecoyChild has begun to animate.
|
// After a small delay, the _DecoyChild has begun to animate.
|
||||||
await tester.pump(const Duration(milliseconds: 100));
|
await tester.pump(const Duration(milliseconds: 100));
|
||||||
@ -125,7 +121,7 @@ void main() {
|
|||||||
await gesture.up();
|
await gesture.up();
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(_findStatic(), findsOneWidget);
|
expect(_findStatic(), findsOneWidget);
|
||||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44152
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('CupertinoContextMenu when open', () {
|
group('CupertinoContextMenu when open', () {
|
||||||
@ -145,7 +141,7 @@ void main() {
|
|||||||
await tester.tapAt(const Offset(1.0, 1.0));
|
await tester.tapAt(const Offset(1.0, 1.0));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(_findStatic(), findsNothing);
|
expect(_findStatic(), findsNothing);
|
||||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44152
|
});
|
||||||
|
|
||||||
testWidgets('Can close CupertinoContextMenu by dragging down', (WidgetTester tester) async {
|
testWidgets('Can close CupertinoContextMenu by dragging down', (WidgetTester tester) async {
|
||||||
final Widget child = _getChild();
|
final Widget child = _getChild();
|
||||||
@ -187,7 +183,7 @@ void main() {
|
|||||||
await swipeGesture.up();
|
await swipeGesture.up();
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(_findStatic(), findsNothing);
|
expect(_findStatic(), findsNothing);
|
||||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44152
|
});
|
||||||
|
|
||||||
testWidgets('Can close CupertinoContextMenu by flinging down', (WidgetTester tester) async {
|
testWidgets('Can close CupertinoContextMenu by flinging down', (WidgetTester tester) async {
|
||||||
final Widget child = _getChild();
|
final Widget child = _getChild();
|
||||||
@ -212,7 +208,7 @@ void main() {
|
|||||||
await tester.fling(_findStaticChild(child), const Offset(0.0, 100.0), 1000.0);
|
await tester.fling(_findStaticChild(child), const Offset(0.0, 100.0), 1000.0);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(_findStatic(), findsNothing);
|
expect(_findStatic(), findsNothing);
|
||||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44152
|
});
|
||||||
|
|
||||||
testWidgets("Backdrop is added using ModalRoute's filter parameter", (WidgetTester tester) async {
|
testWidgets("Backdrop is added using ModalRoute's filter parameter", (WidgetTester tester) async {
|
||||||
final Widget child = _getChild();
|
final Widget child = _getChild();
|
||||||
@ -227,7 +223,7 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(_findStatic(), findsOneWidget);
|
expect(_findStatic(), findsOneWidget);
|
||||||
expect(find.byType(BackdropFilter), findsOneWidget);
|
expect(find.byType(BackdropFilter), findsOneWidget);
|
||||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44152
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group("Open layout differs depending on child's position on screen", () {
|
group("Open layout differs depending on child's position on screen", () {
|
||||||
@ -302,7 +298,7 @@ void main() {
|
|||||||
|
|
||||||
// Set the screen back to its normal size.
|
// Set the screen back to its normal size.
|
||||||
await binding.setSurfaceSize(const Size(800.0, 600.0));
|
await binding.setSurfaceSize(const Size(800.0, 600.0));
|
||||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44152
|
});
|
||||||
|
|
||||||
testWidgets('Landscape', (WidgetTester tester) async {
|
testWidgets('Landscape', (WidgetTester tester) async {
|
||||||
// Pump a CupertinoContextMenu in the center of the screen and open it.
|
// Pump a CupertinoContextMenu in the center of the screen and open it.
|
||||||
@ -367,6 +363,6 @@ void main() {
|
|||||||
expect(find.byType(CupertinoContextMenuAction), findsOneWidget);
|
expect(find.byType(CupertinoContextMenuAction), findsOneWidget);
|
||||||
final Offset right = tester.getTopLeft(find.byType(CupertinoContextMenuAction));
|
final Offset right = tester.getTopLeft(find.byType(CupertinoContextMenuAction));
|
||||||
expect(right.dx, lessThan(left.dx));
|
expect(right.dx, lessThan(left.dx));
|
||||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44152
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ void main() {
|
|||||||
testWidgets('Can be constructed', (WidgetTester tester) async {
|
testWidgets('Can be constructed', (WidgetTester tester) async {
|
||||||
const Widget child = SizedBox(width: 100.0, height: 100.0);
|
const Widget child = SizedBox(width: 100.0, height: 100.0);
|
||||||
await tester.pumpWidget(const ShaderMask(child: child, shaderCallback: createShader));
|
await tester.pumpWidget(const ShaderMask(child: child, shaderCallback: createShader));
|
||||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44152
|
});
|
||||||
|
|
||||||
testWidgets('Bounds rect includes offset', (WidgetTester tester) async {
|
testWidgets('Bounds rect includes offset', (WidgetTester tester) async {
|
||||||
late Rect shaderBounds;
|
late Rect shaderBounds;
|
||||||
@ -43,7 +43,7 @@ void main() {
|
|||||||
|
|
||||||
// The shader bounds rectangle should reflect the position of the centered SizedBox.
|
// The shader bounds rectangle should reflect the position of the centered SizedBox.
|
||||||
expect(shaderBounds, equals(const Rect.fromLTWH(0.0, 0.0, 400.0, 400.0)));
|
expect(shaderBounds, equals(const Rect.fromLTWH(0.0, 0.0, 400.0, 400.0)));
|
||||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44152
|
});
|
||||||
|
|
||||||
|
|
||||||
testWidgets('Bounds rect includes offset visual inspection', (WidgetTester tester) async {
|
testWidgets('Bounds rect includes offset visual inspection', (WidgetTester tester) async {
|
||||||
@ -106,5 +106,5 @@ void main() {
|
|||||||
find.byType(RepaintBoundary),
|
find.byType(RepaintBoundary),
|
||||||
matchesGoldenFile('shader_mask.bounds.matches_top_left.png'),
|
matchesGoldenFile('shader_mask.bounds.matches_top_left.png'),
|
||||||
);
|
);
|
||||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44152
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user