diff --git a/com.unity.toon-graphics-test/Editor/UTSGraphicsTestSetup.cs b/com.unity.toon-graphics-test/Editor/UTSGraphicsTestSetup.cs index 03c7735ad..0fb27eb5b 100644 --- a/com.unity.toon-graphics-test/Editor/UTSGraphicsTestSetup.cs +++ b/com.unity.toon-graphics-test/Editor/UTSGraphicsTestSetup.cs @@ -1,10 +1,8 @@ -using System.Collections; -using System.Collections.Generic; +using System.Collections.Generic; using UnityEngine; -using UnityEditor; using UnityEditor.SceneManagement; -using Tests; using System.Linq; +using Unity.ToonShader.GraphicsTest; namespace UnityEditor.Rendering.Toon { @@ -109,12 +107,12 @@ void SetupScenes(int scneneIndex) { Debug.LogError("Unable to Find MainCamera in " + EditorBuildSettings.scenes[scneneIndex].path ); } - UTS_GraphicsTestSettings settings = cameraList[0].gameObject.GetComponent(); + UTSGraphicsTestSettings settings = cameraList[0].gameObject.GetComponent(); if ( settings == null ) { - settings = cameraList[0].gameObject.AddComponent(); + settings = cameraList[0].gameObject.AddComponent(); } settings.ImageComparisonSettings.ImageResolution = UnityEngine.TestTools.Graphics.ImageComparisonSettings.Resolution.w960h540; settings.ImageComparisonSettings.PerPixelCorrectnessThreshold = 0.005f; diff --git a/com.unity.toon-graphics-test/Runtime/UTS_GraphicsTestSettings.cs b/com.unity.toon-graphics-test/Runtime/UTSGraphicsTestSettings.cs similarity index 83% rename from com.unity.toon-graphics-test/Runtime/UTS_GraphicsTestSettings.cs rename to com.unity.toon-graphics-test/Runtime/UTSGraphicsTestSettings.cs index cad041fb3..bf37d238e 100644 --- a/com.unity.toon-graphics-test/Runtime/UTS_GraphicsTestSettings.cs +++ b/com.unity.toon-graphics-test/Runtime/UTSGraphicsTestSettings.cs @@ -1,8 +1,8 @@ using UnityEngine.TestTools.Graphics; -namespace Tests +namespace Unity.ToonShader.GraphicsTest { - public class UTS_GraphicsTestSettings : GraphicsTestSettings + public class UTSGraphicsTestSettings : GraphicsTestSettings { public int WaitFrames = 0; public bool XRCompatible = true; @@ -12,7 +12,7 @@ public class UTS_GraphicsTestSettings : GraphicsTestSettings public bool CheckMemoryAllocation = true; #endif //#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX - public UTS_GraphicsTestSettings() + public UTSGraphicsTestSettings() { ImageComparisonSettings.TargetWidth = 960; ImageComparisonSettings.TargetHeight = 540; diff --git a/com.unity.toon-graphics-test/Runtime/UTS_GraphicsTestSettings.cs.meta b/com.unity.toon-graphics-test/Runtime/UTSGraphicsTestSettings.cs.meta similarity index 100% rename from com.unity.toon-graphics-test/Runtime/UTS_GraphicsTestSettings.cs.meta rename to com.unity.toon-graphics-test/Runtime/UTSGraphicsTestSettings.cs.meta diff --git a/com.unity.toon-graphics-test/Runtime/UTS_GraphicsTests.cs b/com.unity.toon-graphics-test/Runtime/UTSGraphicsTests.cs similarity index 74% rename from com.unity.toon-graphics-test/Runtime/UTS_GraphicsTests.cs rename to com.unity.toon-graphics-test/Runtime/UTSGraphicsTests.cs index b84cfa596..abbe1b1c8 100644 --- a/com.unity.toon-graphics-test/Runtime/UTS_GraphicsTests.cs +++ b/com.unity.toon-graphics-test/Runtime/UTSGraphicsTests.cs @@ -1,16 +1,14 @@ using System.Collections; -using System.Linq; using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; using UnityEngine.TestTools.Graphics; using UnityEngine.SceneManagement; using System.IO; -using Unity.ToonShader.GraphicsTest; using UnityEditor; -namespace Tests +namespace Unity.ToonShader.GraphicsTest { #if UNITY_EDITOR public class UTSGraphicsTestsXR { @@ -46,8 +44,7 @@ public IEnumerator Run(GraphicsTestCase testCase) { Assert.IsTrue(File.Exists(xrImagePath),$"XR Reference image not found at: {xrImagePath}"); testCase.ReferenceImage = AssetDatabase.LoadAssetAtPath(xrImagePath); - //Unity.ToonShader.GraphicsTest.SetupUTSGraphicsXRTestCases.Setup(); - yield return UTS_GraphicsTests.RunInternal(testCase, isXR:true); + yield return UTSGraphicsTests.RunInternal(testCase, isXR:true); XRUtility.DisableXR(); } @@ -61,27 +58,21 @@ public class UTSGraphicsTestsNonXR { [UseGraphicsTestCases(UTSGraphicsTestConstants.ReferenceImagePath)] [Timeout(3600000)] //1 hour public IEnumerator Run(GraphicsTestCase testCase) { - //[TODO-sin: 2025-7-2] Hack for now to disable XR for non-Stereo projects - string projectName = Path.GetFileName(Path.GetDirectoryName(UnityEngine.Application.dataPath)); - if (!string.IsNullOrEmpty(projectName) && !projectName.Contains("Stereo")) { - XRUtility.DisableXR(); - } - - yield return UTS_GraphicsTests.RunInternal(testCase); + yield return UTSGraphicsTests.RunInternal(testCase); } } //---------------------------------------------------------------------------------------------------------------------- - public class UTS_GraphicsTests { + public static class UTSGraphicsTests { internal static IEnumerator RunInternal(GraphicsTestCase testCase, bool isXR = false) { SceneManager.LoadScene(testCase.ScenePath); // Always wait one frame for scene load yield return null; - var cameras = GameObject.FindGameObjectsWithTag("MainCamera").Select(x => x.GetComponent()); - UTS_GraphicsTestSettings settings = Object.FindFirstObjectByType(); + Camera mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent(); + UTSGraphicsTestSettings settings = Object.FindFirstObjectByType(); Assert.IsNotNull(settings, "Invalid test scene, couldn't find UTS_GraphicsTestSettings"); if (isXR) { @@ -94,8 +85,7 @@ internal static IEnumerator RunInternal(GraphicsTestCase testCase, bool isXR = f int waitFrames = settings.WaitFrames; - if (settings.ImageComparisonSettings.UseBackBuffer && settings.WaitFrames < 1) - { + if (settings.ImageComparisonSettings.UseBackBuffer && settings.WaitFrames < 1) { waitFrames = 1; } @@ -103,12 +93,11 @@ internal static IEnumerator RunInternal(GraphicsTestCase testCase, bool isXR = f for (int i = 0; i < waitFrames; i++) yield return new WaitForEndOfFrame(); - ImageAssert.AreEqual(testCase.ReferenceImage, cameras.Where(x => x != null), + ImageAssert.AreEqual(testCase.ReferenceImage, mainCamera, settings.ImageComparisonSettings, testCase.ReferenceImagePathLog); // Does it allocate memory when it renders what's on the main camera? bool allocatesMemory = false; - var mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent(); if (settings == null || settings.CheckMemoryAllocation) { @@ -124,22 +113,6 @@ internal static IEnumerator RunInternal(GraphicsTestCase testCase, bool isXR = f Assert.Fail("Allocated memory when rendering what is on main camera"); } } - - public static Texture2D LoadPNG(string filePath) - { - - Texture2D tex2D = null; - byte[] fileData; - - if (File.Exists(filePath)) - { - fileData = File.ReadAllBytes(filePath); - tex2D = new Texture2D(2, 2); - tex2D.LoadImage(fileData); - } - return tex2D; - } } - } diff --git a/com.unity.toon-graphics-test/Runtime/UTS_GraphicsTests.cs.meta b/com.unity.toon-graphics-test/Runtime/UTSGraphicsTests.cs.meta similarity index 100% rename from com.unity.toon-graphics-test/Runtime/UTS_GraphicsTests.cs.meta rename to com.unity.toon-graphics-test/Runtime/UTSGraphicsTests.cs.meta