| | 1 | | using DCL; |
| | 2 | | using NUnit.Framework; |
| | 3 | | using System.Collections; |
| | 4 | | using System.Collections.Generic; |
| | 5 | | using UnityEngine; |
| | 6 | | using UnityEngine.TestTools; |
| | 7 | |
|
| | 8 | | namespace Tests |
| | 9 | | { |
| | 10 | | public class NavmapToastViewShould : IntegrationTestSuite_Legacy |
| | 11 | | { |
| | 12 | | NavmapToastView navmapToastView; |
| | 13 | | private NavmapView navmapView; |
| 2 | 14 | | protected override bool justSceneSetUp => true; |
| | 15 | |
|
| | 16 | | [UnitySetUp] |
| | 17 | | protected override IEnumerator SetUp() |
| | 18 | | { |
| 2 | 19 | | yield return base.SetUp(); |
| 2 | 20 | | yield return null; |
| | 21 | |
|
| 2 | 22 | | navmapView = Object.FindObjectOfType<NavmapView>(); |
| 2 | 23 | | navmapToastView = navmapView.toastView; |
| | 24 | |
|
| 2 | 25 | | if (!NavmapView.isOpen) |
| 1 | 26 | | navmapView.ToggleNavMap(); |
| 2 | 27 | | } |
| | 28 | |
|
| | 29 | | protected override IEnumerator TearDown() |
| | 30 | | { |
| 2 | 31 | | navmapView.Initialize(); |
| 2 | 32 | | yield return base.TearDown(); |
| 2 | 33 | | } |
| | 34 | |
|
| | 35 | | [Test] |
| | 36 | | public void CloseWhenCloseButtonIsClicked() |
| | 37 | | { |
| 1 | 38 | | var sceneInfo = new MinimapMetadata.MinimapSceneInfo() |
| | 39 | | { |
| | 40 | | name = "foo", |
| | 41 | | owner = null, |
| | 42 | | description = "", |
| | 43 | | isPOI = false, |
| | 44 | | parcels = new List<Vector2Int>() { new Vector2Int(10, 10), new Vector2Int(10, 11), new Vector2Int(10, 12 |
| | 45 | | }; |
| | 46 | |
|
| 1 | 47 | | MinimapMetadata.GetMetadata().Clear(); |
| 1 | 48 | | MinimapMetadata.GetMetadata().AddSceneInfo(sceneInfo); |
| | 49 | |
|
| 1 | 50 | | navmapToastView.Populate(new Vector2Int(10, 11), sceneInfo); |
| 1 | 51 | | Assert.IsTrue(navmapToastView.gameObject.activeSelf); |
| 1 | 52 | | navmapToastView.OnCloseClick(); |
| 1 | 53 | | Assert.IsFalse(navmapToastView.gameObject.activeSelf); |
| 1 | 54 | | } |
| | 55 | |
|
| | 56 | | [Test] |
| | 57 | | [Explicit("This fails only on run all for some reason")] |
| | 58 | | [Category("Explicit")] |
| | 59 | | public void BePopulatedCorrectlyWithNullOrEmptyElements() |
| | 60 | | { |
| 0 | 61 | | var sceneInfo = new MinimapMetadata.MinimapSceneInfo() |
| | 62 | | { |
| | 63 | | name = "foo", |
| | 64 | | owner = null, |
| | 65 | | description = "", |
| | 66 | | isPOI = false, |
| | 67 | | parcels = new List<Vector2Int>() { new Vector2Int(10, 10), new Vector2Int(10, 11), new Vector2Int(10, 12 |
| | 68 | | }; |
| | 69 | |
|
| 0 | 70 | | MinimapMetadata.GetMetadata().Clear(); |
| 0 | 71 | | MinimapMetadata.GetMetadata().AddSceneInfo(sceneInfo); |
| | 72 | |
|
| 0 | 73 | | navmapToastView.Populate(new Vector2Int(10, 11), sceneInfo); |
| 0 | 74 | | Assert.IsTrue(navmapToastView.gameObject.activeSelf); |
| | 75 | |
|
| 0 | 76 | | Assert.IsTrue(navmapToastView.sceneLocationText.transform.parent.gameObject.activeInHierarchy); |
| 0 | 77 | | Assert.AreEqual("10, 11", navmapToastView.sceneLocationText.text); |
| | 78 | |
|
| 0 | 79 | | Assert.IsTrue(navmapToastView.sceneTitleText.transform.parent.gameObject.activeInHierarchy); |
| 0 | 80 | | Assert.IsFalse(navmapToastView.sceneOwnerText.transform.parent.gameObject.activeInHierarchy); |
| 0 | 81 | | Assert.IsFalse(navmapToastView.scenePreviewContainer.gameObject.activeInHierarchy); |
| 0 | 82 | | } |
| | 83 | |
|
| | 84 | | [Test] |
| | 85 | | public void BePopulatedCorrectly() |
| | 86 | | { |
| 1 | 87 | | var sceneInfo = new MinimapMetadata.MinimapSceneInfo() |
| | 88 | | { |
| | 89 | | name = "foo", |
| | 90 | | owner = "bar", |
| | 91 | | description = "foobar", |
| | 92 | | isPOI = false, |
| | 93 | | parcels = new List<Vector2Int>() { new Vector2Int(10, 10), new Vector2Int(10, 11), new Vector2Int(10, 12 |
| | 94 | | }; |
| | 95 | |
|
| 1 | 96 | | MinimapMetadata.GetMetadata().Clear(); |
| 1 | 97 | | MinimapMetadata.GetMetadata().AddSceneInfo(sceneInfo); |
| | 98 | |
|
| 1 | 99 | | navmapToastView.Populate(new Vector2Int(10, 10), sceneInfo); |
| 1 | 100 | | Assert.IsTrue(navmapToastView.gameObject.activeSelf); |
| | 101 | |
|
| 1 | 102 | | Assert.AreEqual(sceneInfo.name, navmapToastView.sceneTitleText.text); |
| 1 | 103 | | Assert.AreEqual($"Created by: {sceneInfo.owner}", navmapToastView.sceneOwnerText.text); |
| 1 | 104 | | Assert.AreEqual("10, 10", navmapToastView.sceneLocationText.text); |
| | 105 | |
|
| 1 | 106 | | Assert.IsTrue(navmapToastView.sceneTitleText.gameObject.activeInHierarchy); |
| 1 | 107 | | Assert.IsTrue(navmapToastView.sceneOwnerText.gameObject.activeInHierarchy); |
| 1 | 108 | | } |
| | 109 | | } |
| | 110 | | } |