ProfilerScrollbar extends JBScrollBar { private void modelChanged() { myUpdating = true; Range dataRangeUs = myTimeline.getDataRange(); Range viewRangeUs = myTimeline.getViewRange(); int dataExtentMs = (int)((dataRangeUs.getLength()) / MS_TO_US); int viewExtentMs = Math.min(dataExtentMs, (int)(viewRangeUs.getLength() / MS_TO_US)); int viewRelativeMinMs = Math.max(0, (int)((viewRangeUs.getMin() - dataRangeUs.getMin()) / MS_TO_US)); setValues(viewRelativeMinMs, viewExtentMs, 0, dataExtentMs); setBlockIncrement(viewExtentMs); myUpdating = false; } ProfilerScrollbar(@NotNull StreamingTimeline timeline,
                           @NotNull JComponent zoomPanComponent); @VisibleForTesting double getZoomWheelDelta(); @VisibleForTesting double getPanWheelDelta(); @VisibleForTesting boolean isScrollable();  }
@Test public void testModelChanged() { assertEquals(0, myScrollbar.getModel().getMinimum()); assertEquals(10, myScrollbar.getModel().getMaximum()); assertEquals(0, myScrollbar.getModel().getValue()); assertEquals(5, myScrollbar.getModel().getExtent()); myTimeline.getViewRange().set(1000, 4000); assertEquals(0, myScrollbar.getModel().getMinimum()); assertEquals(10, myScrollbar.getModel().getMaximum()); assertEquals(1, myScrollbar.getModel().getValue()); assertEquals(3, myScrollbar.getModel().getExtent()); myTimeline.getDataRange().set(0, 20000); assertEquals(0, myScrollbar.getModel().getMinimum()); assertEquals(20, myScrollbar.getModel().getMaximum()); assertEquals(1, myScrollbar.getModel().getValue()); assertEquals(3, myScrollbar.getModel().getExtent()); }