blob: 4b79de390d5156c5c5ef5e523b56561932eb91eb [file] [log] [blame]
package org.eclipse.nebula.widgets.nattable.renderer.swt.layer.viewport
import java.math.BigDecimal
import org.eclipse.nebula.widgets.nattable.core.layer.axis.Axis
import org.eclipse.nebula.widgets.nattable.core.layer.axis.impl.AxisImpl
import org.eclipse.nebula.widgets.nattable.core.layer.impl.viewport.ViewportAxis
import org.eclipse.swt.widgets.ScrollBar
import org.junit.Before
import static org.junit.Assert.*
import static org.mockito.Mockito.*
abstract class AbstractScrollBarHandlerTest {
Axis underlyingAxis
protected ScrollBar scrollBar
protected ViewportAxis viewportAxis
protected ScrollBarHandler scrollBarHandler
new(long segmentCount, double defaultSegmentSize) {
this(segmentCount, new BigDecimal(defaultSegmentSize))
}
new(long segmentCount, BigDecimal defaultSegmentSize) {
underlyingAxis = new AxisImpl(segmentCount, defaultSegmentSize)
}
@Before
def void before() {
scrollBar = mock(typeof(ScrollBar))
when(scrollBar.thumb).thenReturn(10)
when(scrollBar.increment).thenReturn(1)
when(scrollBar.pageIncrement).thenReturn(10)
viewportAxis = new ViewportAxis(underlyingAxis, null)
viewportAxis.visiblePixelSize = 500
scrollBarHandler = new ScrollBarHandler(scrollBar, viewportAxis)
assertEquals(BigDecimal::TEN, scrollBarHandler.minThumbSize)
assertEquals(1, scrollBarHandler.minIncrement)
assertEquals(10, scrollBarHandler.minPageIncrement)
// ScrollBarHandler constructor makes calls on scrollBar. Reset scrollBar here so they do not interfere with test expectations.
reset(scrollBar)
}
}