| | 1 | | using DCL.Components; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using NUnit.Framework; |
| | 4 | | using System.Collections; |
| | 5 | | using UnityEngine; |
| | 6 | | using UnityEngine.SceneManagement; |
| | 7 | | using UnityEngine.TestTools; |
| | 8 | |
|
| | 9 | | public class BuilderMeshLoadingIndicator : IntegrationTestSuite_Legacy |
| | 10 | | { |
| 1 | 11 | | protected override bool justSceneSetUp => true; |
| | 12 | |
|
| | 13 | | [UnityTest] |
| | 14 | | public IEnumerator BuilderMeshLoadingIndicatorTest() |
| | 15 | | { |
| 1 | 16 | | SetUp_SceneController(); |
| 1 | 17 | | yield return SceneManager.LoadSceneAsync("BuilderScene", LoadSceneMode.Additive); |
| | 18 | |
|
| 1 | 19 | | var builderBridge = Object.FindObjectOfType<Builder.DCLBuilderBridge>(); |
| 1 | 20 | | builderBridge.ResetBuilderScene(); |
| | 21 | |
|
| 1 | 22 | | var objectEntity = TestHelpers.CreateSceneEntity(scene); |
| 1 | 23 | | var objectShape = TestHelpers.AttachGLTFShape(objectEntity, scene, new Vector3(8, 1, 8), new LoadableShape.Model |
| | 24 | | { |
| | 25 | | src = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb" |
| | 26 | | }); |
| | 27 | |
|
| 1 | 28 | | CheckActiveIndicatorsAmount(expectedAmount: 1); |
| | 29 | |
|
| 1 | 30 | | yield return TestHelpers.WaitForGLTFLoad(objectEntity); |
| | 31 | |
|
| 1 | 32 | | CheckActiveIndicatorsAmount(expectedAmount: 0); |
| | 33 | |
|
| 1 | 34 | | yield return SceneManager.UnloadSceneAsync("BuilderScene"); |
| 1 | 35 | | } |
| | 36 | |
|
| | 37 | | void CheckActiveIndicatorsAmount(int expectedAmount) |
| | 38 | | { |
| 2 | 39 | | var indicators = Object.FindObjectsOfType<Builder.MeshLoadIndicator.DCLBuilderMeshLoadIndicator>(); |
| | 40 | |
|
| 2 | 41 | | int activeIndicators = 0; |
| | 42 | |
|
| 6 | 43 | | for (int i = 0; i < indicators.Length; i++) |
| | 44 | | { |
| 1 | 45 | | if (indicators[i].gameObject.activeInHierarchy) |
| | 46 | | { |
| 1 | 47 | | activeIndicators++; |
| | 48 | | } |
| | 49 | | } |
| | 50 | |
|
| 2 | 51 | | Assert.AreEqual(expectedAmount, activeIndicators, $"Expected {expectedAmount} active loading indicator"); |
| 2 | 52 | | } |
| | 53 | | } |