blob: 3d38b3eed9c5f1e4e17e1238952115a48c945cb4 [file] [log] [blame]
package org.eclipse.nebula.widgets.nattable.core.layer.axis.impl.reorder
import org.eclipse.nebula.widgets.nattable.core.layer.axis.Axis
import org.eclipse.nebula.widgets.nattable.core.layer.axis.impl.AxisImpl
import org.junit.Before
import org.junit.Test
import static org.eclipse.nebula.widgets.nattable.core.layer.AxisTest.*
class ReorderSegmentPositionAxisTest {
Axis underlyingAxis
ReorderAxis reorderAxis
@Before
def void before() {
underlyingAxis = new AxisImpl(4, 100)
reorderAxis = new ReorderAxis(underlyingAxis)
}
@Test
def void baseline() {
testAxis(
"underlyingAxis",
underlyingAxis,
#[ 0L, 1L, 2L, 3L ],
#[ 0.0, 100.0, 200.0, 300.0, 400.0 ]
)
testAxis(
"reorderAxis",
reorderAxis,
#[ 0L, 1L, 2L, 3L ],
#[ 0.0, 100.0, 200.0, 300.0, 400.0 ]
)
}
@Test
def void reorderFromBeginningToMiddle() {
reorderAxis.reorderSegmentPosition(0, 2)
testAxis(
"reorderAxis",
reorderAxis,
#[ 1L, 2L, 0L, 3L ],
#[ 0.0, 100.0, 200.0, 300.0, 400.0 ]
)
}
@Test
def void reorderFromBeginningToEnd() {
reorderAxis.reorderSegmentPosition(0, 3)
testAxis(
"reorderAxis",
reorderAxis,
#[ 1L, 2L, 3L, 0L ],
#[ 0.0, 100.0, 200.0, 300.0, 400.0 ]
)
}
@Test
def void reorderFromMiddleToBeginning() {
reorderAxis.reorderSegmentPosition(2, 0)
testAxis(
"reorderAxis",
reorderAxis,
#[ 2L, 0L, 1L, 3L ],
#[ 0.0, 100.0, 200.0, 300.0, 400.0 ]
)
}
@Test
def void reorderFromMiddleToMiddleLeftToRight() {
reorderAxis.reorderSegmentPosition(1, 2)
testAxis(
"reorderAxis",
reorderAxis,
#[ 0L, 2L, 1L, 3L ],
#[ 0.0, 100.0, 200.0, 300.0, 400.0 ]
)
}
@Test
def void reorderFromMiddleToMiddleRightToLeft() {
reorderAxis.reorderSegmentPosition(2, 1)
testAxis(
"reorderAxis",
reorderAxis,
#[ 0L, 2L, 1L, 3L ],
#[ 0.0, 100.0, 200.0, 300.0, 400.0 ]
)
}
@Test
def void reorderFromMiddleToEnd() {
reorderAxis.reorderSegmentPosition(1, 3)
testAxis(
"reorderAxis",
reorderAxis,
#[ 0L, 2L, 3L, 1L ],
#[ 0.0, 100.0, 200.0, 300.0, 400.0 ]
)
}
@Test
def void reorderFromEndToBeginning() {
reorderAxis.reorderSegmentPosition(3, 0)
testAxis(
"reorderAxis",
reorderAxis,
#[ 3L, 0L, 1L, 2L ],
#[ 0.0, 100.0, 200.0, 300.0, 400.0 ]
)
}
@Test
def void reorderFromEndToMiddle() {
reorderAxis.reorderSegmentPosition(3, 2)
testAxis(
"reorderAxis",
reorderAxis,
#[ 0L, 1L, 3L, 2L ],
#[ 0.0, 100.0, 200.0, 300.0, 400.0 ]
)
}
}