|
19 | 19 | */ |
20 | 20 | public class DefaultFontJ3oTest { |
21 | 21 |
|
22 | | - @Test |
23 | | - public void testDefaultFontJ3oLoadsWithoutPngLoader() { |
24 | | - // Create an AssetManager with only jme3-core loaders (no PNG loader) |
| 22 | + private static DesktopAssetManager createCoreOnlyAssetManager() { |
25 | 23 | DesktopAssetManager assetManager = new DesktopAssetManager(false); |
26 | 24 | assetManager.registerLocator("/", ClasspathLocator.class); |
27 | | - |
28 | 25 | // Register only the loaders available in jme3-core (matching General.cfg, minus StbImageLoader/WebpImageLoader) |
29 | 26 | assetManager.registerLoader(BitmapFontLoader.class, "fnt"); |
30 | 27 | assetManager.registerLoader(J3MLoader.class, "j3m", "j3md"); |
31 | 28 | assetManager.registerLoader(DDSLoader.class, "dds"); |
32 | 29 | assetManager.registerLoader(PFMLoader.class, "pfm"); |
33 | 30 | assetManager.registerLoader(BinaryLoader.class, "j3o", "j3f"); |
34 | 31 | assetManager.registerLoader(GLSLLoader.class, "vert", "frag", "geom", "tsctrl", "tseval", "glsl", "glsllib", "comp"); |
| 32 | + return assetManager; |
| 33 | + } |
35 | 34 |
|
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"); |
40 | 39 | 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"); |
42 | 41 | 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"); |
44 | 55 | } |
45 | 56 | } |
0 commit comments