예제 #1
0
        public IEnumerator CreateTemplateInstancesFromUXML()
        {
            var testUXMLTreeViewItem = GetTestAssetsUXMLFileNode();
            var libraryTreeView      = LibraryPane.Q <TreeView>();

            yield return(libraryTreeView.SelectAndScrollToItemWithId(testUXMLTreeViewItem.id));

            yield return(UIETestHelpers.Pause());

            var testUXMLLabel = libraryTreeView.Query <Label>(null, "unity-builder-library__tree-item-label")
                                .Where(label => label.text.Equals(k_TestUXMLFileName)).First();

            Assert.That(testUXMLLabel, Is.Not.Null);

            yield return(UIETestEvents.Mouse.SimulateDoubleClick(testUXMLLabel));

            yield return(UIETestEvents.Mouse.SimulateDragAndDrop(BuilderWindow,
                                                                 testUXMLLabel.worldBound.center,
                                                                 HierarchyPane.worldBound.center));

            Assert.That(ViewportPane.documentElement.childCount, Is.EqualTo(2));
            foreach (var child in ViewportPane.documentElement.Children())
            {
                Assert.That(child, Is.TypeOf <TemplateContainer>());
            }
        }
예제 #2
0
        protected IEnumerator SelectLibraryTreeItemWithName(string elementLabel)
        {
            var builderLibraryTreeItem = FindLibraryItemWithData(elementLabel);

            Assert.IsNotNull(builderLibraryTreeItem);
            var libraryTreeView = LibraryPane.Q <TreeView>();

            yield return(libraryTreeView.SelectAndScrollToItemWithId(builderLibraryTreeItem.id));
        }
        public void BuiltInComponentsLocatedUnderTheUnityHeading()
        {
            var libraryTreeView = LibraryPane.Q <TreeView>();
            var unityComponents = (BuilderLibrary.LibraryTreeItem)libraryTreeView.items.First();

            Assert.That(unityComponents.name, Is.EqualTo("Unity"));
            Assert.That((unityComponents.children.First() as BuilderLibrary.LibraryTreeItem)?.name,
                        Is.EqualTo(nameof(VisualElement)));
        }
        public IEnumerator CanDoubleClickToCreateNewElement()
        {
            Assert.That(ViewportPane.documentElement.childCount, Is.EqualTo(0));
            var libraryTreeView   = LibraryPane.Q <TreeView>();
            var visualElementNode = libraryTreeView.Query <Label>(null, "unity-builder-library__tree-item-label")
                                    .Where(label => label.text.Equals(nameof(VisualElement))).First();

            Assert.That(visualElementNode, Is.Not.Null);
            yield return(UIETestEvents.Mouse.SimulateDoubleClick(visualElementNode));

            Assert.That(ViewportPane.documentElement.childCount, Is.EqualTo(1));
        }
예제 #5
0
        public IEnumerator SwitchLibraryBetweenViewModes()
        {
            yield return(SwitchLibraryTab(BuilderLibrary.BuilderLibraryTab.Standard));

            LibraryPane.SetViewMode(BuilderLibrary.LibraryViewMode.IconTile);
            yield return(UIETestHelpers.Pause());

            Assert.That(LibraryPane.Q <BuilderLibraryPlainView>(), Is.Not.Null);

            LibraryPane.SetViewMode(BuilderLibrary.LibraryViewMode.TreeView);
            yield return(UIETestHelpers.Pause());

            Assert.That(LibraryPane.Q <BuilderLibraryTreeView>(), Is.Not.Null);
        }
