Clean up hover test. (#9826)
diff --git a/packages/devtools_app/lib/src/shared/ui/hover.dart b/packages/devtools_app/lib/src/shared/ui/hover.dart
index b4431fa..47e0048 100644
--- a/packages/devtools_app/lib/src/shared/ui/hover.dart
+++ b/packages/devtools_app/lib/src/shared/ui/hover.dart
@@ -117,7 +117,8 @@
 const _hoverYOffset = 10.0;
 
 /// Minimum distance from the side of screen to show tooltip
-const _hoverMargin = 16.0;
+@visibleForTesting
+const hoverMargin = 16.0;
 
 /// Defines how a [HoverCardTooltip] is positioned
 enum HoverCardPosition {
@@ -256,19 +257,16 @@
     final overlaySize = overlayBox.size;
     final localPosition = overlayBox.globalToLocal(event.position);
 
-    final maxX = math.max(
-      _hoverMargin,
-      overlaySize.width - _hoverMargin - width,
-    );
-    final x = (localPosition.dx - (width / 2.0)).clamp(_hoverMargin, maxX);
+    final maxX = math.max(hoverMargin, overlaySize.width - hoverMargin - width);
+    final x = (localPosition.dx - (width / 2.0)).clamp(hoverMargin, maxX);
 
     final maxY = math.max(
-      _hoverMargin,
+      hoverMargin,
       overlaySize.height -
-          _hoverMargin -
+          hoverMargin -
           _totalMaxHoverCardHeight(hasTitle: title != null),
     );
-    final y = (localPosition.dy + _hoverYOffset).clamp(_hoverMargin, maxY);
+    final y = (localPosition.dy + _hoverYOffset).clamp(hoverMargin, maxY);
 
     return Offset(x, y);
   }
@@ -381,7 +379,8 @@
   }) : asyncGenerateHoverCardData = null,
        asyncTimeout = null;
 
-  static const _hoverDelay = Duration(milliseconds: 500);
+  @visibleForTesting
+  static const hoverDelay = Duration(milliseconds: 500);
   static const defaultHoverWidth = 450.0;
 
   /// Whether the tooltip is currently enabled.
