Skip to content

Commit 3154d3f

Browse files
committed
Added unit test for exporting TextureArray WrapMode
1 parent d1864bb commit 3154d3f

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2009-2021 jMonkeyEngine
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are
7+
* met:
8+
*
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* * Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
package com.jme3.texture;
33+
34+
import static org.junit.Assert.*;
35+
36+
import com.jme3.asset.AssetManager;
37+
import com.jme3.asset.DesktopAssetManager;
38+
import com.jme3.export.binary.BinaryExporter;
39+
import com.jme3.texture.Texture.WrapAxis;
40+
import com.jme3.texture.Texture.WrapMode;
41+
import com.jme3.texture.image.ColorSpace;
42+
import com.jme3.util.BufferUtils;
43+
import java.nio.ByteBuffer;
44+
import java.util.ArrayList;
45+
import java.util.List;
46+
import org.junit.Test;
47+
48+
public class TextureArrayTest {
49+
50+
private static final AssetManager assetManager = new DesktopAssetManager();
51+
52+
@Test
53+
public void testExportWrapMode() {
54+
List<Image> images = new ArrayList<>();
55+
images.add(createImage());
56+
images.add(createImage());
57+
TextureArray tex3 = new TextureArray(images);
58+
tex3.setWrap(WrapMode.Repeat);
59+
TextureArray tex4 = BinaryExporter.saveAndLoad(assetManager, tex3);
60+
61+
assertEquals(tex3.getWrap(WrapAxis.S), tex4.getWrap(WrapAxis.S));
62+
assertEquals(tex3.getWrap(WrapAxis.T), tex4.getWrap(WrapAxis.T));
63+
}
64+
65+
private Image createImage() {
66+
int width = 8;
67+
int height = 8;
68+
int numBytes = 4 * width * height;
69+
ByteBuffer data = BufferUtils.createByteBuffer(numBytes);
70+
return new Image(Image.Format.RGBA8, width, height, data, ColorSpace.Linear);
71+
}
72+
73+
}

0 commit comments

Comments
 (0)