| | 1 | | using System; |
| | 2 | | using NUnit.Framework; |
| | 3 | | using System.Collections; |
| | 4 | | using DCL; |
| | 5 | | using UnityEngine.TestTools; |
| | 6 | |
|
| | 7 | | namespace Tests |
| | 8 | | { |
| | 9 | | public class HUDControllerShould : IntegrationTestSuite_Legacy |
| | 10 | | { |
| 2 | 11 | | protected override bool justSceneSetUp => true; |
| | 12 | |
|
| | 13 | | private IHUDController hudController = null; |
| | 14 | |
|
| | 15 | | protected override IEnumerator SetUp() |
| | 16 | | { |
| 2 | 17 | | hudController = DCL.Environment.i.hud.controller; |
| 2 | 18 | | yield return base.SetUp(); |
| 2 | 19 | | hudController.Cleanup(); |
| 2 | 20 | | } |
| | 21 | |
|
| | 22 | | protected override IEnumerator TearDown() |
| | 23 | | { |
| 2 | 24 | | hudController.Cleanup(); |
| 2 | 25 | | yield return base.TearDown(); |
| 2 | 26 | | } |
| | 27 | |
|
| | 28 | | [UnityTest] |
| | 29 | | public IEnumerator NotCreateHUDsInitially() |
| | 30 | | { |
| | 31 | | // There must be a hud controller |
| 1 | 32 | | Assert.IsNotNull(hudController, "There must be a HUDController in the scene"); |
| | 33 | |
|
| 1 | 34 | | hudController.Cleanup(); |
| | 35 | | // HUD controllers are created |
| 60 | 36 | | for (int i = 1; i < (int) HUDElementID.COUNT; i++) |
| | 37 | | { |
| 29 | 38 | | Assert.IsNull(hudController.GetHUDElement((HUDElementID) i)); |
| | 39 | | } |
| | 40 | |
|
| 1 | 41 | | yield break; |
| | 42 | | } |
| | 43 | |
|
| | 44 | | [UnityTest] |
| | 45 | | public IEnumerator CreateHudIfConfigurationIsActive() |
| | 46 | | { |
| | 47 | | // There must be a hud controller |
| 1 | 48 | | Assert.IsNotNull(hudController, "There must be a HUDController in the scene"); |
| | 49 | |
|
| 1 | 50 | | HUDConfiguration config = new HUDConfiguration() { active = true, visible = true }; |
| | 51 | |
|
| 60 | 52 | | for (int i = 1; i < (int) HUDElementID.COUNT; i++) |
| | 53 | | { |
| 29 | 54 | | hudController.ConfigureHUDElement((HUDElementID) i, config, null); |
| | 55 | | } |
| | 56 | |
|
| 1 | 57 | | yield return null; |
| | 58 | |
|
| | 59 | | // HUD controllers are created |
| 60 | 60 | | for (int i = 1; i < (int) HUDElementID.COUNT; i++) |
| | 61 | | { |
| 29 | 62 | | HUDElementID elementID = (HUDElementID) i; |
| 29 | 63 | | if (HUDController.IsHUDElementDeprecated(elementID)) |
| | 64 | | continue; |
| | 65 | |
|
| 27 | 66 | | Assert.IsNotNull(hudController.GetHUDElement(elementID), $"Failed to create {elementID}"); |
| | 67 | | } |
| 1 | 68 | | } |
| | 69 | | } |
| | 70 | | } |