@@ -1722,6 +1722,50 @@ void main() {
17221722 expect (translation2.y, lessThan (translation1.y));
17231723 });
17241724
1725+ testWidgets ('discrete scroll pointer events' , (WidgetTester tester) async {
1726+ final TransformationController transformationController = TransformationController ();
1727+ const double boundaryMargin = 50.0 ;
1728+ await tester.pumpWidget (
1729+ MaterialApp (
1730+ home: Scaffold (
1731+ body: Center (
1732+ child: InteractiveViewer (
1733+ boundaryMargin: const EdgeInsets .all (boundaryMargin),
1734+ transformationController: transformationController,
1735+ child: const SizedBox (width: 200.0 , height: 200.0 ),
1736+ ),
1737+ ),
1738+ ),
1739+ ),
1740+ );
1741+
1742+ expect (transformationController.value.getMaxScaleOnAxis (), 1.0 );
1743+ Vector3 translation = transformationController.value.getTranslation ();
1744+ expect (translation.x, 0 );
1745+ expect (translation.y, 0 );
1746+
1747+ // Send a mouse scroll event, it should cause a scale.
1748+ final TestPointer mouse = TestPointer (1 , PointerDeviceKind .mouse);
1749+ await tester.sendEventToBinding (mouse.hover (tester.getCenter (find.byType (SizedBox ))));
1750+ await tester.sendEventToBinding (mouse.scroll (const Offset (300 , - 200 )));
1751+ await tester.pump ();
1752+ expect (transformationController.value.getMaxScaleOnAxis (), 2.5 );
1753+ translation = transformationController.value.getTranslation ();
1754+ // Will be translated to maintain centering.
1755+ expect (translation.x, - 150 );
1756+ expect (translation.y, - 150 );
1757+
1758+ // Send a trackpad scroll event, it should cause a pan and no scale.
1759+ final TestPointer trackpad = TestPointer (1 , PointerDeviceKind .trackpad);
1760+ await tester.sendEventToBinding (trackpad.hover (tester.getCenter (find.byType (SizedBox ))));
1761+ await tester.sendEventToBinding (trackpad.scroll (const Offset (100 , - 25 )));
1762+ await tester.pump ();
1763+ expect (transformationController.value.getMaxScaleOnAxis (), 2.5 );
1764+ translation = transformationController.value.getTranslation ();
1765+ expect (translation.x, - 250 );
1766+ expect (translation.y, - 125 );
1767+ });
1768+
17251769 testWidgets ('discrete scale pointer event' , (WidgetTester tester) async {
17261770 final TransformationController transformationController = TransformationController ();
17271771 const double boundaryMargin = 50.0 ;
0 commit comments