@@ -302,6 +302,35 @@ def test_tool_line_handle():
302302 assert tool_line_handle .positions == positions
303303
304304
305+ @pytest .mark .parametrize ('direction' , ("horizontal" , "vertical" ))
306+ def test_span_selector_bound (direction ):
307+ fig , ax = plt .subplots (1 , 1 )
308+ ax .plot ([10 , 20 ], [10 , 30 ])
309+ ax .figure .canvas .draw ()
310+ x_bound = ax .get_xbound ()
311+ y_bound = ax .get_ybound ()
312+
313+ tool = widgets .SpanSelector (ax , print , direction , interactive = True )
314+ assert ax .get_xbound () == x_bound
315+ assert ax .get_ybound () == y_bound
316+
317+ bound = x_bound if direction == 'horizontal' else y_bound
318+ assert tool ._edge_handles .positions == list (bound )
319+
320+ press_data = [10.5 , 11.5 ]
321+ move_data = [11 , 13 ] # Updating selector is done in onmove
322+ release_data = move_data
323+ do_event (tool , 'press' , xdata = press_data [0 ], ydata = press_data [1 ], button = 1 )
324+ do_event (tool , 'onmove' , xdata = move_data [0 ], ydata = move_data [1 ], button = 1 )
325+
326+ assert ax .get_xbound () == x_bound
327+ assert ax .get_ybound () == y_bound
328+
329+ index = 0 if direction == 'horizontal' else 1
330+ handle_positions = [press_data [index ], release_data [index ]]
331+ assert tool ._edge_handles .positions == handle_positions
332+
333+
305334def check_lasso_selector (** kwargs ):
306335 ax = get_ax ()
307336
0 commit comments