Rasagar/Library/PackageCache/com.unity.render-pipelines.high-definition/Tests/Editor/HDLightDataTests.cs
2024-08-26 23:07:20 +03:00

56 lines
1.9 KiB
C#

using NUnit.Framework;
using UnityEditor;
namespace UnityEngine.Rendering.HighDefinition.Tests
{
class HDLightDataTests
{
GameObject m_Root;
[SetUp]
public void SetUp()
{
if (GraphicsSettings.currentRenderPipeline is not HDRenderPipelineAsset)
Assert.Ignore("This is an HDRP Tests, and the current pipeline is not HDRP.");
m_Root = new GameObject("TEST_HDLightDataTests");
m_Root.AddComponent<Light>();
m_Root.AddComponent<HDAdditionalLightData>();
m_Root.SetActive(false);
}
[TearDown]
public void TearDown()
{
if (m_Root != null)
CoreUtils.Destroy(m_Root);
}
[Test]
[TestCase(LightType.Tube)]
[TestCase(LightType.Disc)]
[TestCase(LightType.Point)]
public void TestUpdateMesh(LightType type)
{
var light = m_Root.GetComponent<Light>();
light.type = type;
var additionalLightData = m_Root.GetComponent<HDAdditionalLightData>();
additionalLightData.displayAreaLightEmissiveMesh = true;
m_Root.GetComponent<HDAdditionalLightData>().UpdateAreaLightEmissiveMesh();
if (type.IsArea())
{
Assert.IsTrue(GraphicsSettings.TryGetRenderPipelineSettings<HDRenderPipelineRuntimeAssets>(out var assets));
string expectedPath = AssetDatabase.GetAssetPath(type == LightType.Tube ? assets.emissiveCylinderMesh : assets.emissiveQuadMesh);
string meshPath = AssetDatabase.GetAssetPath(additionalLightData.m_EmissiveMeshFilter.sharedMesh);
Assert.AreEqual(expectedPath, meshPath);
}
else
{
Assert.IsNull(additionalLightData.m_EmissiveMeshFilter);
}
}
}
}