def test_zoom_out(self, single_plot_page) -> None: plot = _make_plot() page = single_plot_page(plot) # First check that scrolling has no effect before the tool is activated page.driver.execute_script(SCROLL(200)) page.click_custom_action() results = page.results assert results['xrstart'] == 0 assert results['xrend'] == 1 assert results['yrstart'] == 0 assert results['yrend'] == 1 # Next check that scrolling adjusts the range after the tool is activated button = page.get_toolbar_button('wheel-zoom') button.click() page.driver.execute_script(SCROLL(200)) page.click_custom_action() results = page.results assert results['xrstart'] < 0 assert results['xrend'] > 1 assert results['yrstart'] < 0 assert results['yrend'] > 1 assert page.has_no_console_errors()
def test_ranges_update(self, single_plot_page) -> None: source = ColumnDataSource(dict(x=[1, 2], y=[1, 1])) plot = Plot(plot_height=400, plot_width=400, x_range=Range1d(0, 1), y_range=Range1d(0, 1), min_border=0) plot.add_glyph(source, Rect(x='x', y='y', width=0.9, height=0.9)) plot.add_tools(WheelZoomTool()) code = RECORD("event_name", "cb_obj.event_name", final=False) + \ RECORD("x0", "cb_obj.x0", final=False) + \ RECORD("x1", "cb_obj.x1", final=False) + \ RECORD("y0", "cb_obj.y0", final=False) + \ RECORD("y1", "cb_obj.y1") plot.js_on_event(RangesUpdate, CustomJS(code=code)) plot.add_tools(CustomAction(callback=CustomJS(code=""))) plot.toolbar_sticky = False page = single_plot_page(plot) button = page.get_toolbar_button('wheel-zoom') button.click() page.driver.execute_script(SCROLL(-200)) page.click_custom_action() results = page.results assert results['event_name'] == "rangesupdate" assert results['x0'] > 0 assert results['x1'] < 1 assert results['y0'] > 0 assert results['y1'] < 1 assert page.has_no_console_errors()
def test_ywheel_pan(self, single_plot_page: SinglePlotPage) -> None: plot = _make_plot("height") page = single_plot_page(plot) # First check that scrolling has no effect before the tool is activated page.driver.execute_script(SCROLL(-200)) page.eval_custom_action() results = page.results assert results['xrstart'] == 0 assert results['xrend'] == 1 assert results['yrstart'] == 0 assert results['yrend'] == 1 # Next check that scrolling adjusts the y range after the tool is activated button = page.get_toolbar_button('wheel-pan') button.click() page.driver.execute_script(SCROLL(-200)) page.eval_custom_action() results = page.results assert results['xrstart'] == 0 assert results['xrend'] == 1 assert results['yrstart'] > 0 assert results['yrend'] > 1 page.driver.execute_script(SCROLL(400)) page.eval_custom_action() results = page.results assert results['xrstart'] == 0 assert results['xrend'] == 1 assert results['yrstart'] < 0 assert results['yrend'] < 1 assert page.has_no_console_errors()