No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DefaultVolumeProfileMigrationTest.cs 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using NUnit.Framework;
  2. using UnityEngine;
  3. using UnityEngine.Rendering;
  4. using UnityEngine.Rendering.Universal;
  5. namespace UnityEditor.Rendering.Universal.Test.GlobalSettingsMigration
  6. {
  7. class DefaultVolumeProfileSettingsMigrationTests : RenderPipelineGraphicsSettingsMigrationTestBase<URPDefaultVolumeProfileSettings>
  8. {
  9. class TestCase : IRenderPipelineGraphicsSettingsTestCase<URPDefaultVolumeProfileSettings>
  10. {
  11. bool m_ProfileExists;
  12. public TestCase(bool profileExists)
  13. {
  14. m_ProfileExists = profileExists;
  15. }
  16. public void SetUp(UniversalRenderPipelineGlobalSettings globalSettingsAsset, UniversalRenderPipelineAsset renderPipelineAsset)
  17. {
  18. #pragma warning disable 618 // Type or member is obsolete
  19. if (m_ProfileExists)
  20. {
  21. globalSettingsAsset.m_ObsoleteDefaultVolumeProfile = ScriptableObject.CreateInstance<VolumeProfile>();
  22. globalSettingsAsset.m_ObsoleteDefaultVolumeProfile.name = "MigratedProfile";
  23. }
  24. else
  25. {
  26. globalSettingsAsset.m_ObsoleteDefaultVolumeProfile = null;
  27. }
  28. globalSettingsAsset.m_AssetVersion = 4;
  29. #pragma warning restore 618
  30. }
  31. public bool IsMigrationCorrect(URPDefaultVolumeProfileSettings settings, out string message)
  32. {
  33. if (settings.volumeProfile == null)
  34. {
  35. message = "The default volume profile is null";
  36. return false;
  37. }
  38. message = $"{settings.volumeProfile.name} is not correct";
  39. return settings.volumeProfile.name.Equals(m_ProfileExists
  40. ? "MigratedProfile"
  41. : "DefaultVolumeProfile");
  42. }
  43. }
  44. static TestCaseData[] s_TestCaseDatas =
  45. {
  46. new TestCaseData(new TestCase(true))
  47. .SetName("When migrating an existing volume profile, settings are being transferred correctly"),
  48. new TestCaseData(new TestCase(false))
  49. .SetName("When migrating a non-existing volume profile, the volume profile is being gather correctly"),
  50. };
  51. [Test, TestCaseSource(nameof(s_TestCaseDatas))]
  52. public void PerformMigration(IRenderPipelineGraphicsSettingsTestCase<URPDefaultVolumeProfileSettings> testCase)
  53. {
  54. base.DoTest(testCase);
  55. }
  56. }
  57. }