You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.2 KiB
75 lines
2.2 KiB
package wow.doge.mygame
|
|
|
|
import com.jme3.asset.DesktopAssetManager
|
|
import com.jme3.material.Material
|
|
import com.jme3.material.MaterialDef
|
|
import com.jme3.scene.Geometry
|
|
import com.jme3.scene.Node
|
|
import wow.doge.mygame.utils.wrappers.jme.AssetManager
|
|
import wow.doge.mygame.utils.wrappers.jme.AssetManager.AssetNotFound
|
|
import wow.doge.mygame.utils.wrappers.jme.AssetManager.CouldNotCastError
|
|
|
|
class AssetManagerTest extends MonixBioSuite {
|
|
|
|
val fixture = FunFixture[AssetManager](
|
|
setup = _ => new AssetManager(new DesktopAssetManager(true)),
|
|
teardown = _ => ()
|
|
)
|
|
|
|
override def beforeAll(): Unit = {
|
|
import java.util.logging.{Logger => JLogger, Level}
|
|
JLogger.getLogger("").setLevel(Level.SEVERE)
|
|
}
|
|
|
|
fixture.test(
|
|
"AssetManager#loadModel should fail with AssetNotFoundError when asset does not exist"
|
|
) { assetManager =>
|
|
assetManager
|
|
.loadModel(os.rel / "doesnotexist")
|
|
.attempt
|
|
.assertEquals(Left(AssetNotFound("doesnotexist")))
|
|
}
|
|
|
|
fixture.test(
|
|
"AssetManager#loadModelAs should fail with CouldNotCastError when model is not of target type"
|
|
) { assetManager =>
|
|
val modelPath = os.rel / "Models" / "Jaime" / "Jaime.j3o"
|
|
assetManager
|
|
.loadModelAs[Geometry](modelPath)
|
|
.attempt
|
|
.assertEquals(Left(CouldNotCastError))
|
|
|
|
}
|
|
|
|
fixture.test(
|
|
"AssetManager#loadModelAs should load com.jme3.Node successfully"
|
|
) { assetManager =>
|
|
val modelPath = os.rel / "Models" / "Jaime" / "Jaime.j3o"
|
|
assetManager
|
|
.loadModelAs[Node](modelPath)
|
|
.attempt
|
|
.map(_.map(_.getName))
|
|
.assertEquals(Right("JaimeGeom-ogremesh"))
|
|
}
|
|
|
|
fixture.test(
|
|
"AssetManager#loadAssetAs should fail with CouldNotCastError when asset is not of target type"
|
|
) { assetManager =>
|
|
val assetPath = os.rel / "Common" / "MatDefs" / "Misc" / "Unshaded.j3md"
|
|
assetManager
|
|
.loadAssetAs[Material](assetPath)
|
|
.attempt
|
|
.assertEquals(Left(CouldNotCastError))
|
|
}
|
|
|
|
fixture.test(
|
|
"AssetManager#loadAssetAs should should load asset succesfully"
|
|
) { assetManager =>
|
|
val assetPath = os.rel / "Common" / "MatDefs" / "Misc" / "Unshaded.j3md"
|
|
assetManager
|
|
.loadAssetAs[MaterialDef](assetPath)
|
|
.attempt
|
|
.map(_.map(_.getName))
|
|
.assertEquals(Right("Unshaded"))
|
|
}
|
|
}
|