first set of tests for the Geometry. There's 18 tests in total, covering roughly 40% of the total number of methods in the geometry class.
To get all the tests to run, I needed to add EasyMock and some related jar files. This enables me to mock classes other the the one actually being tested to get a better test isolation. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10646 75d07b2b-3a1a-0410-a2c5-0572b91ccdca3.0
parent
96006f1383
commit
9b8060bac2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,63 +1,75 @@ |
||||
libs.android.classpath=\ |
||||
${base}/android/android.jar |
||||
libs.bullet.classpath=\ |
||||
${base}/bullet/jME3-bullet-natives.jar |
||||
libs.CopyLibs.classpath=\ |
||||
${base}/CopyLibs-2/org-netbeans-modules-java-j2seproject-copylibstask.jar |
||||
libs.CopyLibs.displayName=CopyLibs Task |
||||
libs.CopyLibs.prop-version=1.0 |
||||
libs.jbullet.classpath=\ |
||||
${base}/jbullet/jbullet.jar:\ |
||||
${base}/jbullet/stack-alloc.jar:\ |
||||
${base}/jbullet/vecmath.jar |
||||
libs.jheora.classpath=\ |
||||
${base}/jheora/jheora-jst-debug-0.6.0.jar |
||||
libs.jme3-test-data.classpath=\ |
||||
${base}/../test-data/ |
||||
libs.jogg.classpath=\ |
||||
${base}/jogg/j-ogg-oggd.jar:\ |
||||
${base}/jogg/j-ogg-vorbisd.jar |
||||
libs.jogl.classpath=\ |
||||
${base}/jogl/gluegen-rt.jar:\ |
||||
${base}/jogl/jME3-jogl-natives.jar:\ |
||||
${base}/jogl/jogl.jar |
||||
libs.jogl2.classpath=\ |
||||
${base}/jogl/gluegen-rt.jar:\ |
||||
${base}/jogl/joal.jar:\ |
||||
${base}/jogl/jogl-all.jar |
||||
libs.junit_4.classpath=\ |
||||
${base}/junit_4/junit-4.5.jar |
||||
libs.junit_4.javadoc=\ |
||||
${base}/junit_4/junit-4.5-api.zip |
||||
libs.junit_4.src=\ |
||||
${base}/junit_4/junit-4.5-src.jar |
||||
libs.JWSAntTasks.classpath=\ |
||||
${base}/JWSAntTasks/org-netbeans-modules-javawebstart-anttasks.jar |
||||
libs.lwjgl.classpath=\ |
||||
${base}/lwjgl/lwjgl.jar;\ |
||||
${base}/lwjgl/jME3-lwjgl-natives.jar;\ |
||||
${base}/lwjgl/jinput.jar |
||||
libs.lwjgl.src=\ |
||||
${base}/../../Libraries/LWJGL2.7.1/src/ |
||||
libs.niftygui1.3.classpath=\ |
||||
${base}/niftygui/eventbus.jar;\ |
||||
${base}/niftygui/nifty-default-controls.jar;\ |
||||
${base}/niftygui/nifty-examples.jar;\ |
||||
${base}/niftygui/nifty-style-black.jar;\ |
||||
${base}/niftygui/nifty.jar;\ |
||||
${base}/niftygui/jglfont-core.jar;\ |
||||
${base}/niftygui/xmlpull-xpp3.jar |
||||
libs.niftygui1.3.javadoc=\ |
||||
${base}/niftygui/nifty-default-controls-javadoc.jar!//;\ |
||||
${base}/niftygui/nifty-examples-javadoc.jar!// |
||||
libs.openalsoft.classpath=\ |
||||
${base}/openal-soft/jME3-openal-soft-natives-android.jar |
||||
libs.swing-layout.classpath=\ |
||||
${base}/swing-layout/swing-layout-1.0.4.jar |
||||
libs.swing-layout.javadoc=\ |
||||
${base}/swing-layout/swing-layout-1.0.4-doc.zip |
||||
libs.swing-layout.src=\ |
||||
${base}/swing-layout/swing-layout-1.0.4-src.zip |
||||
libs.noise.classpath=\ |
||||
${base}/noise/noise-0.0.1-SNAPSHOT.jar |
||||
|
||||
libs.android.classpath=\ |
||||
${base}/android/android.jar |
||||
libs.bullet.classpath=\ |
||||
${base}/bullet/jME3-bullet-natives.jar |
||||
libs.CopyLibs.classpath=\ |
||||
${base}/CopyLibs-2/org-netbeans-modules-java-j2seproject-copylibstask.jar |
||||
libs.CopyLibs.displayName=CopyLibs Task |
||||
libs.CopyLibs.prop-version=1.0 |
||||
libs.EasyMock.classpath=\ |
||||
${base}/EasyMock/easymock-3.1.jar:\ |
||||
${base}/EasyMock/objenesis-1.3.jar:\ |
||||
${base}/EasyMock/cglib-nodep-2.2.3.jar |
||||
libs.EasyMock.displayName=EasyMock |
||||
libs.EasyMock.javadoc=\ |
||||
${base}/EasyMock/easymock-3.1-javadoc.jar!//:\ |
||||
${base}/EasyMock/objenesis-1.3-javadoc.jar!// |
||||
libs.EasyMock.src=\ |
||||
${base}/EasyMock/easymock-3.1-sources.jar!//:\ |
||||
${base}/EasyMock/objenesis-1.3-sources.jar!//:\ |
||||
${base}/EasyMock/cglib-src-2.2.3.jar!/src/test/ |
||||
libs.jbullet.classpath=\ |
||||
${base}/jbullet/jbullet.jar:\ |
||||
${base}/jbullet/stack-alloc.jar:\ |
||||
${base}/jbullet/vecmath.jar |
||||
libs.jheora.classpath=\ |
||||
${base}/jheora/jheora-jst-debug-0.6.0.jar |
||||
libs.jme3-test-data.classpath=\ |
||||
${base}/../test-data/ |
||||
libs.jogg.classpath=\ |
||||
${base}/jogg/j-ogg-oggd.jar:\ |
||||
${base}/jogg/j-ogg-vorbisd.jar |
||||
libs.jogl.classpath=\ |
||||
${base}/jogl/gluegen-rt.jar:\ |
||||
${base}/jogl/jME3-jogl-natives.jar:\ |
||||
${base}/jogl/jogl.jar |
||||
libs.jogl2.classpath=\ |
||||
${base}/jogl/gluegen-rt.jar:\ |
||||
${base}/jogl/joal.jar:\ |
||||
${base}/jogl/jogl-all.jar |
||||
libs.junit_4.classpath=\ |
||||
${base}/junit_4/junit-4.5.jar |
||||
libs.junit_4.javadoc=\ |
||||
${base}/junit_4/junit-4.5-api.zip |
||||
libs.junit_4.src=\ |
||||
${base}/junit_4/junit-4.5-src.jar |
||||
libs.JWSAntTasks.classpath=\ |
||||
${base}/JWSAntTasks/org-netbeans-modules-javawebstart-anttasks.jar |
||||
libs.lwjgl.classpath=\ |
||||
${base}/lwjgl/lwjgl.jar;\ |
||||
${base}/lwjgl/jME3-lwjgl-natives.jar;\ |
||||
${base}/lwjgl/jinput.jar |
||||
libs.lwjgl.src=\ |
||||
${base}/../../Libraries/LWJGL2.7.1/src/ |
||||
libs.niftygui1.3.classpath=\ |
||||
${base}/niftygui/eventbus.jar;\ |
||||
${base}/niftygui/nifty-default-controls.jar;\ |
||||
${base}/niftygui/nifty-examples.jar;\ |
||||
${base}/niftygui/nifty-style-black.jar;\ |
||||
${base}/niftygui/nifty.jar;\ |
||||
${base}/niftygui/jglfont-core.jar;\ |
||||
${base}/niftygui/xmlpull-xpp3.jar |
||||
libs.niftygui1.3.javadoc=\ |
||||
${base}/niftygui/nifty-default-controls-javadoc.jar!//;\ |
||||
${base}/niftygui/nifty-examples-javadoc.jar!// |
||||
libs.openalsoft.classpath=\ |
||||
${base}/openal-soft/jME3-openal-soft-natives-android.jar |
||||
libs.swing-layout.classpath=\ |
||||
${base}/swing-layout/swing-layout-1.0.4.jar |
||||
libs.swing-layout.javadoc=\ |
||||
${base}/swing-layout/swing-layout-1.0.4-doc.zip |
||||
libs.swing-layout.src=\ |
||||
${base}/swing-layout/swing-layout-1.0.4-src.zip |
||||
libs.noise.classpath=\ |
||||
${base}/noise/noise-0.0.1-SNAPSHOT.jar |
||||
|
||||
|
@ -0,0 +1,178 @@ |
||||
package com.jme3.scene; |
||||
|
||||
import com.jme3.bounding.BoundingVolume; |
||||
import com.jme3.material.Material; |
||||
import com.jme3.math.Quaternion; |
||||
import com.jme3.math.Transform; |
||||
import com.jme3.math.Vector3f; |
||||
import org.junit.Test; |
||||
import static org.easymock.EasyMock.*; |
||||
import static org.junit.Assert.*; |
||||
|
||||
public class GeometryTest { |
||||
|
||||
@Test |
||||
public void testConstructorNameNull() { |
||||
Geometry geom = new Geometry(null); |
||||
assertNull(geom.getName()); |
||||
} |
||||
|
||||
@Test |
||||
public void testConstructorName() { |
||||
Geometry geom = new Geometry("TestGeometry"); |
||||
assertEquals("TestGeometry", geom.getName()); |
||||
} |
||||
|
||||
@Test(expected = NullPointerException.class) |
||||
public void testConstructorNameMeshNullMesh() { |
||||
Geometry geom = new Geometry("TestGeometry", null); |
||||
} |
||||
|
||||
@Test |
||||
public void testConstructorNameMesh() { |
||||
Mesh m = new Mesh(); |
||||
Geometry geom = new Geometry("TestGeometry", m); |
||||
assertEquals("TestGeometry", geom.getName()); |
||||
assertEquals(m, geom.getMesh()); |
||||
} |
||||
|
||||
@Test(expected = IllegalStateException.class) |
||||
public void testSetLodLevelMeshLodZero() { |
||||
Mesh m = new Mesh(); |
||||
Geometry geom = new Geometry("TestGeometry", m); |
||||
geom.setLodLevel(0); |
||||
} |
||||
|
||||
@Test(expected = IllegalArgumentException.class) |
||||
public void testSetLodLevelLodLessZero() { |
||||
Mesh m = new Mesh(); |
||||
VertexBuffer lodLevels = new VertexBuffer(VertexBuffer.Type.Size); |
||||
m.setLodLevels(new VertexBuffer[]{lodLevels}); |
||||
Geometry geom = new Geometry("TestGeometry", m); |
||||
geom.setLodLevel(-1); |
||||
} |
||||
|
||||
@Test(expected = IllegalArgumentException.class) |
||||
public void testSetLodLevelLodGreaterMeshLod() { |
||||
Mesh m = new Mesh(); |
||||
VertexBuffer lodLevel = new VertexBuffer(VertexBuffer.Type.Size); |
||||
m.setLodLevels(new VertexBuffer[]{lodLevel}); |
||||
Geometry geom = new Geometry("TestGeometry", m); |
||||
geom.setLodLevel(5); |
||||
} |
||||
|
||||
@Test |
||||
public void testSetLodLevel() { |
||||
Mesh m = new Mesh(); |
||||
VertexBuffer lodLevel = new VertexBuffer(VertexBuffer.Type.Size); |
||||
m.setLodLevels(new VertexBuffer[]{lodLevel, lodLevel, lodLevel}); |
||||
Geometry geom = new Geometry("TestGeometry", m); |
||||
geom.setLodLevel(2); |
||||
assertEquals(2, geom.getLodLevel()); |
||||
} |
||||
|
||||
@Test(expected = IllegalArgumentException.class) |
||||
public void testSetMeshNull() { |
||||
Geometry geom = new Geometry(); |
||||
geom.setMesh(null); |
||||
} |
||||
|
||||
@Test(expected = UnsupportedOperationException.class) |
||||
public void testSetMeshBatched() { |
||||
Mesh m = new Mesh(); |
||||
Geometry geom = new Geometry(); |
||||
BatchNode bn = new BatchNode(); |
||||
geom.batch(bn, 1); |
||||
geom.setMesh(m); |
||||
} |
||||
|
||||
@Test |
||||
public void testSetMesh() { |
||||
Mesh m = new Mesh(); |
||||
Geometry geom = new Geometry(); |
||||
geom.setMesh(m); |
||||
assertEquals(m, geom.getMesh()); |
||||
} |
||||
|
||||
@Test(expected = UnsupportedOperationException.class) |
||||
public void testSetMaterialBatched() { |
||||
Material m = new Material(); |
||||
Geometry geom = new Geometry(); |
||||
BatchNode bn = new BatchNode(); |
||||
geom.batch(bn, 1); |
||||
geom.setMaterial(m); |
||||
} |
||||
|
||||
@Test |
||||
public void testSetMaterial() { |
||||
Material m = new Material(); |
||||
Geometry geom = new Geometry(); |
||||
geom.setMaterial(m); |
||||
assertEquals(m, geom.getMaterial()); |
||||
} |
||||
|
||||
@Test |
||||
public void testUpdateModelBound() { |
||||
Mesh mockedMesh = createMock(Mesh.class); |
||||
mockedMesh.updateBound(); |
||||
expectLastCall(); |
||||
|
||||
replay(mockedMesh); |
||||
Geometry geom = new Geometry(); |
||||
geom.setMesh(mockedMesh); |
||||
geom.updateModelBound(); |
||||
|
||||
verify(mockedMesh); |
||||
} |
||||
|
||||
@Test(expected = NullPointerException.class) |
||||
public void testUpdateWorldBoundNoMesh() { |
||||
Geometry geom = new Geometry(); |
||||
geom.updateWorldBound(); |
||||
} |
||||
|
||||
@Test |
||||
public void testUpdateWorlBoundNoBoundingVolume() { |
||||
Mesh mockedMesh = createMock(Mesh.class); |
||||
expect(mockedMesh.getBound()).andReturn(null); |
||||
replay(mockedMesh); |
||||
|
||||
Geometry geom = new Geometry(); |
||||
geom.setMesh(mockedMesh); |
||||
geom.updateWorldBound(); |
||||
|
||||
verify(mockedMesh); |
||||
} |
||||
|
||||
@Test |
||||
public void testUpdateWorlBoundIgnoreTransform() { |
||||
Mesh mockedMesh = createMock(Mesh.class); |
||||
BoundingVolume mockedBoundingVolume = createMock(BoundingVolume.class); |
||||
expect(mockedMesh.getBound()).andReturn(mockedBoundingVolume).times(2); |
||||
expect(mockedBoundingVolume.clone(null)).andReturn(null); |
||||
replay(mockedMesh, mockedBoundingVolume); |
||||
|
||||
Geometry geom = new Geometry(); |
||||
geom.setMesh(mockedMesh); |
||||
geom.setIgnoreTransform(true); |
||||
geom.updateWorldBound(); |
||||
|
||||
verify(mockedMesh, mockedBoundingVolume); |
||||
} |
||||
|
||||
@Test |
||||
public void testUpdateWorlBoundTransform() { |
||||
Mesh mockedMesh = createMock(Mesh.class); |
||||
BoundingVolume mockedBoundingVolume = createMock(BoundingVolume.class); |
||||
expect(mockedMesh.getBound()).andReturn(mockedBoundingVolume).times(2); |
||||
expect(mockedBoundingVolume.transform(anyObject(Transform.class), same((BoundingVolume) null))).andReturn(null); |
||||
replay(mockedMesh, mockedBoundingVolume); |
||||
|
||||
Geometry geom = new Geometry(); |
||||
geom.setMesh(mockedMesh); |
||||
geom.setIgnoreTransform(false); |
||||
geom.updateWorldBound(); |
||||
|
||||
verify(mockedMesh, mockedBoundingVolume); |
||||
} |
||||
} |
Loading…
Reference in new issue