d02d5ea11d
Root causes found in release web captures (1280x800 and 560x900): - Follow mode undid small wheel/trackpad ticks at the end: each tick is its own scroll, re-judged as following within 32 px and jumped back. A user scroll toward older rows now releases the end however small; the jump control appears once streamed content moves the end beyond the threshold. - The end-of-scroll jump ran inside the position's activity switch, so a touch or scrollbar drag released near the end recursed without end (stack overflow during the gesture). The jump now runs after the notification. - Horizontally scrolling code blocks and tables claimed diagonal trackpad gestures whole. HorizontalScrollView gives mostly vertical gestures to the enclosing list; sideways and Shift + wheel still scroll the block. - The wheel over the floating chat bar, composer and jump control moved nothing. VerticalWheelForwarder scrolls the transcript from them unless something under the pointer claims the event. Adds widget tests per content kind and scroll mode, follow/touch/Load older tests, a capture-kit check (tool/capture/examples/chat-wheel-scroll.json) with eval/expect steps, wheel dx/repeat, --params and eval: targets, a transcript scroll probe and fixture options, and fixes the kit ignoring a script's size. Notes in notes/chat-wheel-scroll.md.
182 lines
5.3 KiB
Dart
182 lines
5.3 KiB
Dart
import 'package:flutter/gestures.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/ui/layout/wheel_scroll_forwarding.dart';
|
|
|
|
Future<void> _wheel(
|
|
WidgetTester tester,
|
|
Offset at,
|
|
Offset delta, {
|
|
PointerDeviceKind kind = PointerDeviceKind.trackpad,
|
|
}) async {
|
|
final pointer = TestPointer(1, kind);
|
|
await tester.sendEventToBinding(pointer.hover(at));
|
|
await tester.sendEventToBinding(pointer.scroll(delta));
|
|
await tester.pump();
|
|
}
|
|
|
|
void main() {
|
|
final list = ScrollController();
|
|
tearDownAll(list.dispose);
|
|
|
|
// A vertical list holding one wide horizontally scrolling row, under a
|
|
// floating button that is not part of the list.
|
|
Widget page({bool passThrough = true}) => MaterialApp(
|
|
home: Scaffold(
|
|
body: VerticalWheelForwarder(
|
|
controller: list,
|
|
child: Stack(
|
|
children: [
|
|
ListView(
|
|
controller: list,
|
|
children: [
|
|
const SizedBox(height: 200),
|
|
SizedBox(
|
|
height: 60,
|
|
child: passThrough
|
|
? const HorizontalScrollView(
|
|
key: Key('wide'),
|
|
child: SizedBox(width: 3000, height: 60),
|
|
)
|
|
: const SingleChildScrollView(
|
|
key: Key('wide'),
|
|
scrollDirection: Axis.horizontal,
|
|
child: SizedBox(width: 3000, height: 60),
|
|
),
|
|
),
|
|
const SizedBox(height: 2000),
|
|
],
|
|
),
|
|
Positioned(
|
|
right: 8,
|
|
bottom: 8,
|
|
child: FilledButton(
|
|
key: const Key('floating'),
|
|
onPressed: () {},
|
|
child: const Text('Floating'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
ScrollPosition sideways(WidgetTester tester) => tester
|
|
.state<ScrollableState>(
|
|
find.descendant(
|
|
of: find.byKey(const Key('wide')),
|
|
matching: find.byType(Scrollable),
|
|
),
|
|
)
|
|
.position;
|
|
|
|
testWidgets('a mostly vertical trackpad gesture over a wide row scrolls '
|
|
'the list', (tester) async {
|
|
await tester.pumpWidget(page());
|
|
final at = tester.getCenter(find.byKey(const Key('wide')));
|
|
await _wheel(tester, at, const Offset(5, 40));
|
|
expect(list.offset, 40);
|
|
expect(sideways(tester).pixels, 0);
|
|
});
|
|
|
|
testWidgets('a plain horizontal scroller takes the whole gesture (the '
|
|
'defect this guards against)', (tester) async {
|
|
await tester.pumpWidget(page(passThrough: false));
|
|
list.jumpTo(0);
|
|
final at = tester.getCenter(find.byKey(const Key('wide')));
|
|
await _wheel(tester, at, const Offset(5, 40));
|
|
expect(list.offset, 0);
|
|
expect(sideways(tester).pixels, 5);
|
|
});
|
|
|
|
testWidgets('a mostly sideways gesture or Shift + wheel scrolls the row', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(page());
|
|
list.jumpTo(0);
|
|
final at = tester.getCenter(find.byKey(const Key('wide')));
|
|
await _wheel(tester, at, const Offset(40, 5));
|
|
expect(sideways(tester).pixels, 40);
|
|
expect(list.offset, 0);
|
|
|
|
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
|
await _wheel(
|
|
tester,
|
|
at,
|
|
const Offset(0, 30),
|
|
kind: PointerDeviceKind.mouse,
|
|
);
|
|
await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
|
|
expect(sideways(tester).pixels, 70);
|
|
expect(list.offset, 0);
|
|
});
|
|
|
|
testWidgets('the wheel over a control floating above the list scrolls it', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(page());
|
|
list.jumpTo(0);
|
|
final at = tester.getCenter(find.byKey(const Key('floating')));
|
|
await _wheel(
|
|
tester,
|
|
at,
|
|
const Offset(0, 50),
|
|
kind: PointerDeviceKind.mouse,
|
|
);
|
|
expect(list.offset, 50);
|
|
// At the start, an upward wheel has nothing to move and is not claimed.
|
|
list.jumpTo(0);
|
|
await _wheel(
|
|
tester,
|
|
at,
|
|
const Offset(0, -50),
|
|
kind: PointerDeviceKind.mouse,
|
|
);
|
|
expect(list.offset, 0);
|
|
});
|
|
|
|
testWidgets('a multi-line field that can scroll its own text keeps the '
|
|
'wheel', (tester) async {
|
|
final field = ScrollController();
|
|
addTearDown(field.dispose);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: VerticalWheelForwarder(
|
|
controller: list,
|
|
child: Column(
|
|
children: [
|
|
Expanded(
|
|
child: ListView(
|
|
controller: list,
|
|
children: const [SizedBox(height: 3000)],
|
|
),
|
|
),
|
|
TextField(
|
|
key: const Key('field'),
|
|
scrollController: field,
|
|
maxLines: 3,
|
|
controller: TextEditingController(
|
|
text: List.generate(20, (i) => 'line $i').join('\n'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
list.jumpTo(0);
|
|
await _wheel(
|
|
tester,
|
|
tester.getCenter(find.byKey(const Key('field'))),
|
|
const Offset(0, 20),
|
|
kind: PointerDeviceKind.mouse,
|
|
);
|
|
expect(field.offset, greaterThan(0));
|
|
expect(list.offset, 0);
|
|
});
|
|
}
|