RenderStreamingTest.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System.Linq;
  2. using NUnit.Framework;
  3. using Unity.RenderStreaming.Editor;
  4. using UnityEditor;
  5. using UnityEngine;
  6. namespace Unity.RenderStreaming.EditorTest
  7. {
  8. class RenderStreamingTest
  9. {
  10. private RenderStreamingSettings temp;
  11. [SetUp]
  12. public void Setup()
  13. {
  14. temp = RenderStreaming.Settings;
  15. RenderStreaming.Settings =
  16. AssetDatabase.LoadAssetAtPath<RenderStreamingSettings>(RenderStreaming.DefaultRenderStreamingSettingsPath);
  17. }
  18. [TearDown]
  19. public void TearDown()
  20. {
  21. if (temp != null)
  22. {
  23. RenderStreaming.Settings = temp;
  24. }
  25. }
  26. [Test]
  27. public void RenderStreamingSettings()
  28. {
  29. Assert.That(() => RenderStreamingEditor.SetRenderStreamingSettings(null), Throws.ArgumentNullException);
  30. var settings = ScriptableObject.CreateInstance<RenderStreamingSettings>();
  31. settings.signalingSettings = new WebSocketSignalingSettings();
  32. RenderStreamingEditor.SetRenderStreamingSettings(settings);
  33. Assert.That(RenderStreaming.Settings.automaticStreaming, Is.EqualTo(settings.automaticStreaming));
  34. Assert.That(RenderStreaming.Settings.signalingSettings, Is.EqualTo(settings.signalingSettings));
  35. Object.DestroyImmediate(settings);
  36. }
  37. [Test]
  38. public void SignalingSettings()
  39. {
  40. Assert.That(() => RenderStreamingEditor.SetSignalingSettings(null), Throws.ArgumentNullException);
  41. var url = "wss://127.0.0.1:8081";
  42. var iceServers = new IceServer[] {new IceServer(new string[] {"stun:stun.l.google.com:19302"})};
  43. var signalingSettings = new WebSocketSignalingSettings(url, iceServers);
  44. Assert.That(() => RenderStreamingEditor.SetSignalingSettings(signalingSettings), Throws.Nothing);
  45. var settings = RenderStreaming.GetSignalingSettings<WebSocketSignalingSettings>();
  46. Assert.That(settings.url, Is.EqualTo(url));
  47. Assert.That(settings.iceServers.ElementAt(0).urls, Is.EquivalentTo(iceServers[0].urls));
  48. }
  49. }
  50. }