-
Notifications
You must be signed in to change notification settings - Fork 870
Expand file tree
/
Copy pathPostProcessingGraphicsTests.cs
More file actions
44 lines (35 loc) · 1.31 KB
/
PostProcessingGraphicsTests.cs
File metadata and controls
44 lines (35 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using UnityEngine.TestTools.Graphics;
using UnityEngine.SceneManagement;
public class PostProcessingGraphicsTests
{
[UnityTest, Category("PostProcessing")]
[PrebuildSetup("SetupGraphicsTestCases")]
[UseGraphicsTestCases]
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>();
#if UNITY_2020_3_OR_NEWER
var settings = Object.FindAnyObjectByType<PostProcessingGraphicsTestSettings>();
#else
var settings = Object.FindObjectOfType<PostProcessingGraphicsTestSettings>();
#endif
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
}