GridLienzoScrollHandler { Integer calculateInternalScrollPanelWidth() { final Double absWidth = scrollBounds().maxBoundX() - scrollBounds().minBoundX(); if (getViewport() != null && scrollPosition().deltaX() != 0) { final Double scaleX = getViewport().getTransform().getScaleX(); final Double width = absWidth * scaleX; return width.intValue(); } return DEFAULT_INTERNAL_SCROLL_WIDTH; } GridLienzoScrollHandler(final GridLienzoPanel panel); void init(); Integer scrollbarWidth(); Integer scrollbarHeight(); void refreshScrollPosition(); void setBounds(final Bounds bounds);  }
@Test public void testCalculateInternalScrollPanelWidthWhenScrollbarXIsEnabled() { final Double maximumBoundX = +20d; final Double minimumBoundX = -20d; final Double zoomLevel = 0.75d; final Double currentScrollPosition = 10d; doReturn(maximumBoundX).when(scrollBounds).maxBoundX(); doReturn(minimumBoundX).when(scrollBounds).minBoundX(); doReturn(zoomLevel).when(transform).getScaleX(); doReturn(currentScrollPosition).when(scrollPosition).deltaX(); final Integer panelWidth = gridLienzoScrollHandler.calculateInternalScrollPanelWidth(); final Integer scaledWidth = (int) ((maximumBoundX - minimumBoundX) * zoomLevel); assertEquals(scaledWidth, panelWidth, 0); }
@Test public void testCalculateInternalScrollPanelWidthWhenScrollbarXIsDisabled() { final Double maximumBoundX = +20d; final Double minimumBoundX = -20d; final Double zoomLevel = 0.75d; final Double currentScrollPosition = 0d; doReturn(maximumBoundX).when(scrollBounds).maxBoundX(); doReturn(minimumBoundX).when(scrollBounds).minBoundX(); doReturn(zoomLevel).when(transform).getScaleX(); doReturn(currentScrollPosition).when(scrollPosition).deltaX(); final Integer panelWidth = gridLienzoScrollHandler.calculateInternalScrollPanelWidth(); assertEquals(DEFAULT_INTERNAL_SCROLL_WIDTH, panelWidth, 0); }