#if UNITY_6000_7_OR_NEWER using System.IO; using System.Linq; using NUnit.Framework; using Unity.Pipeline.Commands; using Unity.Pipeline.Editor; using Unity.Pipeline.Editor.Commands; using Unity.Pipeline.Runtime.Commands; using UnityEditor; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UIElements; namespace Unity.Pipeline.Tests.Editor { /// /// Tests for the visual-element capture commands. The selector resolver /// () is the /// riskiest new logic and is GPU-independent, so it gets the most coverage; the /// capture_editor_element command is covered for its validation/miss branches plus a /// GPU-gated happy path. /// public class CaptureVisualElementCommandsTests { // -- Selector resolver ------------------------------------------------------------------- static VisualElement BuildTree() { // root // #toolbar .toolbar // #search Button .primary (direct child of toolbar) // #content // #title Label .big (disabled) var root = new VisualElement { name = "root" }; var toolbar = new VisualElement { name = "toolbar" }; toolbar.AddToClassList("toolbar"); var search = new Button { name = "search" }; search.AddToClassList("primary"); toolbar.Add(search); var content = new VisualElement { name = "content" }; var title = new Label { name = "title" }; title.AddToClassList("big"); title.SetEnabled(false); // sets the :disabled pseudo-state content.Add(title); root.Add(toolbar); root.Add(content); return root; } [Test] public void Resolve_ById() { var root = BuildTree(); var e = VisualElementCaptureSupport.ResolveElement(root, "#search"); Assert.IsNotNull(e); Assert.AreEqual("search", e.name); } [Test] public void Resolve_ByClass() { var root = BuildTree(); var e = VisualElementCaptureSupport.ResolveElement(root, ".toolbar"); Assert.IsNotNull(e); Assert.AreEqual("toolbar", e.name); } [Test] public void Resolve_ByType() { var root = BuildTree(); var e = VisualElementCaptureSupport.ResolveElement(root, "Label"); Assert.IsNotNull(e); Assert.AreEqual("title", e.name); Assert.IsInstanceOf