Skip to content

Commit 7f3787e

Browse files
authored
Add Console.j3o test and refactor DefaultFontJ3oTest helper
1 parent a622fdd commit 7f3787e

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

jme3-core/src/test/java/com/jme3/asset/DefaultFontJ3oTest.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,38 @@
1919
*/
2020
public class DefaultFontJ3oTest {
2121

22-
@Test
23-
public void testDefaultFontJ3oLoadsWithoutPngLoader() {
24-
// Create an AssetManager with only jme3-core loaders (no PNG loader)
22+
private static DesktopAssetManager createCoreOnlyAssetManager() {
2523
DesktopAssetManager assetManager = new DesktopAssetManager(false);
2624
assetManager.registerLocator("/", ClasspathLocator.class);
27-
2825
// Register only the loaders available in jme3-core (matching General.cfg, minus StbImageLoader/WebpImageLoader)
2926
assetManager.registerLoader(BitmapFontLoader.class, "fnt");
3027
assetManager.registerLoader(J3MLoader.class, "j3m", "j3md");
3128
assetManager.registerLoader(DDSLoader.class, "dds");
3229
assetManager.registerLoader(PFMLoader.class, "pfm");
3330
assetManager.registerLoader(BinaryLoader.class, "j3o", "j3f");
3431
assetManager.registerLoader(GLSLLoader.class, "vert", "frag", "geom", "tsctrl", "tseval", "glsl", "glsllib", "comp");
32+
return assetManager;
33+
}
3534

36-
// This should succeed: Default.j3o has embedded image data (no PNG loader needed)
37-
BitmapFont font = assetManager.loadFont("Interface/Fonts/Default.j3o");
38-
assertNotNull(font, "Default.j3o should load without a PNG loader");
39-
assertNotNull(font.getPage(0), "Default.j3o should have at least one material page");
35+
private static void assertFontLoaded(DesktopAssetManager assetManager, String path) {
36+
BitmapFont font = assetManager.loadFont(path);
37+
assertNotNull(font, path + " should load without a PNG loader");
38+
assertNotNull(font.getPage(0), path + " should have at least one material page");
4039
assertNotNull(font.getPage(0).getTextureParam("ColorMap"),
41-
"Default.j3o material page should have a ColorMap texture");
40+
path + " material page should have a ColorMap texture");
4241
assertNotNull(font.getPage(0).getTextureParam("ColorMap").getTextureValue().getImage(),
43-
"Default.j3o texture should have embedded image data (no key needed)");
42+
path + " texture should have embedded image data (no key needed)");
43+
}
44+
45+
@Test
46+
public void testDefaultFontJ3oLoadsWithoutPngLoader() {
47+
// This should succeed: Default.j3o has embedded image data (no PNG loader needed)
48+
assertFontLoaded(createCoreOnlyAssetManager(), "Interface/Fonts/Default.j3o");
49+
}
50+
51+
@Test
52+
public void testConsoleFontJ3oLoadsWithoutPngLoader() {
53+
// This should succeed: Console.j3o has embedded image data (no PNG loader needed)
54+
assertFontLoaded(createCoreOnlyAssetManager(), "Interface/Fonts/Console.j3o");
4455
}
4556
}

0 commit comments

Comments
 (0)