Skip to content

Commit

Permalink
Tests for texture and beginning of refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinfjola authored and JoopAue committed Mar 24, 2016
1 parent d770adb commit cab36b5
Show file tree
Hide file tree
Showing 18 changed files with 202 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@
/sdk/ant-jme/nbproject/private/
/sdk/nbi/stub/ext/engine/nbproject/private/
/sdk/nbi/stub/ext/components/products/jdk/nbproject/private/
/sdk/nbi/stub/ext/components/products/blender/nbproject/private/
/sdk/nbi/stub/ext/components/products/helloworld/nbproject/private/
/sdk/nbi/stub/ext/components/products/blender/nbproject/private//sdk/nbi/stub/ext/components/products/helloworld/nbproject/private/
/sdk/BasicGameTemplate/nbproject/private/
/sdk/nbi/stub/ext/components/products/jdk/build/
/sdk/nbi/stub/ext/components/products/jdk/dist/
/sdk/jme3-dark-laf/nbproject/private/

jme3-lwjgl3/build/

### Intellij ###
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*___Generated_by_IDEA___*/

package com.jme3.android;

/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
public final static boolean DEBUG = Boolean.parseBoolean(null);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*___Generated_by_IDEA___*/

package com.jme3.android;

/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}
7 changes: 7 additions & 0 deletions jme3-android-examples/src/main/gen/com/jme3/android/R.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*___Generated_by_IDEA___*/

package com.jme3.android;

/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*___Generated_by_IDEA___*/

package com.jme3.androiddemo;

/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
public final static boolean DEBUG = Boolean.parseBoolean(null);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*___Generated_by_IDEA___*/

package com.jme3.androiddemo;

/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*___Generated_by_IDEA___*/

package com.jme3.androiddemo;

