using System; using NUnit.Framework; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; namespace UnityEditor.Rendering.HighDefinition.Test.GlobalSettingsMigration { class CustomPostProcessOrdersMigrationTests : RenderPipelineGraphicsSettingsMigrationTestBase { [Serializable, HideInInspector] class CustomPostProcessesTestComponent : CustomPostProcessVolumeComponent, IPostProcessComponent { // For testing purposes we do not have a correct injection point for each setting as is not checked. public override CustomPostProcessInjectionPoint injectionPoint => CustomPostProcessInjectionPoint.AfterOpaqueAndSky; public override void Setup() { } public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination) { } public override void Cleanup() { } public bool IsActive() => false; } class TestCase : IRenderPipelineGraphicsSettingsTestCase { public void SetUp(HDRenderPipelineGlobalSettings globalSettingsAsset, HDRenderPipelineAsset renderPipelineAsset) { var type = typeof(CustomPostProcessesTestComponent).AssemblyQualifiedName; #pragma warning disable 618 // Type or member is obsolete globalSettingsAsset.beforePostProcessCustomPostProcesses.Add(type); globalSettingsAsset.beforeTransparentCustomPostProcesses.Add(type); globalSettingsAsset.afterPostProcessBlursCustomPostProcesses.Add(type); globalSettingsAsset.afterPostProcessCustomPostProcesses.Add(type); globalSettingsAsset.beforeTAACustomPostProcesses.Add(type); #pragma warning restore 618 globalSettingsAsset.m_Version = HDRenderPipelineGlobalSettings.Version.CustomPostProcessOrdersSettings - 1; } public bool IsMigrationCorrect(CustomPostProcessOrdersSettings settings, out string message) { message = string.Empty; bool isMigrationCorrect = true; isMigrationCorrect &= settings.beforePostProcessCustomPostProcesses.Contains(); isMigrationCorrect &= settings.beforeTransparentCustomPostProcesses.Contains(); isMigrationCorrect &= settings.afterPostProcessBlursCustomPostProcesses.Contains(); isMigrationCorrect &= settings.afterPostProcessCustomPostProcesses.Contains(); isMigrationCorrect &= settings.beforeTAACustomPostProcesses.Contains(); if (!isMigrationCorrect) message = $"{nameof(CustomPostProcessesTestComponent)} has not been found in some list"; return isMigrationCorrect; } } static TestCaseData[] s_TestCaseDatas = { new TestCaseData(new TestCase()) .SetName("When performing a migration of CustomPostProcessOrdersSettings, settings are being transferred correctly") }; [Test, TestCaseSource(nameof(s_TestCaseDatas))] public void PerformMigration(IRenderPipelineGraphicsSettingsTestCase testCase) { base.DoTest(testCase); } } }