예제 #6
0
        protected BuilderLibraryTreeItem FindLibraryItemWithData(string data)
        {
            var libraryTreeView = LibraryPane.Q <TreeView>();

            foreach (var item in libraryTreeView.items)
            {
                if (item is BuilderLibraryTreeItem libraryTreeItem)
                {
                    if (libraryTreeItem.data.Equals(data))
                    {
                        return(libraryTreeItem);
                    }
                }
            }

            return(null);
        }
        public IEnumerator LibraryDoesNotContainsEditorOnlyControlsWhenInRuntimeMode()
        {
            BuilderWindow.selection.Select(null, BuilderWindow.documentRootElement);
            yield return(UIETestHelpers.Pause());

            var documentSettings     = InspectorPane.Q(BuilderInspectorCanvas.ContainerName);
            var extensionsModeToggle = documentSettings.Q <Toggle>(BuilderInspectorCanvas.EditorExtensionsModeToggleName);

            // Should be false by default
            Assert.That(BuilderWindow.document.UXMLFileSettings.EditorExtensionMode, Is.EqualTo(false));
            var controlsTreeView = LibraryPane.Q <TreeView>();

            var hasEditorOnly = false;

            foreach (var item in controlsTreeView.items)
            {
                var libraryTreeItem = (BuilderLibraryTreeItem)item;
                if (libraryTreeItem.IsEditorOnly)
                {
                    hasEditorOnly = true;
                    break;
                }
            }
            Assert.That(hasEditorOnly, Is.EqualTo(false));

            extensionsModeToggle.value = true;
            yield return(UIETestHelpers.Pause());

            controlsTreeView = LibraryPane.Q <TreeView>();
            foreach (var item in controlsTreeView.items)
            {
                var libraryTreeItem = (BuilderLibraryTreeItem)item;
                if (libraryTreeItem.IsEditorOnly)
                {
                    hasEditorOnly = true;
                    break;
                }
            }

            Assert.That(hasEditorOnly, Is.EqualTo(true));
        }
예제 #8
0
        ITreeViewItem GetTestAssetsUXMLFileNode(string nodeName = k_TestUXMLFileName)
        {
            var libraryTreeView = LibraryPane.Q <TreeView>();
            var projectNode     = (BuilderLibraryTreeItem)libraryTreeView.items
                                  .First(item => ((BuilderLibraryTreeItem)item).Name.Equals(BuilderConstants.LibraryAssetsSectionHeaderName));

            libraryTreeView.ExpandItem(projectNode.id);

            var assetsNode = (BuilderLibraryTreeItem)projectNode.children?.FirstOrDefault();

            if (assetsNode == null || !assetsNode.Name.Equals(BuilderConstants.LibraryAssetsSectionHeaderName))
            {
                return(null);
            }

            libraryTreeView.ExpandItem(assetsNode.id);
            var testUXML = assetsNode.children
                           .FirstOrDefault(item => ((BuilderLibraryTreeItem)item).Name.Equals(nodeName));

            return(testUXML);
        }
        ITreeViewItem GetTestAssetsUXMLFileNode(string nodeName = k_TestUXMLFileName)
        {
            var libraryTreeView = LibraryPane.Q <TreeView>();
            var projectNode     = (BuilderLibrary.LibraryTreeItem)libraryTreeView.items
                                  .First(item => ((BuilderLibrary.LibraryTreeItem)item).name.Equals("Project"));

            libraryTreeView.ExpandItem(projectNode.id);

            var assets = (BuilderLibrary.LibraryTreeItem)projectNode.children.First();

            libraryTreeView.ExpandItem(assets.id);
            if (!assets.name.Equals("Assets"))
            {
                return(null);
            }

            var testUXML = assets.children
                           .FirstOrDefault(item => ((BuilderLibrary.LibraryTreeItem)item).name.Equals(nodeName));

            return(testUXML);
        }
예제 #10
0
        public IEnumerator UxmlAssetsOpenButtonTest()
        {
            var testUXMLTreeViewItem = GetTestAssetsUXMLFileNode();
            var libraryTreeView      = LibraryPane.Q <TreeView>();

            yield return(libraryTreeView.SelectAndScrollToItemWithId(testUXMLTreeViewItem.id));

            yield return(UIETestHelpers.Pause());

            var testUXMLLabel = libraryTreeView.Query <Label>(null, "unity-builder-library__tree-item-label")
                                .Where(label => label.text.Equals(k_TestUXMLFileName)).First();

            Assert.That(testUXMLLabel, Is.Not.Null);
            var treeViewItem = testUXMLLabel.parent;
            var openButton   = treeViewItem.Q <Button>();

            Assert.That(openButton, Style.Display(DisplayStyle.Flex));
            Assert.True(openButton.enabledInHierarchy);

            yield return(UIETestEvents.Mouse.SimulateClick(openButton));

            Assert.False(openButton.enabledInHierarchy);
        }
예제 #11
0
        IEnumerator SwitchLibraryTab(BuilderLibrary.BuilderLibraryTab tabName)
        {
            var controlsViewButton = LibraryPane.Q <Button>(tabName.ToString());

            yield return(UIETestEvents.Mouse.SimulateClick(controlsViewButton));
        }