Exemplo n.º 1
0
        public IEnumerator DuplicateInputTest()
        {
            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.SendDuplicateCommand(m_Window);
                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.SendDuplicateCommand(m_Window);
                yield return(null);
            }
        }
Exemplo n.º 2
0
        public IEnumerator DuplicateCategoryTests()
        {
            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");
                }

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

                ShaderGraphUITestHelpers.SendMouseEvent(m_Window, newCategory, EventType.MouseUp, positionOffset: categoryClickOffset);
                yield return(null);

                // Then send duplicate command
                ShaderGraphUITestHelpers.SendDuplicateCommand(m_Window);
                yield return(null);

                var categoryViewsList = m_BlackboardTestController.blackboard.Query <SGBlackboardCategory>().ToList();
                Assert.IsTrue(categoryViewsList.Count() == 3, "Failed to duplicate blackboard category view");
                Assert.IsTrue(categoryViewsList[1].title == categoryViewsList[2].title, "Failed to duplicate blackboard category");
            }

            m_BlackboardTestController.ResetBlackboardState();
        }