| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using DCL.Components; |
| | 4 | | using DCL.Helpers; |
| | 5 | | using DCL.Models; |
| | 6 | | using Newtonsoft.Json; |
| | 7 | | using NSubstitute.Extensions; |
| | 8 | | using NUnit.Framework; |
| | 9 | | using UnityEngine; |
| | 10 | | using UnityEngine.TestTools; |
| | 11 | |
|
| | 12 | | public class BIWPublishShould : IntegrationTestSuite_Legacy |
| | 13 | | { |
| | 14 | | private BuilderInWorldController controller; |
| | 15 | | private BIWPublishController biwPublishController; |
| | 16 | | private BuilderInWorldEntityHandler biwEntityHandler; |
| | 17 | |
|
| | 18 | | private const string entityId = "E1"; |
| | 19 | |
|
| | 20 | | protected override IEnumerator SetUp() |
| | 21 | | { |
| 3 | 22 | | yield return base.SetUp(); |
| 3 | 23 | | controller = Resources.FindObjectsOfTypeAll<BuilderInWorldController>()[0]; |
| | 24 | |
|
| 3 | 25 | | controller.InitGameObjects(); |
| 3 | 26 | | controller.FindSceneToEdit(); |
| 3 | 27 | | controller.InitControllers(); |
| | 28 | |
|
| 3 | 29 | | biwPublishController = controller.biwPublishController; |
| 3 | 30 | | biwPublishController.EnterEditMode(scene); |
| | 31 | |
|
| 3 | 32 | | biwEntityHandler = controller.builderInWorldEntityHandler; |
| 3 | 33 | | biwEntityHandler.EnterEditMode(scene); |
| 3 | 34 | | } |
| | 35 | |
|
| | 36 | | [Test] |
| | 37 | | public void TestEntityOutsidePublish() |
| | 38 | | { |
| | 39 | | //Arrange |
| 1 | 40 | | DCLBuilderInWorldEntity entity = biwEntityHandler.CreateEmptyEntity(scene, Vector3.zero, Vector3.zero); |
| | 41 | |
|
| | 42 | | //Act |
| 1 | 43 | | entity.gameObject.transform.position = Vector3.one * 9999; |
| | 44 | |
|
| | 45 | | //Assert |
| 1 | 46 | | Assert.IsFalse(biwPublishController.CanPublish()); |
| 1 | 47 | | } |
| | 48 | |
|
| | 49 | | [UnityTest] |
| | 50 | | public IEnumerator TestEntityInsidePublish() |
| | 51 | | { |
| | 52 | | //Arrange |
| 1 | 53 | | DCLBuilderInWorldEntity entity = biwEntityHandler.CreateEmptyEntity(scene, Vector3.zero, Vector3.zero); |
| 1 | 54 | | TestHelpers.CreateAndSetShape(scene, entity.rootEntity.entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.Ser |
| | 55 | | new |
| | 56 | | { |
| | 57 | | src = TestAssetsUtils.GetPath() + "/GLB/Trunk/Trunk.glb" |
| | 58 | | })); |
| | 59 | |
|
| 1 | 60 | | LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entity.rootEntity.entityId]); |
| 7 | 61 | | yield return new WaitUntil(() => gltfShape.alreadyLoaded); |
| | 62 | |
|
| | 63 | | //Act |
| 1 | 64 | | entity.rootEntity.gameObject.transform.position = new Vector3(5, 0, 5); |
| | 65 | |
|
| | 66 | | //Assert |
| 1 | 67 | | Assert.IsTrue(biwPublishController.CanPublish()); |
| 1 | 68 | | } |
| | 69 | |
|
| | 70 | | [Test] |
| | 71 | | public void TestMetricsPublish() |
| | 72 | | { |
| | 73 | | //Act |
| 404 | 74 | | for (int i = 0; i < scene.metricsController.GetLimits().entities + 1; i++) |
| | 75 | | { |
| 201 | 76 | | TestHelpers.CreateSceneEntity(scene, entityId + i); |
| | 77 | | } |
| | 78 | |
|
| | 79 | | //Assert |
| 1 | 80 | | Assert.IsFalse(biwPublishController.CanPublish()); |
| 1 | 81 | | } |
| | 82 | |
|
| | 83 | | protected override IEnumerator TearDown() |
| | 84 | | { |
| 3 | 85 | | controller.CleanItems(); |
| 3 | 86 | | yield return base.TearDown(); |
| 3 | 87 | | } |
| | 88 | | } |