|
4 | 4 | import com.badlogic.gdx.Gdx;
|
5 | 5 | import com.badlogic.gdx.graphics.GL20;
|
6 | 6 | import de.bitbrain.braingdx.util.GdxUtils;
|
| 7 | +import org.assertj.core.api.iterable.Extractor; |
7 | 8 | import org.junit.Before;
|
8 | 9 | import org.junit.Test;
|
9 | 10 | import org.junit.runner.RunWith;
|
|
28 | 29 | public class RenderPipelineTest {
|
29 | 30 |
|
30 | 31 | @Parameter
|
31 |
| - public RenderPipelineFactory pipelineFactory; |
| 32 | + public MockedCombinedRenderPipelineFactory pipelineFactory; |
32 | 33 |
|
33 |
| - private RenderPipeline pipeline; |
| 34 | + private InternalRenderPipeline pipeline; |
34 | 35 |
|
35 | 36 | @Parameters
|
36 |
| - public static Collection<RenderPipelineFactory[]> getParams() { |
37 |
| - List<RenderPipelineFactory[]> params = new ArrayList<RenderPipelineFactory[]>(); |
| 37 | + public static Collection<MockedCombinedRenderPipelineFactory[]> getParams() { |
| 38 | + List<MockedCombinedRenderPipelineFactory[]> params = new ArrayList<MockedCombinedRenderPipelineFactory[]>(); |
38 | 39 | GdxUtils.mockApplicationContext();
|
39 | 40 | Gdx.gl = mock(GL20.class);
|
40 | 41 | when(Gdx.app.getType()).thenReturn(ApplicationType.Desktop);
|
41 |
| - params.add(new RenderPipelineFactory[]{new MockedCombinedRenderPipelineFactory()}); |
| 42 | + params.add(new MockedCombinedRenderPipelineFactory[]{new MockedCombinedRenderPipelineFactory()}); |
42 | 43 | return params;
|
43 | 44 | }
|
44 | 45 |
|
@@ -155,4 +156,25 @@ public void testRemove_Existing() {
|
155 | 156 | assertThat(pipeline.getPipeIds()).containsExactly("c");
|
156 | 157 | }
|
157 | 158 |
|
| 159 | + @Test |
| 160 | + public void testReplace_Existing() { |
| 161 | + RenderLayer<?> expectedLayerA = mock(RenderLayer.class); |
| 162 | + RenderLayer<?> expectedLayerB = mock(RenderLayer.class); |
| 163 | + RenderLayer<?> expectedLayerC = mock(RenderLayer.class); |
| 164 | + RenderLayer<?> expectedLayerD = mock(RenderLayer.class); |
| 165 | + RenderLayer<?> expectedLayerANew = mock(RenderLayer.class); |
| 166 | + pipeline.put("a", expectedLayerA); |
| 167 | + pipeline.put("b", expectedLayerB); |
| 168 | + pipeline.putAfter("a", "c", expectedLayerC); |
| 169 | + pipeline.put("a", expectedLayerANew); |
| 170 | + pipeline.putBefore("c", "d", expectedLayerD); |
| 171 | + assertThat(pipeline.getPipeIds()).containsExactly("a", "d", "c", "b"); |
| 172 | + assertThat(pipeline.getPipes()).extracting(new Extractor<RenderPipe, RenderLayer<?>>() { |
| 173 | + @Override |
| 174 | + public RenderLayer<?> extract(RenderPipe input) { |
| 175 | + return input.getLayer(); |
| 176 | + } |
| 177 | + }).containsExactly(expectedLayerANew, expectedLayerD, expectedLayerC, expectedLayerB); |
| 178 | + } |
| 179 | + |
158 | 180 | }
|
0 commit comments