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.

66 lines
2.1 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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. import scala.annotation.nowarn
  15. @nowarn("msg=method get in class LeftProjection is deprecated")
  16. @nowarn("msg=method right in class Either is deprecated")
  17. @nowarn("msg=method get in class RightProjection is deprecated")
  18. class AssetManagerTest extends AnyFunSuite {
  19. val _assetManager: jmea.AssetManager = new DesktopAssetManager(true)
  20. val assetManager = new AssetManager(_assetManager)
  21. test("Test for AssetNotFound error") {
  22. val res =
  23. assetManager.loadModel(os.rel / "doesnotexist").attempt.runSyncUnsafe()
  24. assert(res.isLeft)
  25. assert(res.left.get eqv AssetNotFound("doesnotexist"))
  26. }
  27. test("Test for Model CouldNotCastError") {
  28. val modelPath = os.rel / "Models" / "Jaime" / "Jaime.j3o"
  29. val res1 = assetManager
  30. .loadModelAs[Geometry](modelPath)
  31. .attempt
  32. .runSyncUnsafe()
  33. assert(res1.isLeft)
  34. assert(res1.left.get eqv CouldNotCastError)
  35. val res2 = assetManager
  36. .loadModelAs[Node](modelPath)
  37. .attempt
  38. .runSyncUnsafe()
  39. assert(res2.isRight)
  40. assert(res2.map(_.getName).right.get eqv "JaimeGeom-ogremesh")
  41. }
  42. test("Test for Asset CouldNotCastError") {
  43. val assetPath = os.rel / "Common" / "MatDefs" / "Misc" / "Unshaded.j3md"
  44. val res1 = assetManager
  45. .loadAssetAs[Material](assetPath)
  46. .attempt
  47. .runSyncUnsafe()
  48. assert(res1.isLeft)
  49. assert(res1.left.get eqv CouldNotCastError)
  50. val res2 = assetManager
  51. .loadAssetAs[MaterialDef](assetPath)
  52. .attempt
  53. .runSyncUnsafe()
  54. assert(res2.isRight)
  55. assert(res2.map(_.getName).right.get eqv "Unshaded")
  56. }
  57. }