RuntimeLoaderTests.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using NUnit.Framework;
  5. using Unity.XR.TestTooling;
  6. using UnityEngine.XR.Management.Tests.Standalone;
  7. using UnityEngine.XR.Management.Tests.Standalone.Providing;
  8. namespace UnityEngine.XR.Management.Tests
  9. {
  10. class RuntimeLoaderTests : LoaderTestSetup<StandaloneLoader, RuntimeTestSettings>
  11. {
  12. protected override string settingsKey => "RuntimeTestSettings";
  13. [OneTimeSetUp]
  14. public void OneTimeSetUp()
  15. {
  16. StandaloneSubsystemParams parms = new StandaloneSubsystemParams("Standalone Subsystem", typeof(StandaloneSubsystem));
  17. StandaloneSubsystemDescriptor.Create(parms);
  18. }
  19. [SetUp]
  20. public override void SetupTest()
  21. {
  22. base.SetupTest();
  23. }
  24. [TearDown]
  25. public override void TearDownTest()
  26. {
  27. base.TearDownTest();
  28. }
  29. [Test]
  30. public void DoesItWork()
  31. {
  32. Assert.NotNull(loader);
  33. Assert.NotNull(settings);
  34. }
  35. [Test]
  36. public void StartsAndStops()
  37. {
  38. Assert.IsNull(loader.standaloneSubsystem);
  39. Assert.IsFalse(loader.started);
  40. Assert.IsFalse(loader.stopped);
  41. Assert.IsFalse(loader.deInitialized);
  42. InitializeAndStart();
  43. Assert.IsNotNull(loader.standaloneSubsystem);
  44. Assert.IsTrue(loader.started);
  45. Assert.IsFalse(loader.stopped);
  46. Assert.IsFalse(loader.deInitialized);
  47. StopAndShutdown();
  48. Assert.IsTrue(loader.started);
  49. Assert.IsTrue(loader.stopped);
  50. Assert.IsTrue(loader.deInitialized);
  51. }
  52. [Test]
  53. public void DeinitClearSubsystems()
  54. {
  55. Assert.IsNull(loader.standaloneSubsystem);
  56. InitializeAndStart();
  57. Assert.IsNotNull(loader.GetLoadedSubsystem<StandaloneSubsystem>());
  58. loader.Stop();
  59. loader.Deinitialize();
  60. Assert.IsNull(loader.GetLoadedSubsystem<StandaloneSubsystem>());
  61. }
  62. }
  63. }