public IEnumerator SetVariable() { var asset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(k_NewVariableUxmlFilePath); builder.LoadDocument(asset); yield return(UIETestHelpers.Pause(1)); hierarchy.elementHierarchyView.ExpandRootItems(); styleSheetsPane.elementHierarchyView.ExpandRootItems(); yield return(UIETestHelpers.Pause(1)); // Select test-selector-1 var selector = BuilderTestsHelper.GetExplorerItemWithName(styleSheetsPane, k_Selector_1); yield return(UIETestEvents.Mouse.SimulateClick(selector)); var textFoldout = base.inspector.Query <PersistedFoldout>().Where(f => f.text.Equals("Text")).First(); textFoldout.value = true; // Show variable field for the Size field var sizeField = FindStyleField <DimensionStyleField>(textFoldout, "Size"); var handler = StyleVariableUtilities.GetVarHandler(sizeField); Assert.IsFalse(sizeField.ClassListContains(BuilderConstants.InspectorLocalStyleVariableClassName)); handler.ShowVariableField(); // Enter variable name var textField = handler.variableField.Q <TextField>(); textField.value = k_LengthVarName; selector = BuilderTestsHelper.GetExplorerItemWithName(styleSheetsPane, k_Selector_1); // Click anywhere else to remove focus yield return(UIETestEvents.Mouse.SimulateClick(selector)); yield return(UIETestHelpers.Pause(1)); Assert.IsTrue(sizeField.ClassListContains(BuilderConstants.InspectorLocalStyleVariableClassName)); var inspector = handler.inspector; var styleProperty = BuilderInspectorStyleFields.GetStyleProperty(inspector.currentRule, handler.styleName); Assert.IsTrue(styleProperty != null && styleProperty.IsVariable()); Assert.AreEqual(inspector.styleSheet.ReadVariable(styleProperty), k_LengthVarName); yield return(null); }
public IEnumerator UnsetVariable() { var asset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(k_NewVariableUxmlFilePath); BuilderWindow.LoadDocument(asset); yield return(UIETestHelpers.Pause(1)); HierarchyPane.elementHierarchyView.ExpandAllChildren(); StyleSheetsPane.elementHierarchyView.ExpandAllChildren(); yield return(UIETestHelpers.Pause(1)); // Select test-selector-1 var selector = BuilderTestsHelper.GetExplorerItemWithName(StyleSheetsPane, k_Selector_1); yield return(UIETestEvents.Mouse.SimulateClick(selector)); var textFoldout = InspectorPane.Query <PersistedFoldout>().Where(f => f.text.Equals("Text")).First(); textFoldout.value = true; // Show variable field for the Color field var colorField = FindStyleField <ColorField>(textFoldout, "Color"); var handler = StyleVariableUtilities.GetVarHandler(colorField); Assert.IsTrue(colorField.ClassListContains(BuilderConstants.InspectorLocalStyleVariableClassName)); handler.ShowVariableField(); // Enter variable name var textField = handler.variableField.Q <TextField>(); textField.value = ""; selector = BuilderTestsHelper.GetExplorerItemWithName(StyleSheetsPane, k_Selector_1); // Click anywhere else to remove focus yield return(UIETestEvents.Mouse.SimulateClick(selector)); Assert.IsFalse(colorField.ClassListContains(BuilderConstants.InspectorLocalStyleVariableClassName)); var inspector = handler.inspector; var styleProperty = BuilderInspectorStyleFields.GetStyleProperty(inspector.currentRule, handler.styleName); Assert.IsNull(styleProperty); yield return(null); }