/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}
22 changes: 21 additions & 1 deletion jme3-core/src/main/java/com/jme3/texture/Texture.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ public enum ShadowCompareMode {
private ShadowCompareMode shadowCompareMode = ShadowCompareMode.Off;
private int anisotropicFilter;

protected WrapMode wrapS = WrapMode.EdgeClamp;
protected WrapMode wrapT = WrapMode.EdgeClamp;

/**
* @return A cloned Texture object.
*/
Expand Down Expand Up @@ -450,7 +453,24 @@ public Image getImage() {
* @throws IllegalArgumentException
* if axis or mode are null or invalid for this type of texture
*/
public abstract void setWrap(WrapAxis axis, WrapMode mode);
public void setWrap(WrapAxis axis, WrapMode mode){
if (mode == null) {
throw new IllegalArgumentException("mode can not be null.");
} else if (axis == null) {
throw new IllegalArgumentException("axis can not be null.");
}

switch (axis) {
case S:
this.wrapS = mode;
break;
case T:
this.wrapT = mode;
break;
default:
throw new IllegalArgumentException("Not applicable for 2D textures");
}
}

/**
* <code>setWrap</code> sets the wrap mode of this texture for all axis.
Expand Down
9 changes: 1 addition & 8 deletions jme3-core/src/main/java/com/jme3/texture/Texture2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
*/
public class Texture2D extends Texture {

private WrapMode wrapS = WrapMode.EdgeClamp;
private WrapMode wrapT = WrapMode.EdgeClamp;

/**
* Creates a new two-dimensional texture with default attributes.
*/
Expand Down Expand Up @@ -122,11 +119,7 @@ public Texture createSimpleClone(Texture rVal) {
* if axis or mode are null
*/
public void setWrap(WrapAxis axis, WrapMode mode) {
if (mode == null) {
throw new IllegalArgumentException("mode can not be null.");
} else if (axis == null) {
throw new IllegalArgumentException("axis can not be null.");
}
super.setWrap(axis, mode);
switch (axis) {
case S:
this.wrapS = mode;
Expand Down
12 changes: 3 additions & 9 deletions jme3-core/src/main/java/com/jme3/texture/Texture3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
*/
public class Texture3D extends Texture {

private WrapMode wrapS = WrapMode.EdgeClamp;
private WrapMode wrapT = WrapMode.EdgeClamp;
private WrapMode wrapR = WrapMode.EdgeClamp;

/**
Expand Down Expand Up @@ -107,8 +105,8 @@ public Texture createSimpleClone() {

@Override
public Texture createSimpleClone(Texture rVal) {
rVal.setWrap(WrapAxis.S, wrapS);
rVal.setWrap(WrapAxis.T, wrapT);
rVal.setWrap(WrapAxis.S, this.wrapS);
rVal.setWrap(WrapAxis.T, this.wrapT);
rVal.setWrap(WrapAxis.R, wrapR);
return super.createSimpleClone(rVal);
}
Expand All @@ -125,11 +123,7 @@ public Texture createSimpleClone(Texture rVal) {
* if axis or mode are null
*/
public void setWrap(WrapAxis axis, WrapMode mode) {
if (mode == null) {
throw new IllegalArgumentException("mode can not be null.");
} else if (axis == null) {
throw new IllegalArgumentException("axis can not be null.");
}
super.setWrap(axis, mode);
switch (axis) {
case S:
this.wrapS = mode;
Expand Down
8 changes: 1 addition & 7 deletions jme3-core/src/main/java/com/jme3/texture/TextureArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
*/
public class TextureArray extends Texture {

private WrapMode wrapS = WrapMode.EdgeClamp;
private WrapMode wrapT = WrapMode.EdgeClamp;

/**
* Construct a TextureArray
Expand Down Expand Up @@ -127,11 +125,7 @@ public WrapMode getWrap(WrapAxis axis) {

@Override
public void setWrap(WrapAxis axis, WrapMode mode) {
if (mode == null) {
throw new IllegalArgumentException("mode can not be null.");
} else if (axis == null) {
throw new IllegalArgumentException("axis can not be null.");
}
super.setWrap(axis, mode);
switch (axis) {
case S:
this.wrapS = mode;
Expand Down
8 changes: 1 addition & 7 deletions jme3-core/src/main/java/com/jme3/texture/TextureCubeMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@
*/
public class TextureCubeMap extends Texture {

private WrapMode wrapS = WrapMode.EdgeClamp;
private WrapMode wrapT = WrapMode.EdgeClamp;
private WrapMode wrapR = WrapMode.EdgeClamp;

/**
Expand Down Expand Up @@ -117,11 +115,7 @@ public Texture createSimpleClone(Texture rVal) {
* if axis or mode are null
*/
public void setWrap(WrapAxis axis, WrapMode mode) {
if (mode == null) {
throw new IllegalArgumentException("mode can not be null.");
} else if (axis == null) {
throw new IllegalArgumentException("axis can not be null.");
}
super.setWrap(axis, mode);
switch (axis) {
case S:
this.wrapS = mode;
Expand Down
15 changes: 8 additions & 7 deletions jme3-core/src/main/resources/com/jme3/system/version.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# THIS IS AN AUTO-GENERATED FILE..
# DO NOT MODIFY!
build.date=1900-01-01
git.revision=0
git.branch=unknown
git.hash=
git.hash.short=
git.tag=
name.full=jMonkeyEngine 3.1.0-UNKNOWN
build.date=2016-03-17
git.revision=5377
git.branch=master
git.hash=a0261e78fb5a8f3ac406b3af63c5344a32b790b6
git.hash.short=a0261e7
git.tag=v3.1-alpha1-219-ga0261e7
name.full=jMonkeyEngine 3.1-5377
version.full=3.1-5377
version.number=3.1.0
version.tag=SNAPSHOT
50 changes: 50 additions & 0 deletions jme3-core/src/test/java/com/jme3/texture/Texture2DTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.jme3.texture;

import org.junit.Before;
import org.junit.Test;

/**
* Created by kristinfjola on 17/03/16.
*/
public class Texture2DTest {

private Texture2D tex;

@Before
public void setUp(){
tex = new Texture2D();
}

@Test(expected = IllegalArgumentException.class)
public void testSetWrapWithAxisNull(){
tex.setWrap(null, Texture.WrapMode.EdgeClamp);
}

@Test(expected = IllegalArgumentException.class)
public void testSetWrapModeNull() {
tex.setWrap(Texture.WrapAxis.R, null);
}

@Test
public void testSetWrapAxisS() {
Texture.WrapMode wrapMode = Texture.WrapMode.EdgeClamp;
Texture.WrapAxis wrapAxis = Texture.WrapAxis.S;
tex.setWrap(wrapAxis, wrapMode);
assert tex.getWrap(wrapAxis) == wrapMode;
}

@Test
public void testSetWrapAxisT() {
Texture.WrapMode wrapMode = Texture.WrapMode.MirroredRepeat;
Texture.WrapAxis wrapAxis = Texture.WrapAxis.T;
tex.setWrap(wrapAxis, wrapMode);
assert tex.getWrap(wrapAxis) == wrapMode;
}

@Test(expected = IllegalArgumentException.class)
public void testSetWrapAxisR() {
Texture.WrapMode wrapMode = Texture.WrapMode.Repeat;
Texture.WrapAxis wrapAxis = Texture.WrapAxis.R;
tex.setWrap(wrapAxis, wrapMode);
}
}
49 changes: 49 additions & 0 deletions jme3-core/src/test/java/com/jme3/texture/Texture3DTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.jme3.texture;

import org.junit.Before;
import org.junit.Test;


public class Texture3DTest {

private Texture3D tex;

@Before
public void setUp(){
tex = new Texture3D();
}

@Test(expected = IllegalArgumentException.class)
public void testSetWrapWithAxisNull(){
tex.setWrap(null, Texture.WrapMode.EdgeClamp);
}

@Test(expected = IllegalArgumentException.class)
public void testSetWrapModeNull() {
tex.setWrap(Texture.WrapAxis.R, null);
}

@Test
public void testSetWrapAxisS() {
Texture.WrapMode wrapMode = Texture.WrapMode.EdgeClamp;
Texture.WrapAxis wrapAxis = Texture.WrapAxis.S;
tex.setWrap(wrapAxis, wrapMode);
assert tex.getWrap(wrapAxis) == wrapMode;
}

@Test
public void testSetWrapAxisT() {
Texture.WrapMode wrapMode = Texture.WrapMode.MirroredRepeat;
Texture.WrapAxis wrapAxis = Texture.WrapAxis.T;
tex.setWrap(wrapAxis, wrapMode);
assert tex.getWrap(wrapAxis) == wrapMode;
}

@Test
public void testSetWrapAxisR() {
Texture.WrapMode wrapMode = Texture.WrapMode.Repeat;
Texture.WrapAxis wrapAxis = Texture.WrapAxis.R;
tex.setWrap(wrapAxis, wrapMode);
assert tex.getWrap(wrapAxis) == wrapMode;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*___Generated_by_IDEA___*/

package com.jmonkeyengine.tests;

/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
public final static boolean DEBUG = Boolean.parseBoolean(null);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*___Generated_by_IDEA___*/

package com.jmonkeyengine.tests;

/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*___Generated_by_IDEA___*/

package com.jmonkeyengine.tests;

/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}

0 comments on commit cab36b5

Please sign in to comment.