public async Task Failed_Group_Run_Returns_Failed_Status() { var groupNode = new GroupNode <TestObjectA>(); groupNode.AddChild(new FailingTestNodeA()); groupNode.AddChild(new FailingTestNodeA()); var testObject = new TestObjectA(); NodeResult result = await groupNode.ExecuteAsync(testObject); result.Status.Should().Be(NodeResultStatus.Failed); groupNode.Status.Should().Be(NodeRunStatus.Completed); }
public async void Group_Run_With_Fault_Returns_Failed_Status() { var groupNode = new GroupNode <TestObjectA>(); groupNode.AddChild(new SimpleTestNodeA1()); groupNode.AddChild(new FaultingTestNodeA()); var testObject = new TestObjectA(); NodeResult result = await groupNode.ExecuteAsync(testObject); result.Status.ShouldEqual(NodeResultStatus.Failed); groupNode.Status.ShouldEqual(NodeRunStatus.Completed); }
public async void Successful_Group_Result_Matches_Expectations() { var groupNode = new GroupNode <TestObjectA>(); groupNode.AddChild(new SimpleTestNodeA1()); groupNode.AddChild(new SimpleTestNodeA2()); var testObject = new TestObjectA(); NodeResult result = await groupNode.ExecuteAsync(testObject); result.Status.ShouldEqual(NodeResultStatus.Succeeded); testObject.TestValueString.ShouldEqual("Completed"); testObject.TestValueInt.ShouldEqual(100); }
private void DrawUICreateOption() { using (var hor = new EditorGUILayout.HorizontalScope()) { var style = "miniButton"; var layout = GUILayout.Width(60); if (GUILayout.Button("Build-All", style, layout)) { var canvasObj = Array.Find(Selection.objects, x => x is GameObject && (x as GameObject).GetComponent <Canvas>() != null); var ctrl = PSDImporterUtility.CreatePsdImportCtrlSafty(exporter.ruleObj, exporter.ruleObj.defultUISize, canvasObj == null ? FindObjectOfType <Canvas>() : (canvasObj as GameObject).GetComponent <Canvas>()); ctrl.Import(rootNode); AssetDatabase.Refresh(); } if (GUILayout.Button("Build-Sel", style, layout)) { var canvasObj = Array.Find(Selection.objects, x => x is GameObject && (x as GameObject).GetComponent <Canvas>() != null); var ctrl = PSDImporterUtility.CreatePsdImportCtrlSafty(exporter.ruleObj, exporter.ruleObj.defultUISize, canvasObj == null ? FindObjectOfType <Canvas>() : (canvasObj as GameObject).GetComponent <Canvas>()); var root = new GroupNode(new Rect(Vector2.zero, rootNode.rect.size), 0, -1); root.displayName = "partial build"; foreach (var node in m_TreeView.selected) { root.AddChild(node); } ctrl.Import(root); AssetDatabase.Refresh(); } if (GUILayout.Button("Expland", style, layout)) { m_TreeView.ExpandAll(); } } }
private void RecordAllPsdInformation() { if (!string.IsNullOrEmpty(exporter.psdFile)) { var psd = PsdDocument.Create(exporter.psdFile); if (psd != null) { try { var rootSize = new Vector2(psd.Width, psd.Height); ExportUtility.InitPsdExportEnvrioment(exporter, rootSize); rootNode = new GroupNode(new Rect(Vector2.zero, rootSize), 0, -1); rootNode.displayName = exporter.name; var groupDatas = ExportUtility.CreatePictures(psd.Childs, rootSize, exporter.ruleObj.defultUISize, exporter.ruleObj.forceSprite); if (groupDatas != null) { foreach (var groupData in groupDatas) { rootNode.AddChild(groupData); ExportUtility.ChargeTextures(exporter, groupData); } } TreeViewUtility.TreeToList <GroupNode>(rootNode, exporter.groups, true); EditorUtility.SetDirty(exporter); } catch (Exception e) { psd.Dispose(); throw e; } psd.Dispose(); } } }
private void RecordSelectedInformation() { if (m_TreeView == null || m_TreeView.selected.Count == 0) { return; } var psdLayers = m_TreeView.selected.ConvertAll(x => x.layer as IPsdLayer).ToArray(); if (exporter == null) { exporter = ScriptableObject.CreateInstance <Exporter>(); } exporter.ruleObj = ruleObj; exporter.name = "exporter" + System.DateTime.UtcNow.ToFileTimeUtc(); ProjectWindowUtil.CreateAsset(exporter, exporter.name + ".asset"); EditorUtility.SetDirty(exporter); ExportUtility.InitPsdExportEnvrioment(exporter, new Vector2(psd.Width, psd.Height)); var rootNode = new GroupNode(new Rect(Vector2.zero, exporter.ruleObj.defultUISize), 0, -1); rootNode.displayName = exporter.name; var groupDatas = ExportUtility.CreatePictures(psdLayers, new Vector2(psd.Width, psd.Height), exporter.ruleObj.defultUISize, exporter.ruleObj.forceSprite); if (groupDatas != null) { foreach (var groupData in groupDatas) { rootNode.AddChild(groupData); ExportUtility.ChargeTextures(exporter, groupData); } } TreeViewUtility.TreeToList <GroupNode>(rootNode, exporter.groups, true); EditorUtility.SetDirty(exporter); }
public async void Group_Run_With_Fault_And_ContinueOnError_Returns_SucceededWithErrors_Status() { var groupNode = new GroupNode <TestObjectA> { LocalOptions = new ExecutionOptions { ContinueOnFailure = true } }; groupNode.AddChild(new SimpleTestNodeA1()); groupNode.AddChild(new FaultingTestNodeA()); var testObject = new TestObjectA(); NodeResult result = await groupNode.ExecuteAsync(testObject); result.Status.ShouldEqual(NodeResultStatus.SucceededWithErrors); groupNode.Status.ShouldEqual(NodeRunStatus.Completed); }
private void CreateSceneGraph() { PolygonNode poly1 = new PolygonNode(); PolygonNode poly2 = new PolygonNode(); PolygonNode poly3 = new PolygonNode(); PolygonNode poly4 = new PolygonNode(); GroupNode rt = new GroupNode(); Vector3 a = new Vector3(.0f, .0f, 2.5f); Vector3 b = new Vector3(2.5f, .0f, -2.5f); Vector3 c = new Vector3(-2.5f, .0f, 2.5f); Vector3 d = new Vector3(.0f, 4.0f, .0f); poly1.AddNormal(new Vector3(.0f, -1.0f, .0f)); poly1.AddVertex(0, c); poly1.AddVertex(1, b); poly1.AddVertex(2, c); poly2.AddNormal(new Vector3(.861411f, .269191f, .430706f)); poly2.AddVertex(0, d); poly2.AddVertex(1, a); poly2.AddVertex(2, b); poly3.AddNormal(new Vector3(.0f, .529999f, -.847998f)); poly3.AddVertex(0, d); poly3.AddVertex(1, b); poly3.AddVertex(2, c); poly4.AddNormal(new Vector3(-.861411f, .269191f, .430706f)); poly4.AddVertex(0, d); poly4.AddVertex(1, c); poly4.AddVertex(2, a); GroupNode root = new GroupNode(); GraphLinesNode graph = new GraphLinesNode(); GroupNode rt1 = new GroupNode(); GroupNode rt2 = new GroupNode(); root.AddChild(graph); root.AddChild(rt1); root.AddChild(rt2); rt1.AddChild(rt); rt2.AddChild(rt); rt1.SetTranslation(5, 0, 0); rt2.SetTranslation(-5, 0, 0); rt.AddChild(poly1); rt.AddChild(poly2); rt.AddChild(poly3); rt.AddChild(poly4); m_sceneGraph = root; m_hook1 = rt1; m_hook2 = rt2; }
public async Task Group_Run_With_Multiple_Failures_Returns_Failed_Statuses() { var pipelineNode = new GroupNode <TestObjectA>(); var faultNode1 = new FaultingTestNodeA(); var faultNode2 = new FaultingTestNodeA(); pipelineNode.AddChild(faultNode1); pipelineNode.AddChild(faultNode2); var testObject = new TestObjectA(); NodeResult result = await pipelineNode.ExecuteAsync(testObject); IEnumerable <Exception> exceptions = result.GetFailExceptions(); exceptions.Should().NotBeNull(); exceptions.Count().Should().BeGreaterThan(0); }
public GroupNode(String id, GroupNode parent) { Content = new Dictionary <String, Dictionary <String, String> >(); Id = id; Parent = parent; if (Parent != null) { parent.AddChild(this); } }
public async Task Group_Overall_Result_Subject_Equals_Changed_Subject() { var groupNode = new GroupNode <TestObjectA>(); var node1 = new SimpleTestNodeA1(); var node2 = new SubjectChangingNode1(); var node3 = new SimpleTestNodeA2(); groupNode.AddChild(node1); groupNode.AddChild(node2); groupNode.AddChild(node3); var testObject = new TestObjectA(); NodeResult result = await groupNode.ExecuteAsync(testObject); groupNode.Status.Should().Be(NodeRunStatus.Completed); var childResults = result.ChildResults.ToList(); result.Subject.Should().NotBeSameAs(testObject); result.Subject.Should().BeSameAs(childResults[1].Subject); }
public void AddNode(Node node) { _root.AddChild(node); if (Span.IsEmpty) { Span = _root.Span; } else if (!_root.Span.IsEmpty) { Span = Span.Envelope(_root.Span); } }
/// <summary> /// 转换为组 /// </summary> /// <param name="layer"></param> /// <param name="group"></param> /// <param name="OnRetrive"></param> public static void RetriveLayerToSwitchModle(Vector2 rootSize, PsdLayer layer, GroupNode group, bool forceSprite = false) { if (!layer.IsGroup) { return; } else { float index = 0; foreach (var child in layer.Childs) { var progress = ++index / layer.Childs.Length; EditorUtility.DisplayProgressBar(layer.Name, "转换进度:" + progress, progress); if (child.IsGroup) { GroupNode childNode = new GroupNode(GetRectFromLayer(child), idSpan++, group.depth + 1); childNode.Analyzing(RuleObj, child.Name); group.AddChild(childNode); if (childNode != null) { RetriveLayerToSwitchModle(rootSize, child, childNode, forceSprite); } } else { ImgNode imgnode = AnalysisLayer(group.displayName, rootSize, child, forceSprite); if (imgnode != null) { group.images.Add(imgnode); } } } EditorUtility.ClearProgressBar(); } }
public GroupNode(String id, GroupNode parent) { Content = new Dictionary<String, Dictionary<String, String>>(); Id = id; Parent = parent; if (Parent != null) parent.AddChild(this); }