コード例 #1
0
        public IEnumerator DeleteCategoryTests()
        {
            Assert.IsNotNull(m_BlackboardTestController.addBlackboardItemsMenu, "Blackboard Add Items menu reference owned by BlackboardTestController is null.");

            CreateBlackboardCategory(m_BlackboardTestController);
            yield return(null);

            var categories = m_BlackboardTestController.blackboard.Query <SGBlackboardCategory>().ToList();

            if (categories != null)
            {
                var newCategory = categories[1];
                if (newCategory == null)
                {
                    Assert.Fail("Failed to create Category during DuplicateCategoryTests");
                }

                // Select the new category
                ShaderGraphUITestHelpers.SendMouseEvent(m_Window, newCategory, EventType.MouseDown, positionOffset: new Vector2(40, 10));
                // Wait a frame
                yield return(null);

                ShaderGraphUITestHelpers.SendMouseEvent(m_Window, newCategory, EventType.MouseUp, positionOffset: new Vector2(40, 10));
                yield return(null);

                // Then send delete command
                ShaderGraphUITestHelpers.SendDeleteCommand(m_Window, newCategory);
                yield return(null);

                Assert.IsTrue(m_BlackboardTestController.blackboard.Query <SGBlackboardCategory>().ToEnumerable().Count() == 1, "Failed to delete blackboard category view");
            }

            m_BlackboardTestController.ResetBlackboardState();
        }
コード例 #2
0
        public IEnumerator RemoveInputTests()
        {
            Assert.IsNotNull(m_BlackboardTestController.addBlackboardItemsMenu, "Blackboard Add Items menu reference owned by BlackboardTestController is null.");

            var menuItems = m_BlackboardTestController.addBlackboardItemsMenu.GetPrivateProperty <IList>("menuItems");

            Assert.IsNotNull(menuItems, "Could not retrieve reference to the menu items of the Blackboard Add Items menu");

            // invoke all menu items on the "add Blackboard Items Menu" to add all property types
            foreach (var item in menuItems)
            {
                var menuFunction = item.GetNonPrivateField <GenericMenu.MenuFunction>("func");
                menuFunction?.Invoke();
                yield return(null);
            }

            var cachedPropertyList = m_Window.graphObject.graph.properties.ToList();

            foreach (var property in cachedPropertyList)
            {
                var blackboardRow = m_BlackboardTestController.GetBlackboardRow(property);
                Assert.IsNotNull(blackboardRow, "No blackboard row found associated with blackboard property.");
                var blackboardPropertyView = blackboardRow.Q <SGBlackboardField>();
                Assert.IsNotNull(blackboardPropertyView, "No blackboard property view found in the blackboard row.");
                m_GraphEditorView.graphView.ClearSelection();
                m_GraphEditorView.graphView.AddToSelection(blackboardPropertyView);
                Assert.AreEqual(1, m_Window.graphEditorView.graphView.selection.Count(), "Could not select property!");
                yield return(null);

                ShaderGraphUITestHelpers.SendDeleteCommand(m_Window, m_GraphEditorView.graphView);
                yield return(null);
            }

            var cachedKeywordList = m_Window.graphObject.graph.keywords.ToList();

            foreach (var keyword in cachedKeywordList)
            {
                var blackboardRow = m_BlackboardTestController.GetBlackboardRow(keyword);
                Assert.IsNotNull(blackboardRow, "No blackboard row found associated with blackboard keyword.");
                var blackboardPropertyView = blackboardRow.Q <SGBlackboardField>();
                Assert.IsNotNull(blackboardPropertyView, "No blackboard property view found in the blackboard row.");
                m_GraphEditorView.graphView.ClearSelection();
                m_GraphEditorView.graphView.AddToSelection(blackboardPropertyView);
                Assert.AreEqual(1, m_Window.graphEditorView.graphView.selection.Count(), "Could not select keyword!");
                yield return(null);

                ShaderGraphUITestHelpers.SendDeleteCommand(m_Window, m_GraphEditorView.graphView);
                yield return(null);
            }

            // Should be no properties, keywords, dropdowns
            Assert.IsTrue(m_Window.graphObject.graph.properties.Count() == 0 && m_Window.graphObject.graph.properties.Count() == 0 && m_Window.graphObject.graph.dropdowns.Count() == 0);
            yield return(null);
        }
コード例 #3
0
        public IEnumerator RemoveInputTests()
        {
            Assert.IsNotNull(m_BlackboardTestController.addBlackboardItemsMenu, "Blackboard Add Items menu reference owned by BlackboardTestController is null.");

            var menuItems = m_BlackboardTestController.addBlackboardItemsMenu.GetPrivateProperty <IList>("menuItems");

            Assert.IsNotNull(menuItems, "Could not retrieve reference to the menu items of the Blackboard Add Items menu");

            // invoke all menu items on the "add Blackboard Items Menu" to add all property types
            foreach (var item in menuItems)
            {
                var menuFunction = item.GetNonPrivateField <GenericMenu.MenuFunction>("func");
                menuFunction?.Invoke();
                yield return(null);
            }

            var cachedPropertyList = m_Window.graphObject.graph.properties.ToList();

            foreach (var property in cachedPropertyList)
            {
                var blackboardRow = m_BlackboardTestController.GetBlackboardRow(property);
                Assert.IsNotNull(blackboardRow, "No blackboard row found associated with blackboard property.");
                var blackboardPropertyView = blackboardRow.Q <SGBlackboardField>();
                Assert.IsNotNull(blackboardPropertyView, "No blackboard property view found in the blackboard row.");
                ShaderGraphUITestHelpers.SendMouseEvent(m_Window, blackboardPropertyView, EventType.MouseDown, MouseButton.LeftMouse, 1, EventModifiers.None, new Vector2(5, 1));
                ShaderGraphUITestHelpers.SendMouseEvent(m_Window, blackboardPropertyView, EventType.MouseUp, MouseButton.LeftMouse, 1, EventModifiers.None, new Vector2(5, 1));
                yield return(null);

                ShaderGraphUITestHelpers.SendDeleteCommand(m_Window, m_GraphEditorView.graphView);
                yield return(null);
            }

            var cachedKeywordList = m_Window.graphObject.graph.keywords.ToList();

            foreach (var keyword in cachedKeywordList)
            {
                var blackboardRow = m_BlackboardTestController.GetBlackboardRow(keyword);
                Assert.IsNotNull(blackboardRow, "No blackboard row found associated with blackboard keyword.");
                var blackboardPropertyView = blackboardRow.Q <SGBlackboardField>();
                Assert.IsNotNull(blackboardPropertyView, "No blackboard property view found in the blackboard row.");
                ShaderGraphUITestHelpers.SendMouseEvent(m_Window, blackboardPropertyView, EventType.MouseDown, MouseButton.LeftMouse, 1, EventModifiers.None, new Vector2(5, 1));
                ShaderGraphUITestHelpers.SendMouseEvent(m_Window, blackboardPropertyView, EventType.MouseUp, MouseButton.LeftMouse, 1, EventModifiers.None, new Vector2(5, 1));
                yield return(null);

                ShaderGraphUITestHelpers.SendDeleteCommand(m_Window, m_GraphEditorView.graphView);
                yield return(null);
            }


            yield return(null);
        }