blob: f908fd2bb55b865e201418dd5f900c508a6c0d09 [file] [log] [blame]
package org.eclipse.nebula.widgets.nattable.renderer.swt.layer.viewport
import java.math.BigDecimal
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.runners.MockitoJUnitRunner
import static org.junit.Assert.*
import static org.mockito.Mockito.*
import static extension org.eclipse.nebula.widgets.nattable.core.layer.axis.AxisInvariants.*
import java.math.MathContext
@RunWith(typeof(MockitoJUnitRunner))
class ScrollBarHandlerRangeLargerThanIntTest extends AbstractScrollBarHandlerTest {
val static MILLION = 1000L * 1000
val static BILLION = 1000L * MILLION
val static TRILLION = 1000L * BILLION
val static QUADRILLION = 1000L * TRILLION
//
new() {
super(1 * QUADRILLION, 200)
}
@Test
def void viewportAtBeginning() {
scrollBarHandler.recalculateScrollBarSize
verify(scrollBar).maximum = ScrollBarHandler::MAX_SCROLL_SIZE
verify(scrollBar).thumb = 10
verify(scrollBar).increment = 1
verify(scrollBar).pageIncrement = 10
verify(scrollBar).selection = 0
}
@Test
def void viewportAtEnd() {
viewportAxis.pixelOrigin = new BigDecimal(200 * QUADRILLION - 1)
scrollBarHandler.recalculateScrollBarSize
verify(scrollBar).maximum = ScrollBarHandler::MAX_SCROLL_SIZE
verify(scrollBar).thumb = 10
verify(scrollBar).increment = 1
verify(scrollBar).pageIncrement = 10
verify(scrollBar).selection = ScrollBarHandler::MAX_SCROLL_SIZE - 10
}
@Test
def void moveViewportABit() {
when(scrollBar.selection).thenReturn(1)
scrollBarHandler.updateViewportOrigin
val mathContext = new MathContext(15)
assertEquals(new BigDecimal((1.0 / (ScrollBarHandler::MAX_SCROLL_SIZE - 10)) * (200 * QUADRILLION - 500)).round(mathContext), viewportAxis.pixelOrigin.round(mathContext))
}
@Test
def void moveViewportToEnd() {
when(scrollBar.selection).thenReturn(Integer::MAX_VALUE - 10)
scrollBarHandler.updateViewportOrigin
assertTrue('''viewport origin «viewportAxis.pixelOrigin» + visible pixel size «viewportAxis.visiblePixelSize» should be >= underlying axis pixel size «viewportAxis.underlyingAxis.pixelSize»''', viewportAxis.pixelOrigin + viewportAxis.visiblePixelSize >= new BigDecimal(200 * QUADRILLION))
}
}