Repository: flutter
Issue: Widget test is failing when TextSpan with TapGestureRecognizer is used within MergeSemantics widget
Labels: a: tests,framework,f: material design,f: gestures,a: typography,has reproducible steps,found in release: 2.2,found in release: 2.5,team-design,triaged-design

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->
I tried to use TextSpan with TapGestureRecognizer inside CheckboxListTile, but it crashes inside tests. I narrowed down the problem to MergeSemantics widget.

## Steps to Reproduce
<!-- You must include full steps to reproduce so that we can reproduce the problem. -->

1. Run `flutter create bug`.
2. Add test with the Link widget from below.
3. Run the test.
```
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

class Link extends StatefulWidget {
  const Link({Key? key}) : super(key: key);

  @override
  LinkState createState() => LinkState();
}

class LinkState extends State<Link> {
  late TapGestureRecognizer recognizer;

  @override
  void initState() {
    super.initState();
    recognizer = TapGestureRecognizer();
  }

  @override
  void dispose() {
    super.dispose();
    recognizer.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MergeSemantics( // Replace with something else and it will work
      child: RichText(
        text: TextSpan(
          text: "Hello",
          recognizer: recognizer,
        ),
      ),
    );
  }
}

void main() {
  group('Link', () {
    testWidgets('does not crash', (WidgetTester tester) async {
      await tester.pumpWidget(const MaterialApp(home: Link()));
    });
  });
}
```

**Expected results:** <!-- what did you want to see? -->
Test should pass as the app is working when run outside tests.
**Actual results:** <!-- what did you see? -->
Test crashes.

<details>
  <summary>Logs</summary>

```
Output for Link does not crash
══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
'package:flutter/src/semantics/semantics.dart': Failed assertion: line 2655 pos 16: 'node.parent ==
null || !node.parent!.isPartOfNodeMerging || node.isMergedIntoParent': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially
more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack:
#2      SemanticsOwner.sendSemanticsUpdate (package:flutter/src/semantics/semantics.dart:2655:16)
#3      PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1078:24)
#4      AutomatedTestWidgetsFlutterBinding.drawFrame (package:flutter_test/src/binding.dart:1118:31)
#5      RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:328:5)
#6      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#7      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1082:9)
#8      AutomatedTestWidgetsFlutterBinding.pump.<anonymous closure> (package:flutter_test/src/binding.dart:973:9)
#11     TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:71:41)
#12     AutomatedTestWidgetsFlutterBinding.pump (package:flutter_test/src/binding.dart:960:27)
#13     WidgetTester.pumpWidget.<anonymous closure> (package:flutter_test/src/widget_tester.dart:534:22)
#16     TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:71:41)
#17     WidgetTester.pumpWidget (package:flutter_test/src/widget_tester.dart:531:27)
#18     main.<anonymous closure>.<anonymous closure> (file:///Users/r/Projekty/UX/test/link_test.dart:43:20)
#19     main.<anonymous closure>.<anonymous closure> (file:///Users/r/Projekty/UX/test/link_test.dart:42:35)
#20     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:156:29)
<asynchronous suspension>
<asynchronous suspension>
(elided 7 frames from class _AssertionError, dart:async, and package:stack_trace)
════════════════════════════════════════════════════════════════════════════════════════════════════
Test failed. See exception logs above.
The test description was: does not crash
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale pl-PL)
    • Flutter version 2.2.3 at /Users/r/flutter
    • Framework revision f4abaa0735 (4 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/r/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5, Build version 12E262
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] VS Code (version 1.58.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.24.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 11.4 20F71 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 92.0.4515.107

• No issues found!
```
</details>