ProfilerScrollbar extends JBScrollBar { @VisibleForTesting public double getZoomWheelDelta() { return myTimeline.getViewRange().getLength() * VIEW_ZOOM_PER_MOUSEWHEEL_FACTOR; } ProfilerScrollbar(@NotNull StreamingTimeline timeline,
                           @NotNull JComponent zoomPanComponent); @VisibleForTesting double getZoomWheelDelta(); @VisibleForTesting double getPanWheelDelta(); @VisibleForTesting boolean isScrollable();  }
@Test public void testZoom() { double delta = myScrollbar.getZoomWheelDelta(); myUi.keyboard.press(FakeKeyboard.MENU_KEY); myUi.mouse.wheel(50, 50, -1); myTimer.tick(TimeUnit.SECONDS.toNanos(5)); assertEquals(0 + delta * 0.5, myTimeline.getViewRange().getMin(), EPSILON); assertEquals(5000 - delta * 0.5, myTimeline.getViewRange().getMax(), EPSILON); double delta2 = myScrollbar.getZoomWheelDelta() * 2; myUi.mouse.wheel(50, 50, -2); myTimer.tick(TimeUnit.SECONDS.toNanos(5)); assertEquals(0 + (delta + delta2) * 0.5, myTimeline.getViewRange().getMin(), EPSILON); assertEquals(5000 - (delta + delta2) * 0.5, myTimeline.getViewRange().getMax(), EPSILON); double delta3 = myScrollbar.getZoomWheelDelta(); myUi.mouse.wheel(50, 50, 1); myTimer.tick(TimeUnit.SECONDS.toNanos(5)); assertEquals(0 + (delta + delta2 - delta3) * 0.5, myTimeline.getViewRange().getMin(), EPSILON); assertEquals(5000 - (delta + delta2 - delta3) * 0.5, myTimeline.getViewRange().getMax(), EPSILON); }
@Test public void testScrollableAtMaxRange() { myTimeline.getViewRange().set(0, 10000); double delta = myScrollbar.getZoomWheelDelta(); myUi.keyboard.press(FakeKeyboard.MENU_KEY); myUi.mouse.wheel(50, 50, 1); myTimer.tick(TimeUnit.SECONDS.toNanos(5)); assertEquals(0, myTimeline.getViewRange().getMin(), EPSILON); assertEquals(10000, myTimeline.getViewRange().getMax(), EPSILON); myUi.mouse.wheel(50, 50, -1); myTimer.tick(TimeUnit.SECONDS.toNanos(5)); assertEquals(0 + delta * 0.5, myTimeline.getViewRange().getMin(), EPSILON); assertEquals(10000 - delta * 0.5, myTimeline.getViewRange().getMax(), EPSILON); }