您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
40 行
1.3 KiB
40 行
1.3 KiB
using System.Collections;
|
|
using NUnit.Framework;
|
|
using UnityEngine;
|
|
using UnityEngine.TestTools;
|
|
using UnityEngine.TestTools.Graphics;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class LWGraphicsTests
|
|
{
|
|
|
|
public const string lwPackagePath = "Packages/com.unity.testing.srp.lightweight/Tests/ReferenceImages";
|
|
|
|
[UnityTest, Category("LightWeightRP")]
|
|
[PrebuildSetup("SetupGraphicsTestCases")]
|
|
[UseGraphicsTestCases(lwPackagePath)]
|
|
public IEnumerator Run(GraphicsTestCase testCase)
|
|
{
|
|
SceneManager.LoadScene(testCase.ScenePath);
|
|
|
|
// Always wait one frame for scene load
|
|
yield return null;
|
|
|
|
var camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
|
|
var settings = Object.FindObjectOfType<LWGraphicsTestSettings>();
|
|
Assert.IsNotNull(settings, "Invalid test scene, couldn't find PostProcessingGraphicsTestSettings");
|
|
|
|
for (int i = 0; i < settings.WaitFrames; i++)
|
|
yield return null;
|
|
|
|
ImageAssert.AreEqual(testCase.ReferenceImage, camera, settings.ImageComparisonSettings);
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
[TearDown]
|
|
public void DumpImagesInEditor()
|
|
{
|
|
UnityEditor.TestTools.Graphics.ResultsUtility.ExtractImagesFromTestProperties(TestContext.CurrentContext.Test);
|
|
}
|
|
#endif
|
|
}
|