JOAL v2.6.0-rc-20250706
JOAL, OpenAL® API Binding for Java™ (public API).
ALVersionTest.java
Go to the documentation of this file.
1/**
2 * Copyright 2013-2023 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.openal.test.junit;
29
30import java.io.IOException;
31
32import org.junit.FixMethodOrder;
33import org.junit.Test;
34import org.junit.After;
35import org.junit.Assert;
36import org.junit.runners.MethodSorters;
37
38import com.jogamp.common.util.VersionNumber;
39import com.jogamp.openal.ALC;
40import com.jogamp.openal.ALCcontext;
41import com.jogamp.openal.ALCdevice;
42import com.jogamp.openal.ALFactory;
43import com.jogamp.openal.ALVersion;
44import com.jogamp.openal.JoalVersion;
45import com.jogamp.openal.test.util.UITestCase;
46
47/**
48 * Testing the OpenAL version,
49 * comparing against expected OpenAL-Soft version >= 1.1.0 and vendor-version >= 1.23.0,
50 * as well as the OpenAL-Soft vendor and renderer strings.
51 */
52@FixMethodOrder(MethodSorters.NAME_ASCENDING)
53public class ALVersionTest extends UITestCase {
54 static private final String OpenALVendor = "OpenAL Community";
55 static private final String OpenALRenderer = "OpenAL Soft";
56 static private final VersionNumber ALVersion11 = new VersionNumber(1, 1, 0);
57 static private final VersionNumber OpenALVersion1230 = new VersionNumber(1, 23, 0);
58
59 @Test
60 public void test01ALVersion() {
61 final ALVersion alv = new ALVersion(ALFactory.getALC());
62 final int versionComp = alv.getVersion().compareTo(ALVersion11);
63 final int vendorVersionComp = alv.getVendorVersion().compareTo(OpenALVersion1230);
64 System.out.println("ALVersion: "+alv.toString()+", version >= 1.1: "+versionComp+", vendorVersion >= 1.23.0: "+vendorVersionComp);
65 Assert.assertEquals(OpenALVendor, alv.getVendor());
66 Assert.assertEquals(OpenALRenderer, alv.getRenderer());
67 Assert.assertTrue( versionComp >= 0 );
68 Assert.assertTrue( vendorVersionComp >= 0 );
69 }
70
71 @Test
72 public void test02JoalVersion() {
74 System.err.println(jv.toString(ALFactory.getALC()));
75 }
76
77 @Test
79 final ALC alc = ALFactory.getALC();
80 final ALCdevice intialDevice = alc.alcOpenDevice(null);
81 final ALCcontext initialContext = alc.alcCreateContext(intialDevice, null);
82 alc.alcMakeContextCurrent(initialContext);
84 System.err.println(jv.toString(alc));
85 final ALCcontext currentContext = alc.alcGetCurrentContext();
86 Assert.assertNotNull(currentContext);
87 Assert.assertEquals(initialContext.getDirectBufferAddress(), currentContext.getDirectBufferAddress());
88 final ALCdevice currentDevice = alc.alcGetContextsDevice(currentContext);
89 Assert.assertNotNull(currentDevice);
90 Assert.assertEquals(intialDevice.getDirectBufferAddress(), currentDevice.getDirectBufferAddress());
91 }
92
93 @Test
95 final ALC alc = ALFactory.getALC();
97 System.err.println(jv.toString(alc));
98 final ALCcontext currentContext = alc.alcGetCurrentContext();
99 Assert.assertNull(currentContext);
100 }
101
102 @After
103 @Override
104 public void tearDown() {
105 super.tearDown();
106 final ALC alc = ALFactory.getALC();
107 final ALCcontext context = alc.alcGetCurrentContext();
108 if(null != context) {
109 alc.alcDestroyContext(context);
110 final ALCdevice device = alc.alcGetContextsDevice(context);
111 if(null != device) {
112 alc.alcCloseDevice(device);
113 }
114 }
115 }
116
117 public static void main(final String args[]) throws IOException {
118 org.junit.runner.JUnitCore.main(ALVersionTest.class.getName());
119 }
120}
final long getDirectBufferAddress()
Returns the native address of the underlying native ByteBuffer getBuffer().
Definition: ALCcontext.java:62
final long getDirectBufferAddress()
Returns the native address of the underlying native ByteBuffer getBuffer().
Definition: ALCdevice.java:62
This class provides factory methods for generating AL and ALC objects.
Definition: ALFactory.java:62
static ALC getALC()
Get the default ALC object.
Definition: ALFactory.java:136
VersionNumberString getVersion()
Return the AL context implementation version.
Definition: ALVersion.java:115
String getVendor()
Return the AL context implementation vendor.
Definition: ALVersion.java:105
String getRenderer()
Return the AL context implementation renderer.
Definition: ALVersion.java:110
static JoalVersion getInstance()
StringBuilder toString(final ALC alc, StringBuilder sb)
Return JogampVersion package information and AL informal strings.
Testing the OpenAL version, comparing against expected OpenAL-Soft version >= 1.1....
static void main(final String args[])
void alcDestroyContext(ALCcontext context)
Entry point (through function pointer) to C language function: void alcDestroyContext(ALCcontext * ...
boolean alcMakeContextCurrent(ALCcontext context)
Entry point (through function pointer) to C language function: ALCboolean alcMakeContextCurrent(ALC...
ALCcontext alcGetCurrentContext()
Entry point (through function pointer) to C language function: ALCcontext * alcGetCurrentContext()
boolean alcCloseDevice(ALCdevice device)
Entry point (through function pointer) to C language function: ALCboolean alcCloseDevice(ALCdevice ...
ALCdevice alcGetContextsDevice(ALCcontext context)
Entry point (through function pointer) to C language function: ALCdevice * alcGetContextsDevice(ALC...
ALCdevice alcOpenDevice(String devicename)
Entry point (through function pointer) to C language function: ALCdevice * alcOpenDevice(const ALCc...
ALCcontext alcCreateContext(ALCdevice device, IntBuffer attrlist)
Entry point (through function pointer) to C language function: ALCcontext * alcCreateContext(ALCdev...