Sin descripción
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.

RuntimeTests.cs 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using NUnit.Framework;
  4. using UnityEngine.TestTools;
  5. using UnityEditor;
  6. using UnityEngine.Rendering;
  7. namespace UnityEngine.AdaptivePerformance.Tests
  8. {
  9. [TestFixture(0, -1)] // No loaders, should never have any results
  10. [TestFixture(1, -1)] // 1 loader, fails so no active loaders
  11. [TestFixture(1, 0)] // All others, make sure the active loader is expected loader.
  12. [TestFixture(2, 0)]
  13. [TestFixture(2, 1)]
  14. [TestFixture(3, 2)]
  15. class ManualLifetimeTests
  16. {
  17. AdaptivePerformanceManagerSettings m_Manager;
  18. List<AdaptivePerformanceLoader> m_Loaders = new List<AdaptivePerformanceLoader>();
  19. int m_LoaderCount;
  20. int m_LoaderIndexToWin;
  21. public ManualLifetimeTests(int loaderCount, int loaderIndexToWin)
  22. {
  23. m_LoaderCount = loaderCount;
  24. m_LoaderIndexToWin = loaderIndexToWin;
  25. }
  26. [SetUp]
  27. public void SetupAdaptivePerformanceManagerTest()
  28. {
  29. m_Manager = ScriptableObject.CreateInstance<AdaptivePerformanceManagerSettings>();
  30. m_Manager.automaticLoading = false;
  31. m_Loaders = new List<AdaptivePerformanceLoader>();
  32. for (int i = 0; i < m_LoaderCount; i++)
  33. {
  34. DummyLoader dl = ScriptableObject.CreateInstance(typeof(DummyLoader)) as DummyLoader;
  35. dl.id = i;
  36. dl.shouldFail = (i != m_LoaderIndexToWin);
  37. m_Loaders.Add(dl);
  38. m_Manager.loaders.Add(dl);
  39. }
  40. }
  41. [TearDown]
  42. public void TeardownAdaptivePerformanceManagerTest()
  43. {
  44. Object.Destroy(m_Manager);
  45. m_Manager = null;
  46. }
  47. [UnityTest]
  48. public IEnumerator CheckActivatedLoader()
  49. {
  50. Assert.IsNotNull(m_Manager);
  51. yield return m_Manager.InitializeLoader();
  52. if (m_LoaderIndexToWin < 0 || m_LoaderIndexToWin >= m_Loaders.Count)
  53. {
  54. Assert.IsNull(m_Manager.activeLoader);
  55. }
  56. else
  57. {
  58. Assert.IsNotNull(m_Manager.activeLoader);
  59. Assert.AreEqual(m_Loaders[m_LoaderIndexToWin], m_Manager.activeLoader);
  60. }
  61. m_Manager.DeinitializeLoader();
  62. Assert.IsNull(m_Manager.activeLoader);
  63. m_Manager.loaders.Clear();
  64. }
  65. }
  66. }