Skip to content

Commit da4fccc

Browse files
Test zoom pan key modifiers
1 parent 8f434d6 commit da4fccc

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib/mpl_toolkits/tests/test_mplot3d.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -1533,14 +1533,22 @@ def convert_lim(dmin, dmax):
15331533
assert z_center != pytest.approx(z_center0)
15341534

15351535

1536-
@pytest.mark.parametrize("tool,button,expected",
1537-
[("zoom", MouseButton.LEFT, # zoom in
1536+
@pytest.mark.parametrize("tool,button,key,expected",
1537+
[("zoom", MouseButton.LEFT, None, # zoom in
15381538
((0.03, 0.61), (0.27, 0.71), (0.32, 0.89))),
1539-
("zoom", MouseButton.RIGHT, # zoom out
1539+
("zoom", MouseButton.LEFT, 'x', # zoom in
1540+
((0.17, 0.73), (0.09, 0.43), (-0.06, 0.06))),
1541+
("zoom", MouseButton.LEFT, 'y', # zoom in
1542+
((-0.23, -0.03), (0.07, 0.37), (0.32, 0.89))),
1543+
("zoom", MouseButton.RIGHT, None, # zoom out
15401544
((0.29, 0.35), (0.44, 0.53), (0.57, 0.64))),
1541-
("pan", MouseButton.LEFT,
1542-
((-0.70, -0.58), (-1.03, -0.91), (-1.27, -1.15)))])
1543-
def test_toolbar_zoom_pan(tool, button, expected):
1545+
("pan", MouseButton.LEFT, None,
1546+
((-0.70, -0.58), (-1.03, -0.91), (-1.27, -1.15))),
1547+
("pan", MouseButton.LEFT, 'x',
1548+
((-0.96, -0.84), (-0.58, -0.46), (-0.06, 0.06))),
1549+
("pan", MouseButton.LEFT, 'y',
1550+
((0.20, 0.32), (-0.51, -0.39), (-1.27, -1.15)))])
1551+
def test_toolbar_zoom_pan(tool, button, key, expected):
15441552
# NOTE: The expected zoom values are rough ballparks of moving in the view
15451553
# to make sure we are getting the right direction of motion.
15461554
# The specific values can and should change if the zoom movement
@@ -1561,9 +1569,9 @@ def test_toolbar_zoom_pan(tool, button, expected):
15611569

15621570
# Set up the mouse movements
15631571
start_event = MouseEvent(
1564-
"button_press_event", fig.canvas, *s0, button)
1572+
"button_press_event", fig.canvas, *s0, button, key=key)
15651573
stop_event = MouseEvent(
1566-
"button_release_event", fig.canvas, *s1, button)
1574+
"button_release_event", fig.canvas, *s1, button, key=key)
15671575

15681576
tb = NavigationToolbar2(fig.canvas)
15691577
if tool == "zoom":

0 commit comments

Comments
 (0)