Package com.irurueta.geometry.io
Class MaterialLoaderOBJTest
java.lang.Object
com.irurueta.geometry.io.MaterialLoaderOBJTest
- All Implemented Interfaces:
MaterialLoaderListener
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Stream<org.junit.jupiter.params.provider.Arguments> Provides files without material definitions.(package private) voidChecks alias directives (Ni, Tr), mixed case commands and several materials.(package private) voidChecks that every color, coefficient, transparency and illumination directive is parsed.(package private) voidChecks the bump alias directive without any listener (no validation possible).(package private) voidChecks that binary garbage only produces checked exceptions.(package private) voidChecks that a loader is unlocked after failing to load a hostile file, and that materials from a previous load are not leaked into a later one.(package private) voidChecks that an out of range illumination value yields a null illumination.(package private) voidChecks that malformed directives raise a LoaderException.(package private) voidChecks that a loader without file is not ready to load.(package private) voidChecks that files without any material definition produce an empty set instead of failing unexpectedly.(package private) voidChecks that properties given before any material is declared raise a LoaderException.(package private) voidChecks that every texture map directive is parsed when texture validation succeeds.(package private) voidChecks that texture validation failures raise a LoaderException for every texture directive.(package private) voidChecks that invalid textures are accepted when texture validation is disabled.voidonLoadEnd(MaterialLoader loader) voidonLoadStart(MaterialLoader loader) booleanonValidateTexture(MaterialLoader loader, Texture texture) (package private) voidChecks that a missing file raises an IOException when setting it.(package private) void(package private) void(package private) void(package private) void(package private) void(package private) void(package private) voidtestLoad()(package private) voidprivate FileWrites an MTL file with provided lines into the temporary directory.
-
Field Details
-
tempDir
-
counter
private int counter -
forceLoaderException
private boolean forceLoaderException
-
-
Constructor Details
-
MaterialLoaderOBJTest
MaterialLoaderOBJTest()
-
-
Method Details
-
testConstructor
- Throws:
IOException
-
testLoad
-
testGetMaterialByName
@Test void testGetMaterialByName() throws IOException, LockedException, NotReadyException, LoaderException -
testGetMaterialByTextureMapName
@Test void testGetMaterialByTextureMapName() throws IOException, LockedException, NotReadyException, LoaderException -
testIsSetTextureValidationEnabled
- Throws:
IOException
-
testGetFileSizeLimitToKeepInMemory
- Throws:
LockedExceptionIOException
-
testGetSetListener
- Throws:
LockedExceptionIOException
-
testSetFile
- Throws:
LockedExceptionIOException
-
load_whenAllScalarDirectives_parsesEveryValue
@Test void load_whenAllScalarDirectives_parsesEveryValue() throws IOException, LockedException, NotReadyException, LoaderExceptionChecks that every color, coefficient, transparency and illumination directive is parsed. -
load_whenAliasesAndMixedCase_parsesAllMaterials
@Test void load_whenAliasesAndMixedCase_parsesAllMaterials() throws IOException, LockedException, NotReadyException, LoaderExceptionChecks alias directives (Ni, Tr), mixed case commands and several materials. -
load_whenTextureDirectives_parsesAllTextureMaps
@Test void load_whenTextureDirectives_parsesAllTextureMaps() throws IOException, LockedException, NotReadyException, LoaderExceptionChecks that every texture map directive is parsed when texture validation succeeds. -
load_whenBumpAliasWithoutListener_parsesBumpTexture
@Test void load_whenBumpAliasWithoutListener_parsesBumpTexture() throws IOException, LockedException, NotReadyException, LoaderExceptionChecks the bump alias directive without any listener (no validation possible). -
load_whenTextureValidationFails_throwsLoaderException
@ParameterizedTest @ValueSource(strings={"map_Kd","map_Ka","map_Ks","map_d","map_bump"}) void load_whenTextureValidationFails_throwsLoaderException(String directive) throws IOException Checks that texture validation failures raise a LoaderException for every texture directive.- Throws:
IOException
-
load_whenValidationDisabledAndTextureInvalid_loadsMaterial
@Test void load_whenValidationDisabledAndTextureInvalid_loadsMaterial() throws IOException, LockedException, NotReadyException, LoaderExceptionChecks that invalid textures are accepted when texture validation is disabled. -
load_whenMalformedDirective_throwsLoaderException
@ParameterizedTest @ValueSource(strings={"Ka 1.0 0.5","Ka a b c","Kd 1.0","Kd x y z","Ks","Ks 1 2 q","Ns","Ns abc","d","d xyz","Tr","illum","illum abc","Ni nope"}) void load_whenMalformedDirective_throwsLoaderException(String line) throws IOException Checks that malformed directives raise a LoaderException.- Throws:
IOException
-
load_whenPropertyBeforeMaterial_throwsLoaderException
@ParameterizedTest @ValueSource(strings={"Ka 1 1 1","Kd 1 1 1","Ks 1 1 1","Ns 1","Ni 1","d 1","Tr 1","illum 1","map_Kd a.png","map_Ka a.png","map_Ks a.png","map_d a.png","map_bump a.png"}) void load_whenPropertyBeforeMaterial_throwsLoaderException(String line) throws IOException Checks that properties given before any material is declared raise a LoaderException.- Throws:
IOException
-
load_whenNoMaterialIsDefined_returnsEmptySet
@ParameterizedTest @MethodSource("filesWithoutMaterials") void load_whenNoMaterialIsDefined_returnsEmptySet(String[] lines) throws Exception Checks that files without any material definition produce an empty set instead of failing unexpectedly.- Parameters:
lines- file contents.- Throws:
Exception- if any unexpected error occurs.
-
load_whenFileIsCorrupted_unlocksLoader
Checks that a loader is unlocked after failing to load a hostile file, and that materials from a previous load are not leaked into a later one.- Throws:
Exception- if any unexpected error occurs.
-
load_whenFileIsBinaryGarbage_onlyCheckedExceptionsAreThrown
Checks that binary garbage only produces checked exceptions.- Throws:
Exception- if any unexpected error occurs.
-
filesWithoutMaterials
Provides files without material definitions.- Returns:
- stream of file contents.
-
load_whenIllumOutOfRange_setsNullIllumination
@Test void load_whenIllumOutOfRange_setsNullIllumination() throws IOException, LockedException, NotReadyException, LoaderExceptionChecks that an out of range illumination value yields a null illumination. -
setFile_whenFileMissing_throwsIOException
Checks that a missing file raises an IOException when setting it.- Throws:
IOException
-
load_whenNoFile_throwsNotReadyException
Checks that a loader without file is not ready to load.- Throws:
IOException
-
writeMtl
Writes an MTL file with provided lines into the temporary directory.- Parameters:
lines- lines of the file.- Returns:
- created file.
- Throws:
IOException- if the file cannot be written.
-
onLoadStart
- Specified by:
onLoadStartin interfaceMaterialLoaderListener
-
onLoadEnd
- Specified by:
onLoadEndin interfaceMaterialLoaderListener
-
onValidateTexture
- Specified by:
onValidateTexturein interfaceMaterialLoaderListener
-