code: def test_mouseDragEventSnap():
      plt = pg.GraphicsView()
      plt.show()
      resizeWindow(plt, 200, 200)
      vb = pg.ViewBox()
      plt.scene().addItem(vb)
      vb.resize(200, 200)
      QtTest.QTest.qWaitForWindowExposed(plt)
      QtTest.QTest.qWait(100)
  
      # A Rectangular roi with scaleSnap enabled
      initial_x = 20
      initial_y = 20
      roi = pg.RectROI(
          (initial_x, initial_y),
          (20, 20),
          scaleSnap=True,
          translateSnap=True,
          snapSize=1.0,
          movable=True,
      )
      vb.addItem(roi)
      app.processEvents()
  
      # Snap size roundtrip
      assert roi.snapSize == 1.0
      roi.snapSize = 0.2
      assert roi.snapSize == 0.2
      roi.snapSize = 1.0
      assert roi.snapSize == 1.0
  
      # Snap position check
      snapped = roi.getSnapPosition(pg.Point(2.5, 3.5), snap=True)
      assert snapped == pg.Point(2.0, 4.0)
  
      # Only drag in y direction
      roi_position = roi.mapToView(pg.Point(initial_x, initial_y))
      mouseDrag(
          plt,
          roi_position,
          roi_position + pg.Point(0, 10),
          QtCore.Qt.MouseButton.LeftButton,
      )
      assert roi.pos() == pg.Point(initial_x, 19)
  
      mouseDrag(
          plt,
          roi_position,
          roi_position + pg.Point(0, 10),
          QtCore.Qt.MouseButton.LeftButton,
      )
      assert roi.pos() == pg.Point(initial_x, 18)
  
      # Only drag in x direction
      mouseDrag(
          plt,
          roi_position,
          roi_position + pg.Point(10, 0),
          QtCore.Qt.MouseButton.LeftButton,
      )
      assert roi.pos() == pg.Point(21, 18)
  
file_path: pyqtgraph/tests/graphicsItems/test_ROI.py
imports: import math
  import platform
  import numpy
  import pytest
  from packaging.version import Version, parse
  import pyqtgraph
  from pyqtgraph.Qt import QtCore, QtGui, QtTest
  from tests.image_testing import assertImageApproved
  from tests.ui_testing import mouseClick, mouseDrag, mouseMove, resizeWindow
label_desc: Use image node_id 5 for calling a global function with example usage: test_mouseDragEventSnap() without return types