@@ -39,6 +39,95 @@ final class _CopyClient extends FixtureClient {
3939}
4040
4141void main () {
42+ testWidgets ('alternating pane selection clears before another frame' , (
43+ tester,
44+ ) async {
45+ tester.view.physicalSize = const Size (1400 , 1000 );
46+ tester.view.devicePixelRatio = 1 ;
47+ addTearDown (tester.view.resetPhysicalSize);
48+ addTearDown (tester.view.resetDevicePixelRatio);
49+ final session = GitSession (
50+ client: _CopyClient (),
51+ repository: repo,
52+ host: host (),
53+ );
54+ await session.start ();
55+ session.setViewState ('diffCollapse' , false );
56+ await tester.pumpWidget (
57+ MaterialApp (
58+ home: Scaffold (
59+ body: GitDiffView (
60+ session: session,
61+ comparison: GitComparison (
62+ RepoPath .text ('prose.md' ),
63+ const ContentVersion .index (),
64+ const ContentVersion .working (),
65+ ),
66+ ),
67+ ),
68+ ),
69+ );
70+ await tester.runAsync (
71+ () => Future <void >.delayed (const Duration (milliseconds: 120 )),
72+ );
73+ await tester.pumpAndSettle ();
74+ final left = tester.getCenter (find.text ('LEFT ONE' ));
75+ final right = tester.getCenter (find.text ('RIGHT ONE' ));
76+ String ? copied;
77+ tester.binding.defaultBinaryMessenger.setMockMethodCallHandler (
78+ SystemChannels .platform,
79+ (call) async {
80+ if (call.method == 'Clipboard.setData' ) {
81+ copied = (call.arguments as Map )['text' ] as String ;
82+ }
83+ return null ;
84+ },
85+ );
86+ addTearDown (
87+ () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler (
88+ SystemChannels .platform,
89+ null ,
90+ ),
91+ );
92+ for (var pass = 0 ; pass < 12 ; pass++ ) {
93+ await tester.tapAt (
94+ pass.isEven ? left : right,
95+ kind: PointerDeviceKind .mouse,
96+ );
97+ await tester.sendKeyDownEvent (LogicalKeyboardKey .controlLeft);
98+ await tester.sendKeyEvent (LogicalKeyboardKey .keyA);
99+ await tester.sendKeyUpEvent (LogicalKeyboardKey .controlLeft);
100+ // Another mouse selection starts before the pending pane registration frame.
101+ await tester.tapAt (
102+ pass.isEven ? right : left,
103+ kind: PointerDeviceKind .mouse,
104+ );
105+ await tester.tapAt (
106+ pass.isEven ? left : right,
107+ kind: PointerDeviceKind .mouse,
108+ );
109+ expect (tester.takeException (), isNull);
110+ await tester.pump ();
111+ expect (tester.takeException (), isNull);
112+ await tester.sendKeyDownEvent (LogicalKeyboardKey .controlLeft);
113+ await tester.sendKeyEvent (LogicalKeyboardKey .keyA);
114+ await tester.sendKeyEvent (LogicalKeyboardKey .keyC);
115+ await tester.sendKeyUpEvent (LogicalKeyboardKey .controlLeft);
116+ await tester.pump ();
117+ expect (
118+ copied,
119+ (pass.isEven
120+ ? 'LEFT ONE\n shared middle\n\n LEFT THREE\n LEFT FOUR'
121+ : 'RIGHT ONE\n shared middle\n RIGHT ONLY\n RIGHT THREE\n RIGHT FOUR' )
122+ .replaceAll ('shared middle' , _CopyClient .contextLine),
123+ );
124+ }
125+ // Retiring the view also retires any pending registration callback.
126+ await tester.tapAt (left, kind: PointerDeviceKind .mouse);
127+ await tester.pumpWidget (const SizedBox ());
128+ expect (tester.takeException (), isNull);
129+ session.dispose ();
130+ });
42131 for (final right in [false , true ]) {
43132 testWidgets (
44133 'copy full ${right ? 'right' : 'left' } source without building its tail' ,
0 commit comments