| | 1 | | using Newtonsoft.Json; |
| | 2 | | using NUnit.Framework; |
| | 3 | | using System.Collections; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.TestTools; |
| | 6 | |
|
| | 7 | | namespace CameraController_Test |
| | 8 | | { |
| | 9 | | public class CameraControllerShould : IntegrationTestSuite_Legacy |
| | 10 | | { |
| 0 | 11 | | protected override bool enableSceneIntegrityChecker => false; |
| | 12 | |
|
| | 13 | | [Test] |
| | 14 | | public void ReactToCameraChangeAction() |
| | 15 | | { |
| 1 | 16 | | var currentCamera = CommonScriptableObjects.cameraMode.Get(); |
| 1 | 17 | | cameraController.cameraChangeAction.RaiseOnTriggered(); |
| | 18 | |
|
| 1 | 19 | | Assert.AreNotEqual(currentCamera, CommonScriptableObjects.cameraMode.Get()); |
| 1 | 20 | | } |
| | 21 | |
|
| | 22 | | [Test] |
| | 23 | | [TestCase(CameraMode.ModeId.FirstPerson)] |
| | 24 | | [TestCase(CameraMode.ModeId.ThirdPerson)] |
| | 25 | | public void LiveCameraIsOn(CameraMode.ModeId cameraMode) |
| | 26 | | { |
| 2 | 27 | | cameraController.SetCameraMode(cameraMode); |
| 2 | 28 | | Assert.IsTrue(cameraController.currentCameraState.defaultVirtualCamera.gameObject.activeInHierarchy); |
| 2 | 29 | | } |
| | 30 | |
|
| | 31 | | [Test] |
| | 32 | | [TestCase(1, 0, 0)] |
| | 33 | | [TestCase(0, 0, 1)] |
| | 34 | | [TestCase(1, 0, 1)] |
| | 35 | | [TestCase(-1, 0, 0)] |
| | 36 | | [TestCase(0, 0, -1)] |
| | 37 | | [TestCase(-1, 0, -1)] |
| | 38 | | public void ReactToSetRotation(float lookAtX, float lookAtY, float lookAtZ) |
| | 39 | | { |
| 6 | 40 | | var payload = new DCL.Camera.CameraController.SetRotationPayload() |
| | 41 | | { |
| | 42 | | x = 0, |
| | 43 | | y = 0, |
| | 44 | | z = 0, |
| | 45 | | cameraTarget = new Vector3(lookAtX, lookAtY, lookAtZ) |
| | 46 | | }; |
| | 47 | |
|
| 6 | 48 | | var rotationEuler = Quaternion.LookRotation(payload.cameraTarget.Value).eulerAngles; |
| | 49 | |
|
| 6 | 50 | | cameraController.SetRotation(JsonConvert.SerializeObject(payload, Formatting.None, new JsonSerializerSetting |
| | 51 | | { |
| | 52 | | ReferenceLoopHandling = ReferenceLoopHandling.Ignore |
| | 53 | | })); |
| | 54 | |
|
| 6 | 55 | | Assert.AreEqual(cameraController.GetRotation().y, rotationEuler.y); |
| 6 | 56 | | Assert.AreEqual(cameraController.GetRotation().x, rotationEuler.x); |
| 6 | 57 | | } |
| | 58 | |
|
| | 59 | | [UnityTest] |
| | 60 | | public IEnumerator ActivateAndDeactivateWithKernelRenderingToggleEvents() |
| | 61 | | { |
| 1 | 62 | | RenderingController renderingController = GameObject.FindObjectOfType<RenderingController>(); |
| 1 | 63 | | renderingController.DeactivateRendering(); |
| 1 | 64 | | Assert.IsFalse(cameraController.camera.enabled); |
| | 65 | |
|
| 1 | 66 | | yield return null; |
| | 67 | |
|
| 1 | 68 | | renderingController.renderingActivatedAckLock.RemoveAllLocks(); |
| 1 | 69 | | renderingController.ActivateRendering(); |
| 1 | 70 | | Assert.IsTrue(cameraController.camera.enabled); |
| 1 | 71 | | } |
| | 72 | | } |
| | 73 | | } |