NavigationPresenceInMenus.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Collections.Generic;
  2. using NUnit.Framework;
  3. using UnityEditor;
  4. using UnityEngine;
  5. namespace Unity.AI.Navigation.Editor.Tests
  6. {
  7. [TestFixture]
  8. [Description("Verifies that the desired Navigation editor menus are accessible with the package.")]
  9. public class NavigationPresenceInMenus
  10. {
  11. GameObject m_ComponentsReceiver;
  12. [OneTimeSetUp]
  13. public void OneTimeSetUp()
  14. {
  15. // Create an empty game object and select it in order for components menus to be available
  16. m_ComponentsReceiver = new GameObject("ComponentsReceiver");
  17. Selection.activeObject = m_ComponentsReceiver;
  18. }
  19. static IEnumerable<string> NavigationMenuItemProvider()
  20. {
  21. yield return "Component/Navigation/Nav Mesh Agent";
  22. yield return "Component/Navigation/Nav Mesh Obstacle";
  23. yield return "Component/Navigation/Off Mesh Link";
  24. yield return "Component/Navigation/NavMeshSurface";
  25. yield return "Component/Navigation/NavMeshModifierVolume";
  26. yield return "Component/Navigation/NavMeshModifier";
  27. yield return "Component/Navigation/NavMeshLink";
  28. yield return "Window/AI/Navigation";
  29. #if UNITY_2022_2_OR_NEWER
  30. yield return "Window/AI/Navigation (Obsolete)";
  31. #endif
  32. }
  33. [Test]
  34. [TestCaseSource(nameof(NavigationMenuItemProvider))]
  35. public void MenuIsEnabled(string menuPath)
  36. {
  37. var menuEnabled = Menu.GetEnabled(menuPath);
  38. Assert.That(menuEnabled, Is.True, $"Navigation component menu '{menuPath}' should be available");
  39. }
  40. [OneTimeTearDown]
  41. public void OneTimeTearDown()
  42. {
  43. Object.DestroyImmediate(m_ComponentsReceiver);
  44. }
  45. }
  46. }