CompositeLayerPainterTest
diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/CellLayerPainterTest.xtend b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/CellLayerPainterTest.xtend
index 677ae50..6a81a53 100644
--- a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/CellLayerPainterTest.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/CellLayerPainterTest.xtend
@@ -3,10 +3,10 @@
import org.eclipse.nebula.widgets.nattable.core.geometry.PixelRectangle
import org.eclipse.nebula.widgets.nattable.core.graphics.GraphicsContext
import org.eclipse.nebula.widgets.nattable.core.layer.axis.impl.AxisImpl
-import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
+import org.mockito.Spy
import org.mockito.runners.MockitoJUnitRunner
import static org.junit.Assert.*
@@ -18,26 +18,20 @@
@RunWith(typeof(MockitoJUnitRunner))
class CellLayerPainterTest {
- DummyLayer testLayer
- @Mock GraphicsContext testGC
- CellLayerPainter layerPainter
-
- @Before
- def void before() {
- // 100 100 100 100
- // +-----+-----+-----+-----+
- // | 0,0 | 1,0 | 2,0 | 3,0 | 20
- // +-----+-----+-----+-----+
- // | 0,1 | 1,1 | 2,1 | 3,1 | 20
- // +-----+-----+-----+-----+
- // | 0,2 | 1,2 | 2,2 | 3,2 | 20
- // +-----+-----+-----+-----+
- testLayer = spy(new DummyLayer(
+ // 100 100 100 100
+ // +-----+-----+-----+-----+
+ // | 0,0 | 1,0 | 2,0 | 3,0 | 20
+ // +-----+-----+-----+-----+
+ // | 0,1 | 1,1 | 2,1 | 3,1 | 20
+ // +-----+-----+-----+-----+
+ // | 0,2 | 1,2 | 2,2 | 3,2 | 20
+ // +-----+-----+-----+-----+
+ @Spy DummyLayer testLayer = new DummyLayer(
new AxisImpl(4, 100),
new AxisImpl(3, 20)
- ))
- layerPainter = new CellLayerPainter
- }
+ )
+ CellLayerPainter layerPainter = new CellLayerPainter
+ @Mock GraphicsContext testGC
@Test
def void baseline() {
diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/GridLineCellLayerPainterTest.xtend b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/GridLineCellLayerPainterTest.xtend
index 079b64f..294716d 100644
--- a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/GridLineCellLayerPainterTest.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/GridLineCellLayerPainterTest.xtend
@@ -3,7 +3,6 @@
import org.eclipse.nebula.widgets.nattable.core.geometry.PixelRectangle
import org.eclipse.nebula.widgets.nattable.core.graphics.GraphicsContext
import org.eclipse.nebula.widgets.nattable.core.layer.axis.impl.AxisImpl
-import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
@@ -17,26 +16,20 @@
@RunWith(typeof(MockitoJUnitRunner))
class GridLineCellLayerPainterTest {
- DummyLayer testLayer
- @Mock GraphicsContext testGC
- GridLineCellLayerPainter layerPainter
-
- @Before
- def void before() {
- // 100 100 100 100
- // +-----+-----+-----+-----+
- // | 0,0 | 1,0 | 2,0 | 3,0 | 20
- // +-----+-----+-----+-----+
- // | 0,1 | 1,1 | 2,1 | 3,1 | 20
- // +-----+-----+-----+-----+
- // | 0,2 | 1,2 | 2,2 | 3,2 | 20
- // +-----+-----+-----+-----+
- testLayer = spy(new DummyLayer(
+ // 100 100 100 100
+ // +-----+-----+-----+-----+
+ // | 0,0 | 1,0 | 2,0 | 3,0 | 20
+ // +-----+-----+-----+-----+
+ // | 0,1 | 1,1 | 2,1 | 3,1 | 20
+ // +-----+-----+-----+-----+
+ // | 0,2 | 1,2 | 2,2 | 3,2 | 20
+ // +-----+-----+-----+-----+
+ DummyLayer testLayer = new DummyLayer(
new AxisImpl(4, 100),
new AxisImpl(3, 20)
- ))
- layerPainter = new GridLineCellLayerPainter
- }
+ )
+ GridLineCellLayerPainter layerPainter = new GridLineCellLayerPainter
+ @Mock GraphicsContext testGC
@Test
def void paintEverything() {
diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/composite/CompositeLayerPainterTest.xtend b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/composite/CompositeLayerPainterTest.xtend
new file mode 100644
index 0000000..55180a9
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/composite/CompositeLayerPainterTest.xtend
@@ -0,0 +1,84 @@
+package org.eclipse.nebula.widgets.nattable.core.layer.impl.composite
+
+import org.eclipse.nebula.widgets.nattable.core.geometry.PixelArea
+import org.eclipse.nebula.widgets.nattable.core.graphics.GraphicsContext
+import org.eclipse.nebula.widgets.nattable.core.graphics.PainterFactory
+import org.eclipse.nebula.widgets.nattable.core.layer.LayerPainter
+import org.eclipse.nebula.widgets.nattable.core.layer.axis.impl.AxisImpl
+import org.eclipse.nebula.widgets.nattable.core.layer.impl.DimensionallyDependentLayer
+import org.eclipse.nebula.widgets.nattable.core.layer.impl.DummyLayer
+import org.eclipse.nebula.widgets.nattable.core.layer.impl.LayerDataAccessorImpl
+import org.eclipse.nebula.widgets.nattable.core.layer.impl.header.ColumnHeaderLayer
+import org.eclipse.nebula.widgets.nattable.core.layer.impl.header.RowHeaderLayer
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.InjectMocks
+import org.mockito.Mock
+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.LayerInvariants.*
+
+@RunWith(typeof(MockitoJUnitRunner))
+class CompositeLayerPainterTest {
+
+ // 20 100 100 100 100
+ // +--+-----+-----+-----+-----+
+ // | | | | | | 20
+ // +--+-----+-----+-----+-----+
+ // | | 0,0 | 1,0 | 2,0 | 3,0 | 20
+ // +--+-----+-----+-----+-----+
+ // | | 0,1 | 1,1 | 2,1 | 3,1 | 20
+ // +--+-----+-----+-----+-----+
+ // | | 0,2 | 1,2 | 2,2 | 3,2 | 20
+ // +--+-----+-----+-----+-----+
+ DummyLayer bodyLayer = new DummyLayer(
+ new AxisImpl(4, 100), // Horizontal axis
+ new AxisImpl(3, 20) // Vertical axis
+ )
+ ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(bodyLayer.horizontalAxis, new LayerDataAccessorImpl([ layer, columnId, rowId | columnId ]))
+ RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(bodyLayer.verticalAxis, new LayerDataAccessorImpl([ layer, columnId, rowId | rowId ]))
+ DimensionallyDependentLayer cornerLayer = new DimensionallyDependentLayer(rowHeaderLayer.horizontalAxis, columnHeaderLayer.verticalAxis, new LayerDataAccessorImpl([ layer, columnId, rowId | "" ]))
+ CompositeLayer compositeLayer = new CompositeLayer => [
+ addRow(cornerLayer, columnHeaderLayer)
+ addRow(rowHeaderLayer, bodyLayer)
+ ]
+
+ @Mock LayerPainter<DummyLayer> bodyLayerPainter
+ @Mock LayerPainter<ColumnHeaderLayer> columnHeaderLayerPainter
+ @Mock LayerPainter<RowHeaderLayer> rowHeaderLayerPainter
+ @Mock LayerPainter<DimensionallyDependentLayer> cornerLayerPainter
+
+ @Mock PainterFactory painterFactory
+
+ @InjectMocks CompositeLayerPainter layerPainter = new CompositeLayerPainter
+ @Mock GraphicsContext testGC
+
+ @Before
+ def void before() {
+ when(painterFactory.getLayerPainter(bodyLayer)).thenReturn(bodyLayerPainter)
+ when(painterFactory.getLayerPainter(columnHeaderLayer)).thenReturn(columnHeaderLayerPainter)
+ when(painterFactory.getLayerPainter(rowHeaderLayer)).thenReturn(rowHeaderLayerPainter)
+ when(painterFactory.getLayerPainter(cornerLayer)).thenReturn(cornerLayerPainter)
+ }
+
+ @Test
+ def void baseline() {
+ assertEquals(5, compositeLayer.columnCount)
+ assertEquals(4, compositeLayer.rowCount)
+ assertEquals(new PixelArea(420, 80), compositeLayer.pixelArea)
+ }
+
+ @Test
+ def void childPixelArea() {
+ layerPainter.paintLayer(compositeLayer, compositeLayer.pixelArea, testGC)
+ verify(cornerLayerPainter).paintLayer(cornerLayer, new PixelArea(20, 20), testGC)
+ verify(columnHeaderLayerPainter).paintLayer(columnHeaderLayer, new PixelArea(400, 20), testGC)
+ verify(rowHeaderLayerPainter).paintLayer(rowHeaderLayer, new PixelArea(20, 60), testGC)
+ verify(bodyLayerPainter).paintLayer(bodyLayer, new PixelArea(400, 60), testGC)
+ }
+
+}
\ No newline at end of file