< Summary

Class:Tests.TexturesTests
Assembly:TexturesTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Textures/Tests/TexturesTests.cs
Covered lines:28
Uncovered lines:0
Coverable lines:28
Total lines:74
Line coverage:100% (28 of 28)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
TextureCreateAndLoadTest()0%440100%
TextureAttachedGetsReplacedOnNewAttachment()0%330100%
Texture_OnReadyBeforeLoading()0%110100%
Texture_OnReadyWaitLoading()0%330100%
Texture_OnReadyAfterLoadingInstantlyCalled()0%330100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Textures/Tests/TexturesTests.cs

#LineLine coverage
 1using DCL;
 2using DCL.Helpers;
 3using DCL.Models;
 4using NUnit.Framework;
 5using System.Collections;
 6using UnityEngine;
 7using UnityEngine.TestTools;
 8
 9namespace Tests
 10{
 11    public class TexturesTests : IntegrationTestSuite_Legacy
 12    {
 13        // A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use
 14        // `yield return null;` to skip a frame.
 15        [UnityTest]
 16        public IEnumerator TextureCreateAndLoadTest()
 17        {
 118            DCLTexture dclTexture = TestHelpers.CreateDCLTexture(scene,
 19                TestAssetsUtils.GetPath() + "/Images/avatar.png",
 20                DCLTexture.BabylonWrapMode.CLAMP,
 21                FilterMode.Bilinear);
 22
 123            yield return dclTexture.routine;
 24
 125            Assert.IsTrue(dclTexture.texture != null, "Texture didn't load correctly?");
 126            Assert.IsTrue(dclTexture.unityWrap == TextureWrapMode.Clamp, "Bad wrap mode!");
 127            Assert.IsTrue(dclTexture.unitySamplingMode == FilterMode.Bilinear, "Bad sampling mode!");
 28
 129            dclTexture.Dispose();
 30
 131            yield return null;
 132            Assert.IsTrue(dclTexture.texture == null, "Texture didn't dispose correctly?");
 133        }
 34
 35        [UnityTest]
 36        public IEnumerator TextureAttachedGetsReplacedOnNewAttachment()
 37        {
 138            yield return TestHelpers.TestAttachedSharedComponentOfSameTypeIsReplaced<DCLTexture.Model, DCLTexture>(
 39                scene, CLASS_ID.TEXTURE);
 140        }
 41
 42        [Test]
 43        public void Texture_OnReadyBeforeLoading()
 44        {
 145            DCLTexture dclTexture = TestHelpers.CreateDCLTexture(scene, TestAssetsUtils.GetPath() + "/Images/avatar.png"
 146            bool isOnReady = false;
 347            dclTexture.CallWhenReady((x) => { isOnReady = true; });
 48
 149            Assert.IsTrue(isOnReady); //DCLTexture is ready on creation
 150        }
 51
 52        [UnityTest]
 53        public IEnumerator Texture_OnReadyWaitLoading()
 54        {
 155            DCLTexture dclTexture = TestHelpers.CreateDCLTexture(scene, TestAssetsUtils.GetPath() + "/Images/avatar.png"
 156            bool isOnReady = false;
 357            dclTexture.CallWhenReady((x) => { isOnReady = true; });
 158            yield return dclTexture.routine;
 59
 160            Assert.IsTrue(isOnReady);
 161        }
 62
 63        [UnityTest]
 64        public IEnumerator Texture_OnReadyAfterLoadingInstantlyCalled()
 65        {
 166            DCLTexture dclTexture = TestHelpers.CreateDCLTexture(scene, TestAssetsUtils.GetPath() + "/Images/avatar.png"
 167            yield return dclTexture.routine;
 68
 169            bool isOnReady = false;
 370            dclTexture.CallWhenReady((x) => { isOnReady = true; });
 171            Assert.IsTrue(isOnReady);
 172        }
 73    }
 74}