public void UniqueDefaultSystemNames() { VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); VFXView view = window.graphView; view.controller = m_ViewController; const int count = 16; var spawners = VFXTestCommon.CreateSpawners(view, m_ViewController, count); var systemNames = view.controller.graph.systemNames; var names = new List <string>(); foreach (var system in spawners) { names.Add(systemNames.GetUniqueSystemName(system)); } Assert.IsTrue(names.Where(name => !string.IsNullOrEmpty(name)).Distinct().Count() == count, "Some spawners have the same name or are null or empty."); var GPUSystems = VFXTestCommon.GetFieldValue <VFXView, List <VFXSystemBorder> >(view, "m_Systems"); VFXTestCommon.CreateSystems(view, m_ViewController, count, count); var uniqueSystemNames = GPUSystems.Select(system => system.controller.title).Distinct(); Assert.IsTrue(uniqueSystemNames.Count() == count, "Some GPU systems have the same name or are null or empty."); }
public void PasteSystems() { VFXViewWindow window = EditorWindow.GetWindow <VFXViewWindow>(); VFXView view = window.graphView; view.controller = m_ViewController; // Create a bunch of systems const int spawnerCount = 4, GPUSystemsCount = 4; var spawners = VFXTestCommon.CreateSpawners(view, m_ViewController, spawnerCount); VFXTestCommon.CreateSystems(view, m_ViewController, GPUSystemsCount, 0); // Copy paste them view.ClearSelection(); foreach (var element in view.Query().OfType <GraphElement>().ToList().OfType <ISelectable>()) { view.AddToSelection(element); } view.CopySelectionCallback(); view.PasteCallback(); // Query unique names var systemNames = view.controller.graph.systemNames; var uniqueNames = new List <string>(); foreach (var system in spawners) { uniqueNames.Add(systemNames.GetUniqueSystemName(system)); } var GPUSystems = VFXTestCommon.GetFieldValue <VFXView, List <VFXSystemBorder> >(view, "m_Systems"); uniqueNames = uniqueNames.Concat(GPUSystems.Select(system => system.controller.title)).ToList(); // Remove null or empty names, and duplicates uniqueNames = uniqueNames.Where(name => !string.IsNullOrEmpty(name)).Distinct().ToList(); // Assert all names are unique, and the expected number of elements was obtained Assert.IsTrue(uniqueNames.Count() == spawnerCount + GPUSystemsCount, "Some systems have the same name or are null or empty."); }