Testing out JmonkeyEngine to make a game in Scala with Akka Actors within a pure FP layer
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.

59 lines
1.7 KiB

3 years ago
  1. package wow.doge.mygame
  2. import org.scalatest.funsuite.AnyFunSuite
  3. import monix.execution.Scheduler.Implicits.global
  4. import cats.syntax.eq._
  5. import com.jme3.{asset => jmea}
  6. import com.jme3.asset.DesktopAssetManager
  7. import wow.doge.mygame.utils.wrappers.jme.AssetManager
  8. import wow.doge.mygame.utils.wrappers.jme.AssetManager.AssetNotFound
  9. import com.jme3.scene.Geometry
  10. import wow.doge.mygame.utils.wrappers.jme.AssetManager.CouldNotCastError
  11. import com.jme3.scene.Node
  12. import com.jme3.material.MaterialDef
  13. import com.jme3.material.Material
  14. class AssetManagerTest extends AnyFunSuite {
  15. val _assetManager: jmea.AssetManager = new DesktopAssetManager(true)
  16. val assetManager = new AssetManager(_assetManager)
  17. test("Test for AssetNotFound error") {
  18. val res =
  19. assetManager.loadModel(os.rel / "doesnotexist").attempt.runSyncUnsafe()
  20. assert(res === Left(AssetNotFound("doesnotexist")))
  21. }
  22. test("Test for Model CouldNotCastError") {
  23. val modelPath = os.rel / "Models" / "Jaime" / "Jaime.j3o"
  24. val res1 = assetManager
  25. .loadModelAs[Geometry](modelPath)
  26. .attempt
  27. .runSyncUnsafe()
  28. assert(res1 === Left(CouldNotCastError))
  29. val res2 = assetManager
  30. .loadModelAs[Node](modelPath)
  31. .attempt
  32. .runSyncUnsafe()
  33. assert(res2.map(_.getName) === Right("JaimeGeom-ogremesh"))
  34. }
  35. test("Test for Asset CouldNotCastError") {
  36. val assetPath = os.rel / "Common" / "MatDefs" / "Misc" / "Unshaded.j3md"
  37. val res1 = assetManager
  38. .loadAssetAs[Material](assetPath)
  39. .attempt
  40. .runSyncUnsafe()
  41. assert(res1 === Left(CouldNotCastError))
  42. val res2 = assetManager
  43. .loadAssetAs[MaterialDef](assetPath)
  44. .attempt
  45. .runSyncUnsafe()
  46. assert(res2.map(_.getName) === Right("Unshaded"))
  47. }
  48. }