Skip to content

Commit

Permalink
GLRenderer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoopAue committed Apr 5, 2016
1 parent e73b344 commit 6930ea6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class GLRenderer implements Renderer {
private final IntBuffer intBuf16 = BufferUtils.createIntBuffer(16);
protected final RenderContext context = new RenderContext();
private final NativeObjectManager objManager = new NativeObjectManager();
private final GLCapabilities glCaps = new GLCapabilities();
protected final GLCapabilities glCaps = new GLCapabilities();

private FrameBuffer mainFbOverride = null;
private final Statistics statistics = new Statistics();
Expand Down Expand Up @@ -124,7 +124,7 @@ private boolean getBoolean(int en) {

@SuppressWarnings("fallthrough")
public void initialize() {
glCaps.loadCapabilities(gl, gl2, gl3, context);
loadCapabilities();

texUtil.initialize(glCaps.getCaps());

Expand All @@ -151,6 +151,10 @@ public void initialize() {
}
}

protected void loadCapabilities() {
glCaps.loadCapabilities(gl, gl2, gl3, context);
}

public void invalidateState() {
context.reset();
if (gl2 != null) {
Expand Down
23 changes: 16 additions & 7 deletions jme3-core/src/test/java/com/jme3/renderer/opengl/GLCapabilitiesTest.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import java.util.HashSet;

import static org.junit.Assert.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isNull;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
Expand Down Expand Up @@ -98,11 +96,6 @@ public void loadCapabilitiesGL2NotRealVersion() throws Exception {
assertFalse(c_gl2.caps.contains(Caps.OpenGL40));
}

@Test
public void loadCapabilitiesGLSL() throws Exception {

}

@Test
public void loadCapabilitiesGLSLWithRealVersionNumber() throws Exception {
doReturn(150).when(c_gl2).extractVersion(null);
Expand Down Expand Up @@ -217,4 +210,20 @@ public void loadCapabilitiesCommon() {
assertFalse(c_gl2.caps.contains(Caps.CoreProfile));
assertFalse(c_gl2.caps.contains(Caps.BinaryShader));
}

@Test
public void testHas() {
Caps test = Caps.Multisample;
assertFalse(c.has(test));

c.caps.add(test);

assertTrue(c.has(test));
}

@Test
public void testHasNot() {
Caps test = Caps.Multisample;
assertFalse(c.has(test));
}
}
27 changes: 24 additions & 3 deletions jme3-core/src/test/java/com/jme3/renderer/opengl/GLRendererTest.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.jme3.renderer.opengl;

import com.jme3.renderer.Caps;
import com.jme3.renderer.Limits;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;

import java.util.HashSet;
import java.util.EnumSet;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.mockito.Mockito.*;
Expand All @@ -29,4 +28,26 @@ public void setUp() throws Exception {
r = spy(new GLRenderer(gl, glExt, glFbo));
}

@Test
public void testCapabilitiesInitialized() {
assertNotNull(r.getCaps());
}

@Test
public void testInitialize() {
doNothing().when(r).loadCapabilities();

r.initialize();

verify(r, times(1)).loadCapabilities();
}

@Test
public void testGetCaps() {
EnumSet<Caps> expected = r.glCaps.caps;
EnumSet<Caps> actual = r.getCaps();

assertThat(actual, is(expected));
}

}

0 comments on commit 6930ea6

Please sign in to comment.