@@ -420,7 +419,7 @@
 
   void _onHoverExit() {
     _showTimer?.cancel();
-    _removeTimer = Timer(HoverCardTooltip._hoverDelay, () {
+    _removeTimer = Timer(HoverCardTooltip.hoverDelay, () {
       if (_currentHoverCard != null) {
         _hoverCardController.maybeRemoveHoverCard(_currentHoverCard!);
       }
@@ -448,7 +447,7 @@
     final generateHoverCardData = widget.generateHoverCardData;
     final asyncTimeout = widget.asyncTimeout;
 
-    _showTimer = Timer(HoverCardTooltip._hoverDelay, () {
+    _showTimer = Timer(HoverCardTooltip.hoverDelay, () {
       if (asyncGenerateHoverCardData != null) {
         assert(generateHoverCardData == null);
         _showAsyncHoverCard(
@@ -596,13 +595,13 @@
     final box = context.findRenderObject() as RenderBox;
 
     final maxX = math.max(
-      _hoverMargin,
-      overlayBox.size.width - _hoverMargin - width,
+      hoverMargin,
+      overlayBox.size.width - hoverMargin - width,
     );
     final maxY = math.max(
-      _hoverMargin,
+      hoverMargin,
       overlayBox.size.height -
-          _hoverMargin -
+          hoverMargin -
           _totalMaxHoverCardHeight(hasTitle: title != null),
     );
 
@@ -612,8 +611,8 @@
     );
 
     return Offset(
-      offset.dx.clamp(_hoverMargin, maxX),
-      offset.dy.clamp(_hoverMargin, maxY),
+      offset.dx.clamp(hoverMargin, maxX),
+      offset.dy.clamp(hoverMargin, maxY),
     );
   }
 
diff --git a/packages/devtools_app/test/shared/ui/hover_positioning_test.dart b/packages/devtools_app/test/shared/ui/hover_positioning_test.dart
index 79d2acd..4a5d968 100644
--- a/packages/devtools_app/test/shared/ui/hover_positioning_test.dart
+++ b/packages/devtools_app/test/shared/ui/hover_positioning_test.dart
@@ -7,7 +7,10 @@
 import 'package:flutter/gestures.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_test/flutter_test.dart';
-import 'package:provider/provider.dart';
+
+const _windowWidth = 800.0;
+const _windowHeight = 600.0;
+const _windowSize = Size(_windowWidth, _windowHeight);
 
 void main() {
   Future<void> pumpHoverCardTooltip(
@@ -40,13 +43,13 @@
     await gesture.addPointer(location: Offset.zero);
     final center = tester.getCenter(find.text('Hover Me'));
     await gesture.moveTo(center);
-    await tester.pump(const Duration(milliseconds: 500));
+    await tester.pump(HoverCardTooltip.hoverDelay);
     await tester.pumpAndSettle();
   }
 
   testWidgetsWithWindowSize(
     'HoverCard at the bottom of the window should not overflow',
-    const Size(800, 600),
+    _windowSize,
     (WidgetTester tester) async {
       // Use a title to increase the height beyond the base content height.
       await pumpHoverCardTooltip(
@@ -66,14 +69,16 @@
       final position = renderBox.localToGlobal(Offset.zero);
       final size = renderBox.size;
 
-      // _hoverMargin = 16.0
-      expect(position.dy + size.height, lessThanOrEqualTo(600.0 - 16.0));
+      expect(
+        position.dy + size.height,
+        lessThanOrEqualTo(_windowHeight - hoverMargin),
+      );
     },
   );
 
   testWidgetsWithWindowSize(
     'HoverCard at the right of the window should not overflow',
-    const Size(800, 600),
+    _windowSize,
     (WidgetTester tester) async {
       await pumpHoverCardTooltip(tester, alignment: Alignment.centerRight);
 
@@ -88,8 +93,10 @@
       final position = renderBox.localToGlobal(Offset.zero);
       final size = renderBox.size;
 
-      // _hoverMargin = 16.0
-      expect(position.dx + size.width, lessThanOrEqualTo(800.0 - 16.0));
+      expect(
+        position.dx + size.width,
+        lessThanOrEqualTo(_windowWidth - hoverMargin),
+      );
     },
   );
 
@@ -110,38 +117,36 @@
     },
   );
 
-  testWidgetsWithWindowSize(
-    'HoverCard height clamping with title',
-    const Size(800, 600),
-    (WidgetTester tester) async {
-      await pumpHoverCardTooltip(
-        tester,
-        alignment: Alignment.bottomCenter,
-        title: 'An Important Title',
-      );
+  testWidgetsWithWindowSize('HoverCard height clamping with title', _windowSize, (
+    WidgetTester tester,
+  ) async {
+    await pumpHoverCardTooltip(
+      tester,
+      alignment: Alignment.bottomCenter,
+      title: 'An Important Title',
+    );
 
-      final hoverContentFinderWithTitle = find.text('Hover Content');
-      expect(hoverContentFinderWithTitle, findsOneWidget);
+    final hoverContentFinderWithTitle = find.text('Hover Content');
+    expect(hoverContentFinderWithTitle, findsOneWidget);
 
-      final containerWithTitle = find
-          .ancestor(
-            of: hoverContentFinderWithTitle,
-            matching: find.byType(Container),
-          )
-          .last;
+    final containerWithTitle = find
+        .ancestor(
+          of: hoverContentFinderWithTitle,
+          matching: find.byType(Container),
+        )
+        .last;
 
-      final renderBoxWithTitle =
-          tester.renderObject(containerWithTitle) as RenderBox;
-      final positionWithTitle = renderBoxWithTitle.localToGlobal(Offset.zero);
+    final renderBoxWithTitle =
+        tester.renderObject(containerWithTitle) as RenderBox;
+    final positionWithTitle = renderBoxWithTitle.localToGlobal(Offset.zero);
 
-      // Clamps strictly at y = 274.0 because of dynamic height containing title/divider.
-      expect(positionWithTitle.dy, equals(274.0));
-    },
-  );
+    // Clamps strictly at y = 274.0 because of dynamic height containing title/divider.
+    expect(positionWithTitle.dy, equals(274.0));
+  });
 
   testWidgetsWithWindowSize(
     'HoverCard height clamping without title',
-    const Size(800, 600),
+    _windowSize,
     (WidgetTester tester) async {
       await pumpHoverCardTooltip(tester, alignment: Alignment.bottomCenter);
 
@@ -166,39 +171,34 @@
 
   testWidgetsWithWindowSize(
     'HoverCard translates global coordinates to local coordinates for offset overlays',
-    const Size(800, 600),
+    _windowSize,
     (WidgetTester tester) async {
       final overlayKey = GlobalKey();
 
       await tester.pumpWidget(
-        MaterialApp(
-          home: Scaffold(
-            body: Padding(
-              padding: const EdgeInsets.only(left: 50.0, top: 100.0),
-              child: Provider<HoverCardController>.value(
-                value: HoverCardController(),
-                child: Overlay(
-                  key: overlayKey,
-                  initialEntries: [
-                    OverlayEntry(
-                      builder: (context) => Align(
-                        alignment: Alignment.topLeft,
-                        child: HoverCardTooltip.sync(
-                          enabled: () => true,
-                          generateHoverCardData: (event) => HoverCardData(
-                            contents: const SizedBox(
-                              width: 200,
-                              height: 250,
-                              child: Text('Hover Content'),
-                            ),
-                          ),
-                          child: const Text('Hover Me Offset'),
+        wrapSimple(
+          Padding(
+            padding: const EdgeInsets.only(left: 50.0, top: 100.0),
+            child: Overlay(
+              key: overlayKey,
+              initialEntries: [
+                OverlayEntry(
+                  builder: (context) => Align(
+                    alignment: Alignment.topLeft,
+                    child: HoverCardTooltip.sync(
+                      enabled: () => true,
+                      generateHoverCardData: (event) => HoverCardData(
+                        contents: const SizedBox(
+                          width: 200,
+                          height: 250,
+                          child: Text('Hover Content'),
                         ),
                       ),
+                      child: const Text('Hover Me Offset'),
                     ),
-                  ],
+                  ),
                 ),
-              ),
+              ],
             ),
           ),
         ),
@@ -210,7 +210,7 @@
 
       final center = tester.getCenter(find.text('Hover Me Offset'));
       await gesture.moveTo(center);
-      await tester.pump(const Duration(milliseconds: 500));
+      await tester.pump(HoverCardTooltip.hoverDelay);
       await tester.pumpAndSettle();
 
       final hoverContentFinder = find.text('Hover Content');
diff --git a/pubspec.lock b/pubspec.lock
index d6df6ba..769f78d 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -951,10 +951,10 @@
     dependency: transitive
     description:
       name: url_launcher_web
-      sha256: d0412fcf4c6b31ecfdb7762359b7206ffba3bbffd396c6d9f9c4616ece476c1f
+      sha256: "85c81589622fbc87c1c683aaea164d3604a7777495a79d91e39ffcdec39ddb34"
       url: "https://pub.dev"
     source: hosted
-    version: "2.4.2"
+    version: "2.4.3"
   url_launcher_windows:
     dependency: transitive
     description: