flutter/examples/api/test/material/tooltip/tooltip.3_test.dart
LongCatIsLooong 1b800fd496
Remove Tooltip mouse tracker listener & update hovering/MouseRegion logic & animation (#119199)
Fixes https://github.com/flutter/flutter/issues/117627

### Behavior changes:
1. If fade in/fade out animation is already in progress, hiding/showing the tooltip will immediately take effect without waiting for `waitDuration`.
2. A PointerDownEvent that doesn't become a part of a "trigger" gesture dismisses the tooltip, even for hovered ones.
3. The OverlayEntry is now updated only when the previous tooltip was completely dismissed. This can be fixed by OverlayPortal but I'm not sure what the correct behavior is.
2023-05-25 07:24:45 +00:00

29 lines
1.1 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/material/tooltip/tooltip.3.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Tooltip is visible when tapping button', (WidgetTester tester) async {
const String tooltipText = 'I am a Tooltip';
await tester.pumpWidget(
const example.TooltipExampleApp(),
);
// Tooltip is not visible before tapping the button.
expect(find.text(tooltipText), findsNothing);
// Tap on the button and wait for the tooltip to appear.
await tester.tap(find.byType(FloatingActionButton));
await tester.pump(const Duration(milliseconds: 10));
expect(find.text(tooltipText), findsOneWidget);
// Tap on the tooltip and wait for the tooltip to disappear.
await tester.tap(find.byTooltip(tooltipText));
await tester.pump(const Duration(seconds: 1));
expect(find.text(tooltipText), findsNothing);
});
}