Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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();
                }
            }
        }
Пример #5
0
        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();
                }
            }
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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;
        }
Пример #9
0
        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);
        }
Пример #10
0
 public GroupNode(String id, GroupNode parent)
 {
     Content = new Dictionary <String, Dictionary <String, String> >();
     Id      = id;
     Parent  = parent;
     if (Parent != null)
     {
         parent.AddChild(this);
     }
 }
Пример #11
0
        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);
        }
Пример #12
0
        public void AddNode(Node node)
        {
            _root.AddChild(node);

            if (Span.IsEmpty)
            {
                Span = _root.Span;
            }
            else if (!_root.Span.IsEmpty)
            {
                Span = Span.Envelope(_root.Span);
            }
        }
Пример #13
0
        /// <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();
            }
        }
Пример #14
0
 public GroupNode(String id, GroupNode parent)
 {
     Content = new Dictionary<String, Dictionary<String, String>>();
     Id = id;
     Parent = parent;
     if (Parent != null)
         parent.AddChild(this);
 }