Skip to content

Commit

Permalink
Consolidated the GLProfile used by the unit tests in OGLUtilTest, for #…
Browse files Browse the repository at this point in the history
  • Loading branch information
pdavidc committed Dec 7, 2016
1 parent 3a85481 commit a284053
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions test/gov/nasa/worldwind/util/OGLUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

import com.jogamp.opengl.util.texture.TextureData;
import gov.nasa.worldwind.Configuration;
import org.junit.Test;
import org.junit.*;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import javax.media.opengl.GL;
import javax.media.opengl.*;
import java.io.*;
import java.net.URL;

Expand All @@ -25,12 +25,26 @@ public class OGLUtilTest
private static final String DDS_FILE = "./src/images/BMNG_world.topo.bathy.200405.3.2048x1024.dds";
private static final String JPG_FILE = "./src/images/BMNG_world.topo.bathy.200405.3.2048x1024.jpg";

private GLProfile glProfile;

@Before
public void setUp()
{
this.glProfile = Configuration.getMaxCompatibleGLProfile();
}

@After
public void tearDown()
{
this.glProfile = null;
}

@Test
public void testPngFile() throws IOException
{
File f = new File(PNG_FILE);

TextureData td = OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(), f, false);
TextureData td = OGLUtil.newTextureData(this.glProfile, f, false);

assertEquals(td.getWidth(), 512);
assertEquals(td.getHeight(), 256);
Expand All @@ -42,7 +56,7 @@ public void testPngStream() throws IOException
File f = new File(PNG_FILE);
InputStream s = new FileInputStream(f);

TextureData td = OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(), s, false);
TextureData td = OGLUtil.newTextureData(this.glProfile, s, false);

assertEquals(td.getWidth(), 512);
assertEquals(td.getHeight(), 256);
Expand All @@ -53,7 +67,7 @@ public void testPngUrl() throws IOException
{
URL url = new File(PNG_FILE).toURI().toURL();

TextureData td = OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(), url, false);
TextureData td = OGLUtil.newTextureData(this.glProfile, url, false);

assertEquals(td.getWidth(), 512);
assertEquals(td.getHeight(), 256);
Expand All @@ -64,7 +78,7 @@ public void testDdsFile() throws IOException
{
File f = new File(DDS_FILE);

TextureData td = OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(), f, false);
TextureData td = OGLUtil.newTextureData(this.glProfile, f, false);

assertEquals(td.getWidth(), 2048);
assertEquals(td.getHeight(), 1024);
Expand All @@ -76,7 +90,7 @@ public void testDdsStream() throws IOException
File f = new File(DDS_FILE);
InputStream s = new FileInputStream(f);

TextureData td = OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(), s, false);
TextureData td = OGLUtil.newTextureData(this.glProfile, s, false);

assertEquals(td.getWidth(), 2048);
assertEquals(td.getHeight(), 1024);
Expand All @@ -87,7 +101,7 @@ public void testDdsUrl() throws IOException
{
URL url = new File(DDS_FILE).toURI().toURL();

TextureData td = OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(), url, false);
TextureData td = OGLUtil.newTextureData(this.glProfile, url, false);

assertEquals(td.getWidth(), 2048);
assertEquals(td.getHeight(), 1024);
Expand All @@ -98,7 +112,7 @@ public void testJpgFile() throws IOException
{
File f = new File(JPG_FILE);

TextureData td = OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(), f, false);
TextureData td = OGLUtil.newTextureData(this.glProfile, f, false);

assertEquals(td.getWidth(), 2048);
assertEquals(td.getHeight(), 1024);
Expand All @@ -110,7 +124,7 @@ public void testJpgStream() throws IOException
File f = new File(JPG_FILE);
InputStream s = new FileInputStream(f);

TextureData td = OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(), s, false);
TextureData td = OGLUtil.newTextureData(this.glProfile, s, false);

assertEquals(td.getWidth(), 2048);
assertEquals(td.getHeight(), 1024);
Expand All @@ -121,7 +135,7 @@ public void testJpgUrl() throws IOException
{
URL url = new File(JPG_FILE).toURI().toURL();

TextureData td = OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(), url, false);
TextureData td = OGLUtil.newTextureData(this.glProfile, url, false);

assertEquals(td.getWidth(), 2048);
assertEquals(td.getHeight(), 1024);
Expand All @@ -133,7 +147,7 @@ public void testIndexedColorPng() throws IOException
{
URL url = new File("./testData/32x32-icon-nasa-indexed-color.png").toURI().toURL();

TextureData td = OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(), url, false);
TextureData td = OGLUtil.newTextureData(this.glProfile, url, false);
assertEquals(td.getPixelFormat(), GL.GL_RGBA);
}

Expand All @@ -143,7 +157,7 @@ public void testInterlacedPng() throws IOException
{
URL url = new File("./testData/32x32-icon-nasa-interlaced.png").toURI().toURL();

TextureData td = OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(), url, false);
TextureData td = OGLUtil.newTextureData(this.glProfile, url, false);

assertEquals(td.getWidth(), 32);
assertEquals(td.getHeight(), 32);
Expand Down

0 comments on commit a284053

Please sign in to comment.