summaryrefslogtreecommitdiffstats
path: root/unit_tests
diff options
context:
space:
mode:
authorkbr <[email protected]>2006-01-10 11:07:30 +0000
committerkbr <[email protected]>2006-01-10 11:07:30 +0000
commit1a0b7c61155813ac0bf3c6d58b4dac15f0225101 (patch)
treee3b573ca2193ae8a6aacd5bc5cb3060321308ba7 /unit_tests
parent0badf374064da5c608dcb06ef2d2e9966792ddc8 (diff)
Merged gluegen-branch-1-0 on to the main JOAL trunk. JOAL is now built
using GlueGen and currently requires a built JOGL workspace as a sibling workspace of the JOAL workspace. git-svn-id: file:///home/mbien/NetBeansProjects/JOGAMP/joal-sync/git-svn/../svn-server-sync/joal/trunk@101 03bf7f67-59de-4072-a415-9a990d468a3f
Diffstat (limited to 'unit_tests')
-rw-r--r--unit_tests/build.xml14
-rw-r--r--unit_tests/src/OpenALTest.java44
-rw-r--r--unit_tests/src/Sound3DTest.java18
-rw-r--r--unit_tests/src/net/java/games/joal/ALTest.java132
4 files changed, 71 insertions, 137 deletions
diff --git a/unit_tests/build.xml b/unit_tests/build.xml
index fafdf5b..7b1f8e2 100644
--- a/unit_tests/build.xml
+++ b/unit_tests/build.xml
@@ -40,7 +40,7 @@
</target>
<target name="compile" depends="init">
- <javac debug="true" srcdir="./src" classpath="../classes" destdir="classes"/>
+ <javac debug="true" srcdir="./src" classpath="../build/joal.jar;lib/junit.jar" destdir="classes"/>
</target>
<target name="clean">
@@ -50,22 +50,22 @@
<target name="runOpenALTest" depends="compile">
<java classname="OpenALTest" fork="true">
<classpath>
- <pathelement location="../lib/joal.jar"/>
+ <pathelement location="../build/joal.jar"/>
<pathelement location="lib/junit.jar"/>
<pathelement location="classes"/>
</classpath>
- <jvmarg value="-Djava.library.path=${basedir}/../lib"/>
+ <jvmarg value="-Djava.library.path=${basedir}/../build/obj"/>
</java>
</target>
<target name="runALTest" depends="compile">
<java classname="junit.textui.TestRunner" fork="true">
<classpath>
- <pathelement location="../lib/joal.jar"/>
+ <pathelement location="../build/joal.jar"/>
<pathelement location="lib/junit.jar"/>
<pathelement location="classes"/>
</classpath>
- <jvmarg value="-Djava.library.path=${basedir}/../lib"/>
+ <jvmarg value="-Djava.library.path=${basedir}/../build/obj"/>
<arg value="net.java.games.joal.ALTest" />
</java>
</target>
@@ -73,11 +73,11 @@
<target name="runSound3DTest" depends="compile">
<java classname="Sound3DTest" fork="true">
<classpath>
- <pathelement location="../lib/joal.jar"/>
+ <pathelement location="../build/joal.jar"/>
<pathelement location="lib/junit.jar"/>
<pathelement location="classes"/>
</classpath>
- <jvmarg value="-Djava.library.path=${basedir}/../lib"/>
+ <jvmarg value="-Djava.library.path=${basedir}/../build/obj"/>
</java>
</target>
</project>
diff --git a/unit_tests/src/OpenALTest.java b/unit_tests/src/OpenALTest.java
index 12745fe..5b9930a 100644
--- a/unit_tests/src/OpenALTest.java
+++ b/unit_tests/src/OpenALTest.java
@@ -18,7 +18,7 @@
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
-* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS
+* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS
* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A
* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT
@@ -30,17 +30,12 @@
* You acknowledge that this software is not designed or intended for use in the
* design, construction, operation or maintenance of any nuclear facility.
*/
-import java.nio.IntBuffer;
-
-import net.java.games.joal.AL;
-import net.java.games.joal.ALC;
-import net.java.games.joal.ALFactory;
-import net.java.games.joal.OpenALException;
-import net.java.games.joal.eax.EAX;
-import net.java.games.joal.eax.EAXFactory;
-import net.java.games.joal.util.BufferUtils;
-import net.java.games.joal.util.WAVData;
-import net.java.games.joal.util.WAVLoader;
+
+import java.nio.*;
+
+import net.java.games.joal.*;
+import net.java.games.joal.eax.*;
+import net.java.games.joal.util.*;
/**
* @author Athomas Goldberg
@@ -49,11 +44,9 @@ import net.java.games.joal.util.WAVLoader;
public class OpenALTest {
public static void main(String[] args) {
try {
- ALFactory.initialize();
-
ALC alc = ALFactory.getALC();
- ALC.Device device = alc.alcOpenDevice(null);
- ALC.Context context = alc.alcCreateContext(device, null);
+ ALCdevice device = alc.alcOpenDevice(null);
+ ALCcontext context = alc.alcCreateContext(device, null);
alc.alcMakeContextCurrent(context);
AL al = ALFactory.getAL();
boolean eaxPresent = al.alIsExtensionPresent("EAX2.0");
@@ -62,23 +55,20 @@ public class OpenALTest {
try {
int[] buffers = new int[1];
- al.alGenBuffers(1, buffers);
+ al.alGenBuffers(1, buffers, 0);
WAVData wd = WAVLoader.loadFromFile("lewiscarroll.wav");
al.alBufferData(buffers[0], wd.format, wd.data, wd.size, wd.freq);
int[] sources = new int[1];
- al.alGenSources(1, sources);
+ al.alGenSources(1, sources, 0);
al.alSourcei(sources[0], AL.AL_BUFFER, buffers[0]);
- System.out.println(
- "Looping 1: "
- + (al.alGetSourcei(sources[0], AL.AL_LOOPING) == AL.AL_TRUE));
int[] loopArray = new int[1];
- al.alGetSourcei(sources[0], AL.AL_LOOPING, loopArray);
- System.out.println("Looping 2: " + (loopArray[0] == AL.AL_TRUE));
+ al.alGetSourcei(sources[0], AL.AL_LOOPING, loopArray, 0);
+ System.out.println("Looping 1: " + (loopArray[0] == AL.AL_TRUE));
int[] loopBuffer = new int[1];
- al.alGetSourcei(sources[0], AL.AL_LOOPING, loopBuffer);
- System.out.println("Looping 3: " + (loopBuffer[0] == AL.AL_TRUE));
+ al.alGetSourcei(sources[0], AL.AL_LOOPING, loopBuffer, 0);
+ System.out.println("Looping 2: " + (loopBuffer[0] == AL.AL_TRUE));
if (eaxPresent) {
IntBuffer env = BufferUtils.newIntBuffer(1);
@@ -117,13 +107,13 @@ public class OpenALTest {
}
al.alSourceStop(sources[0]);
- al.alDeleteSources(1, sources);
+ al.alDeleteSources(1, sources, 0);
alc.alcDestroyContext(context);
alc.alcCloseDevice(device);
} catch (Exception e) {
e.printStackTrace();
}
- } catch (OpenALException e) {
+ } catch (ALException e) {
e.printStackTrace();
}
}
diff --git a/unit_tests/src/Sound3DTest.java b/unit_tests/src/Sound3DTest.java
index ffaefb0..f6a65a3 100644
--- a/unit_tests/src/Sound3DTest.java
+++ b/unit_tests/src/Sound3DTest.java
@@ -18,7 +18,7 @@
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
-* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS
+* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS
* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A
* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT
@@ -30,16 +30,10 @@
* You acknowledge that this software is not designed or intended for use in the
* design, construction, operation or maintenance of any nuclear facility.
*/
-import java.io.IOException;
-
-import javax.sound.sampled.UnsupportedAudioFileException;
-
-import net.java.games.sound3d.AudioSystem3D;
-import net.java.games.sound3d.Context;
-import net.java.games.sound3d.Device;
-import net.java.games.sound3d.Listener;
-import net.java.games.sound3d.Sound3DException;
-import net.java.games.sound3d.Source;
+import java.io.*;
+import javax.sound.sampled.*;
+import net.java.games.joal.*;
+import net.java.games.sound3d.*;
/**
* @author Athomas Goldberg
@@ -56,7 +50,7 @@ public class Sound3DTest {
public static void main(String[] args) {
try {
AudioSystem3D.init();
- } catch (Sound3DException e) {
+ } catch (ALException e) {
e.printStackTrace();
return;
}
diff --git a/unit_tests/src/net/java/games/joal/ALTest.java b/unit_tests/src/net/java/games/joal/ALTest.java
index 024b856..7b25aa1 100644
--- a/unit_tests/src/net/java/games/joal/ALTest.java
+++ b/unit_tests/src/net/java/games/joal/ALTest.java
@@ -12,8 +12,7 @@ import java.nio.ByteBuffer;
import javax.sound.sampled.UnsupportedAudioFileException;
import junit.framework.TestCase;
-import net.java.games.joal.util.WAVData;
-import net.java.games.joal.util.WAVLoader;
+import net.java.games.joal.util.*;
/**
* @author Athomas Goldberg
@@ -24,8 +23,8 @@ public class ALTest extends TestCase {
static AL al;
static ALC alc;
- static ALC.Context context;
- static ALC.Device device;
+ static ALCcontext context;
+ static ALCdevice device;
final static String TEST_FILE ="lewiscarroll.wav";
/**
@@ -38,13 +37,12 @@ public class ALTest extends TestCase {
public void setUp() {
try {
- ALFactory.initialize();
al = ALFactory.getAL();
alc = ALFactory.getALC();
device = alc.alcOpenDevice(null);
context = alc.alcCreateContext(device, null);
alc.alcMakeContextCurrent(context);
- } catch (OpenALException e) {
+ } catch (ALException e) {
e.printStackTrace();
}
}
@@ -121,7 +119,7 @@ public class ALTest extends TestCase {
// try basic case
try {
int[] buffers = new int[7];
- al.alGenBuffers(7,buffers);
+ al.alGenBuffers(7,buffers, 0);
for(int i = 0; i < 7; i++) {
assertFalse(buffers[i] == 0);
assertTrue(al.alIsBuffer(buffers[i]));
@@ -134,7 +132,7 @@ public class ALTest extends TestCase {
// try exceptions
try {
int[] buffers = null;
- al.alGenBuffers(7,buffers);
+ al.alGenBuffers(7,buffers, 0);
} catch(IllegalArgumentException e) {
@@ -144,7 +142,7 @@ public class ALTest extends TestCase {
ex = null;
try {
int[] buffers = new int[5];
- al.alGenBuffers(7,buffers);
+ al.alGenBuffers(7,buffers, 0);
} catch(IllegalArgumentException e) {
ex = e;
}
@@ -162,12 +160,12 @@ public class ALTest extends TestCase {
// try basic case
try {
int[] buffers = new int[7];
- al.alGenBuffers(7,buffers);
+ al.alGenBuffers(7,buffers,0);
for(int i = 0; i < 7; i++) {
assertFalse(buffers[i] == 0);
assertTrue(al.alIsBuffer(buffers[i]));
}
- al.alDeleteBuffers(7,buffers);
+ al.alDeleteBuffers(7,buffers,0);
for(int i = 0; i < 7; i++) {
assertFalse(al.alIsBuffer(buffers[i]));
}
@@ -178,7 +176,7 @@ public class ALTest extends TestCase {
Exception ex = null;
// try exceptions
try {
- al.alDeleteBuffers(7,(int[])null);
+ al.alDeleteBuffers(7,(int[])null, 0);
} catch(IllegalArgumentException e) {
ex = e;
}
@@ -186,8 +184,8 @@ public class ALTest extends TestCase {
ex = null;
try {
int[] buffers = new int[5];
- al.alGenBuffers(5,buffers);
- al.alDeleteBuffers(7,buffers);
+ al.alGenBuffers(5,buffers,0);
+ al.alDeleteBuffers(7,buffers,0);
} catch(IllegalArgumentException e) {
ex = e;
}
@@ -195,7 +193,7 @@ public class ALTest extends TestCase {
try {
int[] buffers = new int[7];
- al.alDeleteBuffers(7,buffers);
+ al.alDeleteBuffers(7,buffers,0);
assertTrue(al.alGetError() != 0);
} catch(Exception e) {
fail("deleting an unfilled buffer list should generate an ALError but not an exception");
@@ -212,12 +210,12 @@ public class ALTest extends TestCase {
// try basic case
try {
int[] buffers = new int[7];
- al.alGenBuffers(7,buffers);
+ al.alGenBuffers(7,buffers,0);
for(int i = 0; i < 7; i++) {
assertFalse(buffers[i] == 0);
assertTrue(al.alIsBuffer(buffers[i]));
}
- al.alDeleteBuffers(7,buffers);
+ al.alDeleteBuffers(7,buffers,0);
for(int i = 0; i < 7; i++) {
assertFalse(al.alIsBuffer(buffers[i]));
}
@@ -228,7 +226,7 @@ public class ALTest extends TestCase {
Exception ex = null;
// try exceptions
try {
- al.alDeleteBuffers(7,(int[])null);
+ al.alDeleteBuffers(7,(int[])null,0);
} catch(IllegalArgumentException e) {
ex = e;
}
@@ -236,8 +234,8 @@ public class ALTest extends TestCase {
ex = null;
try {
int[] buffers = new int[5];
- al.alGenBuffers(5,buffers);
- al.alDeleteBuffers(7,buffers);
+ al.alGenBuffers(5,buffers,0);
+ al.alDeleteBuffers(7,buffers,0);
} catch(IllegalArgumentException e) {
ex = e;
}
@@ -246,7 +244,7 @@ public class ALTest extends TestCase {
ex = null;
try {
int[] buffers = new int[5];
- al.alDeleteBuffers(7,buffers);
+ al.alDeleteBuffers(7,buffers,0);
} catch(IllegalArgumentException e) {
ex = e;
}
@@ -254,7 +252,7 @@ public class ALTest extends TestCase {
try {
int[] buffers = new int[7];
- al.alDeleteBuffers(7,buffers);
+ al.alDeleteBuffers(7,buffers,0);
assertTrue(al.alGetError() != 0);
} catch(Exception e) {
fail("deleting an unfilled buffer list should generate an ALError but not an exception");
@@ -273,12 +271,12 @@ public class ALTest extends TestCase {
assertFalse(al.alIsBuffer(buffers[i]));
}
// created
- al.alGenBuffers(7,buffers);
+ al.alGenBuffers(7,buffers,0);
for(int i = 0; i < 7; i++) {
assertTrue(al.alIsBuffer(buffers[i]));
}
// deleted
- al.alDeleteBuffers(7,buffers);
+ al.alDeleteBuffers(7,buffers,0);
for(int i = 0; i < 7; i++) {
assertFalse(al.alIsBuffer(buffers[i]));
}
@@ -290,63 +288,13 @@ public class ALTest extends TestCase {
}
/*
- * Test for void alBufferData(int, int, byte[], int, int)
- */
- final public void testAlBufferDataintintbyteArrayintint() {
- System.out.println("begin testAlBufferDataintintbyteArrayintint");
- try {
- int[] buffers = new int[1];
- al.alGenBuffers(1, buffers);
- WAVData wd = WAVLoader.loadFromFile(TEST_FILE);
- int capacity = wd.data.capacity();
- int remaining = wd.data.remaining();
-
- byte[] data = new byte[wd.data.capacity()];
- for(int i = 0; i < data.length; i++) {
- data[i] = wd.data.get(i);
- }
-
- al.alBufferData(
- buffers[0],
- wd.format,
- data,
- wd.size,
- wd.freq
- );
-
- assertFalse(al.alGetBufferi(buffers[0],AL.AL_SIZE) == 0);
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- Exception ex = null;
- try {
- int[] buffers = new int[1];
- al.alGenBuffers(1, buffers);
-
- al.alBufferData(
- buffers[0],
- AL.AL_FORMAT_STEREO16,
- (byte[])null,
- 0,
- 0
- );
- } catch(IllegalArgumentException e) {
- ex = e;
- }
- assertNotNull(ex);
-
- System.out.println("end testAlBufferDataintintbyteArrayintint");
- }
-
- /*
- * Test for void alBufferData(int, int, ByteBuffer, int, int)
+ * Test for void alBufferData(int, int, Buffer, int, int)
*/
final public void testAlBufferDataintintByteBufferintint() {
System.out.println("begin testAlBufferDataintintByteBufferintint");
try {
int[] buffers = new int[1];
- al.alGenBuffers(1, buffers);
+ al.alGenBuffers(1, buffers, 0);
WAVData wd =
WAVLoader.loadFromFile(TEST_FILE);
al.alBufferData(
@@ -356,19 +304,21 @@ public class ALTest extends TestCase {
wd.size,
wd.freq
);
- assertFalse(al.alGetBufferi(buffers[0],AL.AL_SIZE) == 0);
+ int[] tmp = new int[1];
+ al.alGetBufferi(buffers[0],AL.AL_SIZE,tmp,0);
+ assertFalse(tmp[0] == 0);
} catch(Exception e) {
fail(e.toString());
}
Exception ex = null;
try {
int[] buffers = new int[1];
- al.alGenBuffers(1, buffers);
+ al.alGenBuffers(1, buffers, 0);
al.alBufferData(
buffers[0],
AL.AL_FORMAT_STEREO16,
- (ByteBuffer)null,
+ null,
0,
0
);
@@ -420,7 +370,7 @@ public class ALTest extends TestCase {
System.out.println("begin testAlGetBufferiintintintArray");
try {
int[] buffers = new int[1];
- al.alGenBuffers(1, buffers);
+ al.alGenBuffers(1, buffers, 0);
WAVData wd =
WAVLoader.loadFromFile(TEST_FILE);
al.alBufferData(
@@ -432,8 +382,8 @@ public class ALTest extends TestCase {
);
int[] size = new int[1];
int[] freq = new int[1];
- al.alGetBufferi(buffers[0],AL.AL_SIZE, size);
- al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq);
+ al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0);
+ al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq, 0);
assertEquals(wd.size, size[0]);
assertEquals(wd.freq, freq[0]);
} catch(Exception e) {
@@ -443,7 +393,7 @@ public class ALTest extends TestCase {
Exception ex = null;
try {
int[] buffers = new int[1];
- al.alGenBuffers(1, buffers);
+ al.alGenBuffers(1, buffers, 0);
WAVData wd =
WAVLoader.loadFromFile(TEST_FILE);
al.alBufferData(
@@ -454,7 +404,7 @@ public class ALTest extends TestCase {
wd.freq
);
int[] size = null;
- al.alGetBufferi(buffers[0],AL.AL_SIZE, size);
+ al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0);
} catch (IllegalArgumentException e) {
ex = e;
@@ -477,7 +427,7 @@ public class ALTest extends TestCase {
final public void testAlGetBufferiintintIntBuffer() {
try {
int[] buffers = new int[1];
- al.alGenBuffers(1, buffers);
+ al.alGenBuffers(1, buffers, 0);
WAVData wd =
WAVLoader.loadFromFile(TEST_FILE);
al.alBufferData(
@@ -489,8 +439,8 @@ public class ALTest extends TestCase {
);
int[] size = new int[1];
int[] freq = new int[1];
- al.alGetBufferi(buffers[0],AL.AL_SIZE, size);
- al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq);
+ al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0);
+ al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq, 0);
assertEquals(wd.size, size[0]);
assertEquals(wd.freq, freq[0]);
} catch(Exception e) {
@@ -499,7 +449,7 @@ public class ALTest extends TestCase {
Exception ex = null;
try {
int[] buffers = new int[1];
- al.alGenBuffers(1, buffers);
+ al.alGenBuffers(1, buffers, 0);
WAVData wd =
WAVLoader.loadFromFile(TEST_FILE);
al.alBufferData(
@@ -510,7 +460,7 @@ public class ALTest extends TestCase {
wd.freq
);
int[] size = null;
- al.alGetBufferi(buffers[0],AL.AL_SIZE, size);
+ al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0);
} catch (IllegalArgumentException e) {
ex = e;
@@ -526,7 +476,7 @@ public class ALTest extends TestCase {
ex = null;
try {
int[] buffers = new int[1];
- al.alGenBuffers(1, buffers);
+ al.alGenBuffers(1, buffers, 0);
WAVData wd =
WAVLoader.loadFromFile(TEST_FILE);
al.alBufferData(
@@ -537,7 +487,7 @@ public class ALTest extends TestCase {
wd.freq
);
int[] size = new int[1];
- al.alGetBufferi(buffers[0],AL.AL_SIZE, size);
+ al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0);
} catch (IllegalArgumentException e) {
ex = e;