forked from jMonkeyEngine/jmonkeyengine
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bab8705
commit 1eaab97
Showing
2 changed files
with
113 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
jme3-core/src/test/java/com/jme3/renderer/opengl/GLRendererTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package com.jme3.renderer.opengl; | ||
|
||
import com.jme3.renderer.Caps; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
|
||
import java.util.HashSet; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.mockito.MockitoAnnotations.initMocks; | ||
import static org.mockito.Mockito.*; | ||
|
||
public class GLRendererTest { | ||
|
||
private GLRenderer r; | ||
@Mock | ||
private GL2 gl; | ||
@Mock | ||
private GLExt glExt; | ||
@Mock | ||
private GLFbo glFbo; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
initMocks(this); | ||
r = spy(new GLRenderer(gl, glExt, glFbo)); | ||
|
||
|
||
doReturn(new HashSet<String>()).when(r).loadExtensions(); | ||
} | ||
|
||
@Test | ||
public void initialize() { | ||
doReturn(310).when(r).extractVersion(null); | ||
|
||
r.initialize(); | ||
|
||
verify(r).loadCapabilities(); | ||
verify(r).loadCapabilitiesGL2(); | ||
} | ||
|
||
|
||
@Test | ||
public void loadCapabilitiesGL2Common() throws Exception { | ||
doReturn(310).when(r).extractVersion(null); | ||
|
||
r.initialize(); | ||
|
||
assertTrue(r.caps.contains(Caps.GLSL110)); | ||
assertTrue(r.caps.contains(Caps.GLSL100)); | ||
|
||
assertNotNull(r.context.initialDrawBuf); | ||
assertNotNull(r.context.initialReadBuf); | ||
} | ||
|
||
@Test | ||
public void loadCapabilitiesGL2oglVer() throws Exception { | ||
doReturn(310).when(r).extractVersion(null); | ||
|
||
r.initialize(); | ||
|
||
assertTrue(r.caps.contains(Caps.OpenGL20)); | ||
assertTrue(r.caps.contains(Caps.OpenGL21)); | ||
assertTrue(r.caps.contains(Caps.OpenGL30)); | ||
assertTrue(r.caps.contains(Caps.OpenGL31)); | ||
assertFalse(r.caps.contains(Caps.OpenGL32)); | ||
assertFalse(r.caps.contains(Caps.OpenGL33)); | ||
assertFalse(r.caps.contains(Caps.OpenGL40)); | ||
} | ||
|
||
@Test | ||
public void loadCapabilitiesGL2glslVer() throws Exception { | ||
doReturn(150).when(r).extractVersion(null); | ||
|
||
r.initialize(); | ||
|
||
assertTrue(r.caps.contains(Caps.GLSL150)); | ||
assertTrue(r.caps.contains(Caps.GLSL140)); | ||
assertTrue(r.caps.contains(Caps.GLSL130)); | ||
assertTrue(r.caps.contains(Caps.GLSL120)); | ||
assertTrue(r.caps.contains(Caps.GLSL110)); | ||
assertTrue(r.caps.contains(Caps.GLSL100)); | ||
assertFalse(r.caps.contains(Caps.GLSL400)); | ||
assertFalse(r.caps.contains(Caps.GLSL330)); | ||
} | ||
|
||
public class TestGLRenderer extends GLRenderer { | ||
|
||
public TestGLRenderer(GL gl, GLExt glext, GLFbo glfbo) { | ||
super(gl, glext, glfbo); | ||
} | ||
/* | ||
@Override | ||
public int extractVersion(String version) { | ||
return 200; | ||
} | ||
*/ | ||
|
||
@Override | ||
protected HashSet<String> loadExtensions() { | ||
return new HashSet<String>(); | ||
} | ||
} | ||
} |