Esempio n. 1
0
        protected IEnumerator EnsureSelectorsCanBeAddedAndReloadBuilder()
        {
            var builderWindow = BuilderWindow;

            // Need to have at least one element in the asset.
            if (builderWindow.document.visualTreeAsset.IsEmpty())
            {
                AddElementCodeOnly("TestElement");
            }

            yield return(UIETestHelpers.Pause(1));

            // If the builder currently has no stylesheets,
            // we add the test one so we can add selectors.
            if (builderWindow.document.firstStyleSheet == null)
            {
                // Make sure there's no modified version in memory.
                AssetDatabase.ImportAsset(
                    k_TestEmptyUSSFilePath,
                    ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);

                yield return(UIETestHelpers.Pause(1));

                BuilderStyleSheetsUtilities.AddUSSToAsset(builderWindow, k_TestEmptyUSSFilePath);
            }

            yield return(UIETestHelpers.Pause(1));

            StyleSheetsPane.elementHierarchyView.ExpandAllChildren();
            HierarchyPane.elementHierarchyView.ExpandAllChildren();
        }
        public IEnumerator PastingAddsSelectorToActiveStyleSheet()
        {
            yield return(CodeOnlyAddUSSToDocument(k_ColorsTestUSSPath));

            yield return(CodeOnlyAddUSSToDocument(k_LayoutTestUSSPath));

            // Copy Selector.
            var unityButtonSelectors = BuilderTestsHelper.GetExplorerItemsWithName(StyleSheetsPane, ".unity-button");

            yield return(UIETestEvents.Mouse.SimulateClick(unityButtonSelectors[0]));

            yield return(UIETestEvents.ExecuteCommand(BuilderWindow, UIETestEvents.Command.Copy));

            // Activate the second StyleSheet.
            var layoutExplorerItem = BuilderTestsHelper.GetExplorerItemWithName(StyleSheetsPane, k_LayoutTestUSSFileName);

            Assert.That(layoutExplorerItem, Is.Not.Null);
            var layoutStyleSheet          = GetStyleSheetFromExplorerItem(layoutExplorerItem, k_LayoutTestUSSPath);
            var previousNumberOfSelectors = layoutStyleSheet.complexSelectors.Length;

            BuilderStyleSheetsUtilities.SetActiveUSS(Selection, StyleSheetsPane.paneWindow, layoutStyleSheet);
            Assert.That(BuilderWindow.document.activeStyleSheet, Is.EqualTo(layoutStyleSheet));

            // Paste Selector.
            yield return(UIETestEvents.ExecuteCommand(BuilderWindow, UIETestEvents.Command.Paste));

            Assert.That(layoutStyleSheet.complexSelectors.Length, Is.EqualTo(previousNumberOfSelectors + 2)); // 2 for the extra fake rule added to the stylesheet for the pasted selector. see BuilderSharedStyles.CreateNewSelectorElement
        }
Esempio n. 3
0
        protected IEnumerator CodeOnlyAddUSSToDocument(string path)
        {
            var builderWindow = BuilderWindow;

            // Need to have at least one element in the asset.
            if (builderWindow.document.visualTreeAsset.IsEmpty())
            {
                AddElementCodeOnly("TestElement");
            }

            yield return(UIETestHelpers.Pause(1));

            // Make sure there's no modified version in memory.
            AssetDatabase.ImportAsset(
                k_TestEmptyUSSFilePath,
                ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);

            yield return(UIETestHelpers.Pause(1));

            BuilderStyleSheetsUtilities.AddUSSToAsset(builderWindow, path);

            yield return(UIETestHelpers.Pause(1));

            StyleSheetsPane.elementHierarchyView.ExpandAllChildren();
            HierarchyPane.elementHierarchyView.ExpandAllChildren();
        }
        protected override IEnumerator TearDown()
        {
            BuilderStyleSheetsUtilities.RestoreTestCallbacks();

            yield return(base.TearDown());

            AssetDatabase.DeleteAsset(k_TestUSSFilePath);
        }