| | 1 | | using DCL; |
| | 2 | | using DCL.Components; |
| | 3 | | using DCL.Helpers; |
| | 4 | | using DCL.Models; |
| | 5 | | using Newtonsoft.Json; |
| | 6 | | using NUnit.Framework; |
| | 7 | | using System.Collections; |
| | 8 | | using DCL.Controllers; |
| | 9 | | using Tests; |
| | 10 | | using UnityEngine; |
| | 11 | | using UnityEngine.TestTools; |
| | 12 | | using UnityGLTF; |
| | 13 | |
|
| | 14 | | public class BIWSceneBoundarieShould : IntegrationTestSuite |
| | 15 | | { |
| | 16 | | protected override PlatformContext CreatePlatformContext() |
| | 17 | | { |
| 2 | 18 | | WebRequestController webRequestController = new WebRequestController(); |
| 2 | 19 | | webRequestController.Initialize( |
| | 20 | | genericWebRequest: new WebRequest(), |
| | 21 | | assetBundleWebRequest: new WebRequestAssetBundle(), |
| | 22 | | textureWebRequest: new WebRequestTexture(), |
| | 23 | | null); |
| | 24 | |
|
| 2 | 25 | | var context = DCL.Tests.PlatformContextFactory.CreateWithCustomMocks |
| | 26 | | ( |
| | 27 | | webRequestController: webRequestController |
| | 28 | | ); |
| | 29 | |
|
| 2 | 30 | | return context; |
| | 31 | | } |
| | 32 | |
|
| | 33 | | protected override WorldRuntimeContext CreateRuntimeContext() |
| | 34 | | { |
| 2 | 35 | | return DCL.Tests.WorldRuntimeContextFactory.CreateWithCustomMocks |
| | 36 | | ( |
| | 37 | | sceneController: new SceneController(), |
| | 38 | | state: new WorldState(), |
| | 39 | | componentFactory: new RuntimeComponentFactory(), |
| | 40 | | sceneBoundsChecker: new SceneBoundsChecker() |
| | 41 | | ); |
| | 42 | | } |
| | 43 | |
|
| | 44 | | [Test] |
| | 45 | | public void BuilderInWorldChangeFeedbackStyleChange() |
| | 46 | | { |
| | 47 | | //Arrange |
| 1 | 48 | | var biwStyle = new SceneBoundsFeedbackStyle_BIW(); |
| | 49 | |
|
| | 50 | | //Act |
| 1 | 51 | | Environment.i.world.sceneBoundsChecker.SetFeedbackStyle(biwStyle); |
| | 52 | |
|
| | 53 | | //Assert |
| 1 | 54 | | Assert.AreSame( Environment.i.world.sceneBoundsChecker.GetFeedbackStyle(), biwStyle ); |
| 1 | 55 | | } |
| | 56 | |
|
| | 57 | | [UnityTest] |
| | 58 | | public IEnumerator BuilderInWorldRendererEnableOutsideParcel() |
| | 59 | | { |
| | 60 | | //Arrange |
| 1 | 61 | | WebRequestController.Create(); |
| 1 | 62 | | ParcelScene scene = (ParcelScene) Environment.i.world.sceneController.CreateTestScene(); |
| | 63 | |
|
| 1 | 64 | | Environment.i.world.sceneBoundsChecker.SetFeedbackStyle(new SceneBoundsFeedbackStyle_Simple()); |
| 1 | 65 | | var biwStyle = new SceneBoundsFeedbackStyle_BIW(); |
| 1 | 66 | | string entityId = "1"; |
| 1 | 67 | | TestHelpers.CreateSceneEntity(scene, entityId); |
| | 68 | |
|
| 1 | 69 | | Assert.IsTrue( |
| | 70 | | scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() == null, |
| | 71 | | "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist"); |
| | 72 | |
|
| 1 | 73 | | TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject( |
| | 74 | | new |
| | 75 | | { |
| | 76 | | src = TestAssetsUtils.GetPath() + "/GLB/Trunk/Trunk.glb" |
| | 77 | | })); |
| | 78 | |
|
| 1 | 79 | | LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]); |
| 7 | 80 | | yield return new DCL.WaitUntil(() => gltfShape.alreadyLoaded); |
| | 81 | |
|
| | 82 | | //Act |
| 1 | 83 | | scene.entities[entityId].gameObject.transform.position = new Vector3(100, 100, 100); |
| 1 | 84 | | Environment.i.world.sceneBoundsChecker.SetFeedbackStyle(biwStyle); |
| | 85 | |
|
| 1 | 86 | | yield return null; |
| | 87 | |
|
| | 88 | | //Assert |
| 4 | 89 | | foreach (var renderer in scene.entities[entityId].renderers) |
| | 90 | | { |
| 1 | 91 | | Assert.IsTrue(renderer.enabled); |
| | 92 | | } |
| 1 | 93 | | } |
| | 94 | |
|
| 4 | 95 | | protected override IEnumerator TearDown() { yield return base.TearDown(); } |
| | 96 | | } |