public void SizeProperties_OverrideBaseStyleInState() { Action <string, string, string> TestBody = (setFnName, propName, defaultName) => { MockApplication view = MockApplication.Setup <StyleSetTestThing>(); StyleSetTestThing root = (StyleSetTestThing)view.RootElement; UIStyle baseStyle = new UIStyle(); SetStyleValue(baseStyle, propName, new UIMeasurement(500)); CallMethod(root.style, setFnName, new UIMeasurement(1500), StyleState.Hover); UIStyleGroup group = new UIStyleGroup() { name = "Name", normal = new UIStyleRunCommand() { style = baseStyle } }; UIStyleGroupContainer container = new UIStyleGroupContainer(0, "Name", StyleType.Shared, new[] { group }); root.style.AddStyleGroupContainer(container); Assert.AreEqual(new UIMeasurement(500), ComputedValue <UIMeasurement>(root, propName)); root.style.EnterState(StyleState.Hover); Assert.AreEqual(new UIMeasurement(1500), ComputedValue <UIMeasurement>(root, propName)); }; RunSizeTests(TestBody); }
public void SizeProperties_EnterSecondState() { Action <string, string, string> TestBody = (setFnName, propName, defaultName) => { MockApplication view = MockApplication.Setup <StyleSetTestThing>(); StyleSetTestThing root = (StyleSetTestThing)view.RootElement; CallMethod(root.style, setFnName, new UIMeasurement(1000), StyleState.Hover); CallMethod(root.style, setFnName, new UIMeasurement(5000), StyleState.Focused); root.style.EnterState(StyleState.Hover); Assert.AreEqual(new UIMeasurement(1000), ComputedValue <UIMeasurement>(root, propName)); root.style.EnterState(StyleState.Focused); Assert.AreEqual(new UIMeasurement(5000), ComputedValue <UIMeasurement>(root, propName)); root.style.ExitState(StyleState.Focused); Assert.AreEqual(new UIMeasurement(1000), ComputedValue <UIMeasurement>(root, propName)); }; RunSizeTests(TestBody); }
public void IntProperties_OverrideBaseStyle() { Action <string, string, string> TestBody = (setFnName, propName, defaultName) => { MockApplication view = MockApplication.Setup <StyleSetTestThing>(); StyleSetTestThing root = (StyleSetTestThing)view.RootElement; UIStyle baseStyle = new UIStyle(); SetStyleValue(baseStyle, propName, 5); CallMethod(root.style, setFnName, 15, StyleState.Normal); UIStyleGroup group = new UIStyleGroup() { name = "Name", normal = new UIStyleRunCommand() { style = baseStyle } }; group.styleType = StyleType.Shared; UIStyleGroupContainer container = new UIStyleGroupContainer(0, "Name", StyleType.Shared, new[] { group }); root.style.AddStyleGroupContainer(container); Assert.AreEqual(15, ComputedValue <int>(root, propName)); root.style.RemoveStyleGroupContainer(container); Assert.AreEqual(15, ComputedValue <int>(root, propName)); }; RunIntTests(TestBody); }
public void IntProperties_EnterSecondState() { Action <string, string, string> TestBody = (setFnName, propName, defaultName) => { MockApplication view = MockApplication.Setup <StyleSetTestThing>(); StyleSetTestThing root = (StyleSetTestThing)view.RootElement; CallMethod(root.style, setFnName, DefaultValue <int>(defaultName) + 1, StyleState.Hover); CallMethod(root.style, setFnName, DefaultValue <int>(defaultName) + 5, StyleState.Focused); root.style.EnterState(StyleState.Hover); Assert.AreEqual(DefaultValue <int>(defaultName) + 1, ComputedValue <int>(root, propName)); root.style.EnterState(StyleState.Focused); Assert.AreEqual(DefaultValue <int>(defaultName) + 5, ComputedValue <int>(root, propName)); root.style.ExitState(StyleState.Focused); Assert.AreEqual(DefaultValue <int>(defaultName) + 1, ComputedValue <int>(root, propName)); }; RunIntTests(TestBody); }
public void ApplyDynamicStyleBinding() { MockApplication app = MockApplication.Setup <StyleSetTestThing>(); StyleSetTestThing root = (StyleSetTestThing)app.RootElement; app.Update(); Assert.AreEqual(100, root.FindById("dynamic").style.MarginTop.value); }
public void IntProperties_UpdateComputedStyleWithValue() { Action <string, string, string> TestBody = (setFnName, computedPropertyName, defaultName) => { MockApplication view = MockApplication.Setup <StyleSetTestThing>(); StyleSetTestThing root = (StyleSetTestThing)view.RootElement; Assert.AreEqual(DefaultValue <int>(defaultName), ComputedValue <int>(root, computedPropertyName)); CallMethod(root.style, setFnName, ComputedValue <int>(root, computedPropertyName) + 1, StyleState.Normal); Assert.AreEqual(DefaultValue <int>(defaultName) + 1, ComputedValue <int>(root, computedPropertyName)); }; RunIntTests(TestBody); }
public void Inherit_TextColor() { MockApplication app = MockApplication.Setup <StyleSetTestThing>(); StyleSetTestThing root = (StyleSetTestThing)app.RootElement; UIStyleSetStateProxy normal = root.style.Normal; normal.TextColor = Color.red; app.Update(); Assert.AreEqual(Color.red, root.FindById("group1").style.TextColor); Assert.AreEqual(Color.red, root.FindById("group2").style.TextColor); root.FindById("group1").style.SetTextColor(Color.blue, StyleState.Normal); app.Update(); Assert.AreEqual(Color.blue, root.FindById("group1").style.TextColor); Assert.AreEqual(Color.blue, root.FindById("group2").style.TextColor); root.FindById("group1").style.SetTextColor(null, StyleState.Normal); app.Update(); Assert.AreEqual(Color.red, root.FindById("group1").style.TextColor); Assert.AreEqual(Color.red, root.FindById("group2").style.TextColor); }
public void Inherit_FontSize() { MockApplication app = MockApplication.Setup <StyleSetTestThing>(); StyleSetTestThing root = (StyleSetTestThing)app.RootElement; UIStyleSetStateProxy normal = root.style.Normal; normal.TextFontSize = 8; app.Update(); Assert.AreEqual(new UIFixedLength(8), root.FindById("group1").style.TextFontSize); Assert.AreEqual(new UIFixedLength(8), root.FindById("group2").style.TextFontSize); root.FindById("group1").style.SetTextFontSize(12, StyleState.Normal); app.Update(); Assert.AreEqual(new UIFixedLength(12), root.FindById("group1").style.TextFontSize); Assert.AreEqual(new UIFixedLength(12), root.FindById("group2").style.TextFontSize); root.FindById("group1").style.SetTextFontSize(null, StyleState.Normal); app.Update(); Assert.AreEqual(new UIFixedLength(8), root.FindById("group1").style.TextFontSize); Assert.AreEqual(new UIFixedLength(8), root.FindById("group2").style.TextFontSize); }
public void Inherit_FontAsset() { MockApplication app = MockApplication.Setup <StyleSetTestThing>(); StyleSetTestThing root = (StyleSetTestThing)app.RootElement; UIStyleSetStateProxy normal = root.style.Normal; // var font0 = new FontAsset(TMP_FontAsset.defaultFontAsset); // var font1 = new FontAsset(TMP_FontAsset.defaultFontAsset); // normal.TextFontAsset = font0; // app.Update(); // Assert.AreEqual(font0, root.FindById("group1").style.TextFontAsset); // Assert.AreEqual(font0, root.FindById("group2").style.TextFontAsset); // root.FindById("group1").style.SetTextFontAsset(font1, StyleState.Normal); // app.Update(); // Assert.AreEqual(font1, root.FindById("group1").style.TextFontAsset); // Assert.AreEqual(font1, root.FindById("group2").style.TextFontAsset); // root.FindById("group1").style.SetTextFontAsset(null, StyleState.Normal); // app.Update(); // Assert.AreEqual(font0, root.FindById("group1").style.TextFontAsset); // Assert.AreEqual(font0, root.FindById("group2").style.TextFontAsset); }