PluginTest.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using UnityEngine; // RuntimePlatform
  2. using System.IO;
  3. using System.Diagnostics; // Process
  4. using System.Linq;
  5. using UnityEngine.TestTools; // UnityPlatform
  6. using NUnit.Framework; // Assert
  7. using UnityEditor;
  8. namespace Unity.WebRTC.EditorTest {
  9. class PluginTest {
  10. /// <todo>
  11. /// This test is only supported on Linux Editor, OSX Editor
  12. /// not found "libwebrtc.so" on Linux Editor.
  13. /// </todo>
  14. [Test]
  15. [UnityPlatform(RuntimePlatform.WindowsEditor)]
  16. public static void IsPluginLoaded() {
  17. // Get the current process.
  18. Process currentProcess = Process.GetCurrentProcess();
  19. var names = currentProcess.Modules
  20. .Cast<ProcessModule>()
  21. .Where(_ => _ != null)
  22. .Select(_ => Path.GetFileNameWithoutExtension(_.ModuleName));
  23. Assert.That(names, Contains.Item(WebRTC.GetModuleName()));
  24. }
  25. //----------------------------------------------------------------------------------------------------------------------
  26. [Test]
  27. public static void CheckPluginImportSettings() {
  28. string[] guids = AssetDatabase.FindAssets("", new[] {"Packages/com.unity.webrtc/Runtime/Plugins"});
  29. foreach (string guid in guids) {
  30. string path = AssetDatabase.GUIDToAssetPath(guid);
  31. AssetImporter assetImporter = AssetImporter.GetAtPath(path);
  32. Assert.IsNotNull(assetImporter);
  33. if (assetImporter.GetType() != typeof(PluginImporter))
  34. continue;
  35. PluginImporter pluginImporter = assetImporter as PluginImporter;
  36. Assert.That(pluginImporter, Is.Not.Null);
  37. Assert.That(pluginImporter.isPreloaded, Is.True);
  38. }
  39. }
  40. }
  41. } //namespace Unity.WebRTC.EditorTest