| | 1 | | using NUnit.Framework; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.TestTools; |
| | 6 | |
|
| | 7 | | namespace Tests |
| | 8 | | { |
| | 9 | | public class NavmapTests : IntegrationTestSuite_Legacy |
| | 10 | | { |
| | 11 | | private MinimapHUDController controller; |
| | 12 | | DCL.NavmapView navmapView; |
| 1 | 13 | | protected override bool justSceneSetUp => true; |
| | 14 | |
|
| | 15 | | [UnitySetUp] |
| | 16 | | protected override IEnumerator SetUp() |
| | 17 | | { |
| 1 | 18 | | yield return base.SetUp(); |
| | 19 | |
|
| 1 | 20 | | controller = new MinimapHUDController(); |
| 1 | 21 | | navmapView = Object.FindObjectOfType<DCL.NavmapView>(); |
| 1 | 22 | | } |
| | 23 | |
|
| | 24 | | protected override IEnumerator TearDown() |
| | 25 | | { |
| 1 | 26 | | controller.Dispose(); |
| 1 | 27 | | yield return base.TearDown(); |
| 1 | 28 | | } |
| | 29 | |
|
| | 30 | | [UnityTest] |
| | 31 | | [Explicit] |
| | 32 | | [Category("Explicit")] |
| | 33 | | public IEnumerator Toggle() |
| | 34 | | { |
| 0 | 35 | | InputAction_Trigger action = null; |
| 0 | 36 | | var inputController = GameObject.FindObjectOfType<InputController>(); |
| 0 | 37 | | for (int i = 0; i < inputController.triggerTimeActions.Length; i++) |
| | 38 | | { |
| | 39 | | // Find the open nav map action used by the input controller |
| 0 | 40 | | if (inputController.triggerTimeActions[i].GetDCLAction() == DCLAction_Trigger.ToggleNavMap) |
| | 41 | | { |
| 0 | 42 | | action = inputController.triggerTimeActions[i]; |
| 0 | 43 | | break; |
| | 44 | | } |
| | 45 | | } |
| | 46 | |
|
| 0 | 47 | | Assert.IsNotNull(action); |
| | 48 | |
|
| 0 | 49 | | action.RaiseOnTriggered(); |
| | 50 | |
|
| 0 | 51 | | yield return null; |
| | 52 | |
|
| 0 | 53 | | Assert.IsTrue(navmapView.scrollRect.gameObject.activeSelf); |
| | 54 | |
|
| 0 | 55 | | action.RaiseOnTriggered(); |
| | 56 | |
|
| 0 | 57 | | yield return null; |
| | 58 | |
|
| 0 | 59 | | Assert.IsFalse(navmapView.scrollRect.gameObject.activeSelf); |
| 0 | 60 | | } |
| | 61 | |
|
| | 62 | | [Test] |
| | 63 | | public void ReactToPlayerCoordsChange() |
| | 64 | | { |
| | 65 | | const string sceneName = "SCENE_NAME"; |
| 1 | 66 | | MinimapMetadata.GetMetadata() |
| | 67 | | .AddSceneInfo( |
| | 68 | | new MinimapMetadata.MinimapSceneInfo |
| | 69 | | { |
| | 70 | | parcels = new List<Vector2Int> |
| | 71 | | { |
| | 72 | | new Vector2Int(-77, -77) |
| | 73 | | }, |
| | 74 | | name = sceneName |
| | 75 | | }); |
| 1 | 76 | | CommonScriptableObjects.playerCoords.Set(new Vector2Int(-77, -77)); |
| 1 | 77 | | Assert.AreEqual(sceneName, navmapView.currentSceneNameText.text); |
| 1 | 78 | | Assert.AreEqual("-77,-77", navmapView.currentSceneCoordsText.text); |
| 1 | 79 | | } |
| | 80 | | } |
| | 81 | | } |