Repository: flutter/flutter
File: packages/flutter/test/material/selection_area_test.dart (Dart)

Code before:

      expect(paragraph.selections.length, 1);
      expect(paragraph.selections[0], const TextSelection(baseOffset: 8, extentOffset: 22));

      // Attempt to move the start handle while still touching the end handle.
      final Offset startHandlePos = paragraph.localToGlobal(boxes[0].toRect().bottomLeft);
      final TestGesture startHandleGesture = await tester.startGesture(startHandlePos);
      addTearDown(startHandleGesture.removePointer);
      await tester.pump();
      await startHandleGesture.moveTo(
        textOffsetToPosition(paragraph, 0) + Offset(0, paragraph.size.height / 2),
      );
      await tester.pump();
      await gesture.up();
      await startHandleGesture.up();
      await tester.pumpAndSettle();
      // Selection changes when dragging start handle.
      expect(paragraph.selections.length, 1);
      expect(paragraph.selections[0], const TextSelection(baseOffset: 0, extentOffset: 22));
    },
    variant: TargetPlatformVariant.only(TargetPlatform.android),
    skip: kIsWeb, // [intended] on web only one selection handle can be dragged at a time.
  );

  // Regression test for https://github.com/flutter/flutter/issues/174246 .
  testWidgets('SelectionArea applies correct mouse cursors in its empty region', (
    WidgetTester tester,
  ) async {
    final GlobalKey innerRegion = GlobalKey();
    await tester.pumpWidget(
      MaterialApp(
        debugShowCheckedModeBanner: false,
        home: Scaffold(
          // Region 1 (fullscreen)
          body: MouseRegion(
            cursor: SystemMouseCursors.grab,
            child: Center(
              child: Container(
                decoration: BoxDecoration(border: Border.all()),
                // Region 2 (SelectionArea)
                child: SelectionArea(
                  child: Padding(
                    padding: const EdgeInsetsGeometry.all(40),
                    // Region 3 (inner MouseRegion)
                    child: MouseRegion(
                      key: innerRegion,
                      cursor: SystemMouseCursors.forbidden,
                      onHover: (_) {},
                      child: Container(color: const Color(0xFFAA9933), width: 200, height: 50),
                    ),
                  ),

Review comment (suggestion):
@gbolahan507 Would you be open to moving this test to `widgets/selectable_region_test.dart `? It's not testing a specific `SelectionArea` feature like adaptive text selection controls or context menus so i'm leaning towards moving it.

Code after:

      expect(paragraph.selections.length, 1);
      expect(paragraph.selections[0], const TextSelection(baseOffset: 8, extentOffset: 22));

      // Attempt to move the start handle while still touching the end handle.
      final Offset startHandlePos = paragraph.localToGlobal(boxes[0].toRect().bottomLeft);
      final TestGesture startHandleGesture = await tester.startGesture(startHandlePos);
      addTearDown(startHandleGesture.removePointer);
      await tester.pump();
      await startHandleGesture.moveTo(
        textOffsetToPosition(paragraph, 0) + Offset(0, paragraph.size.height / 2),
      );
      await tester.pump();
      await gesture.up();
      await startHandleGesture.up();
      await tester.pumpAndSettle();
      // Selection changes when dragging start handle.
      expect(paragraph.selections.length, 1);
      expect(paragraph.selections[0], const TextSelection(baseOffset: 0, extentOffset: 22));
    },
    variant: TargetPlatformVariant.only(TargetPlatform.android),
    skip: kIsWeb, // [intended] on web only one selection handle can be dragged at a time.
  );

  testWidgets('SelectionArea does not crash at zero area', (WidgetTester tester) async {
    await tester.pumpWidget(
      const MaterialApp(
        home: Center(
          child: SizedBox.shrink(child: SelectionArea(child: Text('X'))),
        ),
      ),
    );
    expect(tester.getSize(find.byType(SelectionArea)), Size.zero);
  });
}