1
0
mirror of https://github.com/flutter/samples.git synced 2026-05-14 02:47:42 +00:00

Flutter 3.29 beta (#2571)

This commit is contained in:
Eric Windmill
2025-02-12 18:08:01 -05:00
committed by GitHub
parent d62c784789
commit 719fd72c38
685 changed files with 76244 additions and 53721 deletions

View File

@@ -6,121 +6,124 @@ import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Can show and use the cascading menu', (tester) async {
await tester.pumpWidget(const MyApp());
testWidgets(
'Can show and use the cascading menu',
(tester) async {
await tester.pumpWidget(const MyApp());
// Navigate to the CascadingMenuPage example.
await tester.dragUntilVisible(
find.text(CascadingMenuPage.title),
find.byType(ListView),
const Offset(0.0, -250.0),
);
await tester.pumpAndSettle();
await tester.tap(find.text(CascadingMenuPage.title));
await tester.pumpAndSettle();
// Navigate to the CascadingMenuPage example.
await tester.dragUntilVisible(
find.text(CascadingMenuPage.title),
find.byType(ListView),
const Offset(0.0, -250.0),
);
await tester.pumpAndSettle();
await tester.tap(find.text(CascadingMenuPage.title));
await tester.pumpAndSettle();
const String message =
'Right click or long press anywhere to show the cascading menu.';
expect(find.text(message), findsOneWidget);
const String message =
'Right click or long press anywhere to show the cascading menu.';
expect(find.text(message), findsOneWidget);
// Right click on the background of the app to show the cascading context
// menu.
TestGesture gesture = await tester.startGesture(
const Offset(0.0, 100.0),
kind: PointerDeviceKind.mouse,
buttons: kSecondaryMouseButton,
);
await tester.pump();
await gesture.up();
await gesture.removePointer();
await tester.pumpAndSettle();
// Right click on the background of the app to show the cascading context
// menu.
TestGesture gesture = await tester.startGesture(
const Offset(0.0, 100.0),
kind: PointerDeviceKind.mouse,
buttons: kSecondaryMouseButton,
);
await tester.pump();
await gesture.up();
await gesture.removePointer();
await tester.pumpAndSettle();
// The custom cascading context menu is shown.
expect(find.byType(DesktopTextSelectionToolbar), findsOneWidget);
expect(find.text('About'), findsOneWidget);
expect(find.text('Show'), findsNothing);
expect(find.text('Hide'), findsOneWidget);
expect(find.text('Reset'), findsOneWidget);
expect(find.text('Color'), findsOneWidget);
// The custom cascading context menu is shown.
expect(find.byType(DesktopTextSelectionToolbar), findsOneWidget);
expect(find.text('About'), findsOneWidget);
expect(find.text('Show'), findsNothing);
expect(find.text('Hide'), findsOneWidget);
expect(find.text('Reset'), findsOneWidget);
expect(find.text('Color'), findsOneWidget);
// Click "Hide Message" and the message and menu are hidden.
await tester.tap(find.text('Hide'));
await tester.pumpAndSettle();
expect(find.byType(DesktopTextSelectionToolbar), findsNothing);
expect(find.text(message), findsNothing);
// Click "Hide Message" and the message and menu are hidden.
await tester.tap(find.text('Hide'));
await tester.pumpAndSettle();
expect(find.byType(DesktopTextSelectionToolbar), findsNothing);
expect(find.text(message), findsNothing);
// Right click to show the menu again.
gesture = await tester.startGesture(
const Offset(0.0, 100.0),
kind: PointerDeviceKind.mouse,
buttons: kSecondaryMouseButton,
);
await tester.pump();
await gesture.up();
await gesture.removePointer();
await tester.pumpAndSettle();
expect(find.byType(DesktopTextSelectionToolbar), findsOneWidget);
expect(find.text('About'), findsOneWidget);
expect(find.text('Show'), findsOneWidget);
expect(find.text('Hide'), findsNothing);
expect(find.text('Reset'), findsOneWidget);
expect(find.text('Color'), findsOneWidget);
// Right click to show the menu again.
gesture = await tester.startGesture(
const Offset(0.0, 100.0),
kind: PointerDeviceKind.mouse,
buttons: kSecondaryMouseButton,
);
await tester.pump();
await gesture.up();
await gesture.removePointer();
await tester.pumpAndSettle();
expect(find.byType(DesktopTextSelectionToolbar), findsOneWidget);
expect(find.text('About'), findsOneWidget);
expect(find.text('Show'), findsOneWidget);
expect(find.text('Hide'), findsNothing);
expect(find.text('Reset'), findsOneWidget);
expect(find.text('Color'), findsOneWidget);
// Use the shortcut to show the message again.
await tester.sendKeyDownEvent(LogicalKeyboardKey.control);
await tester.sendKeyDownEvent(LogicalKeyboardKey.keyS);
await tester.sendKeyUpEvent(LogicalKeyboardKey.control);
await tester.sendKeyUpEvent(LogicalKeyboardKey.keyS);
await tester.pumpAndSettle();
expect(find.byType(DesktopTextSelectionToolbar), findsNothing);
expect(find.text(message), findsOneWidget);
// Use the shortcut to show the message again.
await tester.sendKeyDownEvent(LogicalKeyboardKey.control);
await tester.sendKeyDownEvent(LogicalKeyboardKey.keyS);
await tester.sendKeyUpEvent(LogicalKeyboardKey.control);
await tester.sendKeyUpEvent(LogicalKeyboardKey.keyS);
await tester.pumpAndSettle();
expect(find.byType(DesktopTextSelectionToolbar), findsNothing);
expect(find.text(message), findsOneWidget);
// Right click to show the menu again.
gesture = await tester.startGesture(
const Offset(0.0, 100.0),
kind: PointerDeviceKind.mouse,
buttons: kSecondaryMouseButton,
);
await tester.pump();
await gesture.up();
await gesture.removePointer();
await tester.pumpAndSettle();
expect(find.byType(DesktopTextSelectionToolbar), findsOneWidget);
expect(find.text('About'), findsOneWidget);
expect(find.text('Show'), findsNothing);
expect(find.text('Hide'), findsOneWidget);
expect(find.text('Reset'), findsOneWidget);
expect(find.text('Color'), findsOneWidget);
expect(find.text('Red'), findsNothing);
expect(find.text('Green'), findsNothing);
expect(find.text('Blue'), findsNothing);
// Right click to show the menu again.
gesture = await tester.startGesture(
const Offset(0.0, 100.0),
kind: PointerDeviceKind.mouse,
buttons: kSecondaryMouseButton,
);
await tester.pump();
await gesture.up();
await gesture.removePointer();
await tester.pumpAndSettle();
expect(find.byType(DesktopTextSelectionToolbar), findsOneWidget);
expect(find.text('About'), findsOneWidget);
expect(find.text('Show'), findsNothing);
expect(find.text('Hide'), findsOneWidget);
expect(find.text('Reset'), findsOneWidget);
expect(find.text('Color'), findsOneWidget);
expect(find.text('Red'), findsNothing);
expect(find.text('Green'), findsNothing);
expect(find.text('Blue'), findsNothing);
// Hover Background Color.
gesture = await tester.startGesture(
//tester.getCenter(find.text('Color')),
const Offset(0.0, 100),
kind: PointerDeviceKind.mouse,
);
await tester.pump();
await gesture.moveTo(tester.getCenter(find.text('Color')));
await tester.pumpAndSettle();
// Hover Background Color.
gesture = await tester.startGesture(
//tester.getCenter(find.text('Color')),
const Offset(0.0, 100),
kind: PointerDeviceKind.mouse,
);
await tester.pump();
await gesture.moveTo(tester.getCenter(find.text('Color')));
await tester.pumpAndSettle();
// Background colors are shown.
expect(find.text('Red'), findsOneWidget);
expect(find.text('Green'), findsOneWidget);
expect(find.text('Blue'), findsOneWidget);
// Background colors are shown.
expect(find.text('Red'), findsOneWidget);
expect(find.text('Green'), findsOneWidget);
expect(find.text('Blue'), findsOneWidget);
// Select green.
await gesture.moveTo(tester.getCenter(find.text('Green')));
await tester.pump();
await tester.tap(find.text('Green'));
await tester.pump();
await gesture.removePointer();
// Select green.
await gesture.moveTo(tester.getCenter(find.text('Green')));
await tester.pump();
await tester.tap(find.text('Green'));
await tester.pump();
await gesture.removePointer();
// The menu is gone and the UI shows green was selected.
expect(find.byType(DesktopTextSelectionToolbar), findsNothing);
expect(find.text('Last Selected: Green Background'), findsOneWidget);
},
// TODO(justinmc): https://github.com/flutter/samples/issues/2086
skip: true);
// The menu is gone and the UI shows green was selected.
expect(find.byType(DesktopTextSelectionToolbar), findsNothing);
expect(find.text('Last Selected: Green Background'), findsOneWidget);
},
// TODO(justinmc): https://github.com/flutter/samples/issues/2086
skip: true,
);
}