Package org.gbcpainter.test

Source Code of org.gbcpainter.test.TransparencyTextureLoadingTest

package org.gbcpainter.test;


import org.gbcpainter.env.GraphicsEnv;
import org.gbcpainter.loaders.textures.TextureLoader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import static org.junit.Assert.*;

/**
* @author Lorenzo Pellegrini
*/
@RunWith (JUnit4.class)
public class TransparencyTextureLoadingTest {

  private JFrame frame;

  @Before
  public void initializeEnv() throws Exception {
    frame = InitializeEnv.initialize( 400, 400, "testimg" );
  }

  @After
  public void deinitalize() {
    if(frame != null) {
      frame.dispose();
      frame = null;
    }
  }

  @Test
  public void transparentTextureLoading() throws Exception {
    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    BufferedImage loaded = (BufferedImage) loader.loadTexture( "Transparent", false );

    assertNotSame(loaded.getTransparency(), Transparency.OPAQUE);
  }

  @Test
  public void opaqueTextureLoading() throws Exception {
    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    BufferedImage loaded = (BufferedImage) loader.loadTexture( "Opaque", false );

    assertEquals(loaded.getTransparency(), Transparency.OPAQUE);

    loaded = (BufferedImage) loader.loadTexture( "Opaque_with_alpha", false );

    assertNotSame(loaded.getTransparency(), Transparency.OPAQUE);
  }
}
TOP

Related Classes of org.gbcpainter.test.TransparencyTextureLoadingTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.