forked from jMonkeyEngine/jmonkeyengine
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for ImageRaster and refactorings for tests
Both DefaultImageRaster and MipMapImageRaster were refactored in order to be able to create tests for each class
- Loading branch information
1 parent
ec47807
commit cfcf6a1
Showing
4 changed files
with
158 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
jme3-core/src/test/java/com/jme3/texture/image/MipMapImageRasterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.jme3.texture.image; | ||
|
||
import com.jme3.math.ColorRGBA; | ||
import com.jme3.texture.Image; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.mockito.Matchers.any; | ||
import static org.mockito.Mockito.*; | ||
import static org.mockito.Mockito.verify; | ||
|
||
/** | ||
* Created by kristinfjola on 21/03/16. | ||
*/ | ||
public class MipMapImageRasterTest { | ||
|
||
MipMapImageRaster ir; | ||
Image image; | ||
|
||
@Before | ||
public void setUp() { | ||
image = createImage(); | ||
ir = spy(new MipMapImageRaster(image, 0)); | ||
doNothing().when(ir).writeComponents(any(Integer.class), any(Integer.class)); | ||
doNothing().when(ir).readComponents(any(Integer.class), any(Integer.class)); | ||
} | ||
|
||
public Image createImage() { | ||
Image image = spy(new Image()); | ||
when(image.getFormat()).thenReturn(Image.Format.BGR8); | ||
when(image.getWidth()).thenReturn(1); | ||
when(image.getHeight()).thenReturn(1); | ||
when(image.hasMipmaps()).thenReturn(true); | ||
when(image.getMipMapSizes()).thenReturn(new int[5]); | ||
return image; | ||
} | ||
|
||
@Test | ||
public void testSetPixel() { | ||
int x = 0; | ||
int y = 0; | ||
ColorRGBA color = ColorRGBA.Black; | ||
ir.setPixel(x, y, color); | ||
|
||
verify(ir).rangeCheck(x, y); | ||
verify(ir).grayscaleCheck(color); | ||
verify(ir).setComponents(color); | ||
verify(ir).writeComponents(x, y); | ||
verify(image).setUpdateNeeded(); | ||
} | ||
|
||
@Test | ||
public void testGetPixel() { | ||
int x = 0; | ||
int y = 0; | ||
ColorRGBA color = ColorRGBA.Black; | ||
ColorRGBA pixelColor = ir.getPixel(x, y, color); | ||
|
||
verify(ir).rangeCheck(x, y); | ||
verify(ir).readComponents(x, y); | ||
verify(ir).setStoreComponents(color); | ||
verify(ir).setStoreRGBA(color); | ||
} | ||
} |