Improve file image gestures
This commit is contained in:
@@ -651,6 +651,70 @@ void main() {
|
||||
expect(find.textContaining('1 of 2'), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('pinch owns the image gesture, pans while zoomed, and resets', (
|
||||
tester,
|
||||
) async {
|
||||
final first = recordedArtifact(
|
||||
'a.png',
|
||||
url: '/artifacts/1/1/a.png',
|
||||
contentType: 'image/png',
|
||||
);
|
||||
final second = recordedArtifact(
|
||||
'b.png',
|
||||
url: '/artifacts/1/2/b.png',
|
||||
contentType: 'image/png',
|
||||
);
|
||||
final groups = [
|
||||
_group([first], visit: 1),
|
||||
_group([second], visit: 2),
|
||||
];
|
||||
await _pumpViewer(
|
||||
tester,
|
||||
groups: groups,
|
||||
selected: artifactVisitIdentity(groups[0], first),
|
||||
);
|
||||
|
||||
final viewport = tester.getRect(
|
||||
find.byKey(const Key('artifact-image-zoom')),
|
||||
);
|
||||
final center = viewport.center;
|
||||
final one = await tester.startGesture(
|
||||
center + const Offset(-30, 0),
|
||||
pointer: 1,
|
||||
);
|
||||
final two = await tester.startGesture(
|
||||
center + const Offset(30, 0),
|
||||
pointer: 2,
|
||||
);
|
||||
await one.moveTo(center + const Offset(-110, 0));
|
||||
await two.moveTo(center + const Offset(110, 0));
|
||||
await tester.pump();
|
||||
await one.up();
|
||||
await two.up();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('artifact-image-reset-zoom')), findsOneWidget);
|
||||
// A one-finger drag now belongs to the zoomed image, not the gallery.
|
||||
await tester.fling(
|
||||
find.byKey(const Key('artifact-image-zoom')),
|
||||
const Offset(-300, 0),
|
||||
1000,
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('1 of 2'), findsWidgets);
|
||||
|
||||
await tester.tap(find.byKey(const Key('artifact-image-reset-zoom')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('artifact-image-reset-zoom')), findsNothing);
|
||||
await tester.fling(
|
||||
find.byKey(const Key('artifact-viewer-swipe')),
|
||||
const Offset(-300, 0),
|
||||
1000,
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('2 of 2'), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('Material paging stays inside 320px at 2x text', (tester) async {
|
||||
tester.view.physicalSize = const Size(640, 1200);
|
||||
tester.view.devicePixelRatio = 2;
|
||||
|
||||
Reference in New Issue
Block a user