public void LengthToPixelsPercentThrowsOnInvalidRenderDimensions() { var l = new Length(50, Length.Unit.Percent); var renderDevice = new DefaultRenderDevice(); Assert.Throws <ArgumentException>(() => l.ToPixel(renderDevice, RenderMode.Undefined)); Assert.Throws <ArgumentException>(() => l.ToPixel(null, RenderMode.Undefined)); }
public void LengthToPixelsCorrectVw() { var l = new Length(20, Length.Unit.Vw); var renderDevice = new DefaultRenderDevice { ViewPortWidth = 1000 }; Assert.AreEqual(200, l.ToPixel(renderDevice, RenderMode.Undefined)); }
public void LengthToPixelsCorrectPercentWidth() { var l = new Length(50, Length.Unit.Percent); var renderDevice = new DefaultRenderDevice { ViewPortWidth = 500 }; Assert.AreEqual(250, l.ToPixel(renderDevice, RenderMode.Horizontal)); }
public void LengthToVhCorrectValue() { var l = new Length(100, Length.Unit.Px); var renderDevice = new DefaultRenderDevice { ViewPortHeight = 1000 }; Assert.AreEqual(10, l.To(Length.Unit.Vh, renderDevice, RenderMode.Undefined)); }
public void LengthToVwCorrectValue() { var l = new Length(50, Length.Unit.Px); var renderDevice = new DefaultRenderDevice { ViewPortWidth = 1000 }; Assert.AreEqual(5, l.To(Length.Unit.Vw, renderDevice, RenderMode.Undefined)); }
public void LengthToEmCorrectValue() { var l = new Length(1600, Length.Unit.Px); var renderDevice = new DefaultRenderDevice { FontSize = 16 }; Assert.AreEqual(100, l.To(Length.Unit.Em, renderDevice, RenderMode.Undefined)); }
public void LengthToPercentCorrectHeight() { var l = new Length(100, Length.Unit.Px); var renderDevice = new DefaultRenderDevice { ViewPortHeight = 1000 }; Assert.AreEqual(10, l.To(Length.Unit.Percent, renderDevice, RenderMode.Vertical)); }
public void LengthToPercentCorrectWidth() { var l = new Length(100, Length.Unit.Px); var renderDevice = new DefaultRenderDevice { ViewPortWidth = 500 }; Assert.AreEqual(20, l.To(Length.Unit.Percent, renderDevice, RenderMode.Horizontal)); }
public void LengthToPixelsCorrectEm() { var l = new Length(10, Length.Unit.Em); var renderDevice = new DefaultRenderDevice { FontSize = 10 }; Assert.AreEqual(100, l.ToPixel(renderDevice, RenderMode.Undefined)); }
public void LengthToPixelsCorrectPercentHeight() { var l = new Length(25, Length.Unit.Percent); var renderDevice = new DefaultRenderDevice { ViewPortHeight = 600 }; Assert.AreEqual(150, l.ToPixel(renderDevice, RenderMode.Vertical)); }
public void LengthToPixelsCorrectVh() { var l = new Length(10, Length.Unit.Vh); var renderDevice = new DefaultRenderDevice { ViewPortHeight = 1000 }; Assert.AreEqual(100, l.ToPixel(renderDevice, RenderMode.Undefined)); }
public void SupportsBackgroundRedWithImportantRule() { var source = @"@supports (background: red !important) { }"; var sheet = ParseStyleSheet(source); var device = new DefaultRenderDevice(); Assert.AreEqual(1, sheet.Rules.Length); Assert.IsInstanceOf <CssSupportsRule>(sheet.Rules[0]); var supports = sheet.Rules[0] as CssSupportsRule; Assert.AreEqual("(background: red !important)", supports.ConditionText); Assert.IsTrue(supports.Condition.Check(device)); }
public void SupportsBackgroundColorRedAndColorBlueRule() { var source = @"@supports ((background-color: red) and (color: blue)) { }"; var sheet = ParseStyleSheet(source); var device = new DefaultRenderDevice(); Assert.AreEqual(1, sheet.Rules.Length); Assert.IsInstanceOf <CssSupportsRule>(sheet.Rules[0]); var supports = sheet.Rules[0] as CssSupportsRule; Assert.AreEqual("((background-color: red) and (color: blue))", supports.ConditionText); Assert.IsTrue(supports.Condition.Check(device)); }
public void SupportsUnsupportedDeclarationRule() { var source = @"@supports ((background-transparency: zero)) { }"; var sheet = ParseStyleSheet(source); var device = new DefaultRenderDevice(); Assert.AreEqual(1, sheet.Rules.Length); Assert.IsInstanceOf <CssSupportsRule>(sheet.Rules[0]); var supports = sheet.Rules[0] as CssSupportsRule; Assert.AreEqual("((background-transparency: zero))", supports.ConditionText); Assert.IsFalse(supports.Condition.Check(device)); }
public void SupportsDisplayFlexMultipleBracketsRule() { var source = @"@supports ((display: flex)) { }"; var sheet = ParseStyleSheet(source); var device = new DefaultRenderDevice(); Assert.AreEqual(1, sheet.Rules.Length); Assert.IsInstanceOf <CssSupportsRule>(sheet.Rules[0]); var supports = sheet.Rules[0] as CssSupportsRule; Assert.AreEqual("((display: flex))", supports.ConditionText); Assert.IsTrue(supports.Condition.Check(device)); }
public void SupportsPaddingTopOrPaddingLeftAndPaddingBottomOrPaddingRightRule() { var source = @"@supports (((padding-top: 0) or (padding-left: 0)) and ((padding-bottom: 0) or (padding-right: 0))) { }"; var sheet = ParseStyleSheet(source); var device = new DefaultRenderDevice(); Assert.AreEqual(1, sheet.Rules.Length); Assert.IsInstanceOf <CssSupportsRule>(sheet.Rules[0]); var supports = sheet.Rules[0] as CssSupportsRule; Assert.AreEqual("(((padding-top: 0) or (padding-left: 0)) and ((padding-bottom: 0) or (padding-right: 0)))", supports.ConditionText); Assert.IsTrue(supports.Condition.Check(device)); }
public void SupportsTransitionOrAnimationNameAndTransformBackBracketRule() { var source = @"@supports (transition-property: color) or ((animation-name: foo) and (transform: rotate(10deg))) { }"; var sheet = ParseStyleSheet(source); var device = new DefaultRenderDevice(); Assert.AreEqual(1, sheet.Rules.Length); Assert.IsInstanceOf <CssSupportsRule>(sheet.Rules[0]); var supports = sheet.Rules[0] as CssSupportsRule; Assert.AreEqual("(transition-property: color) or ((animation-name: foo) and (transform: rotate(10deg)))", supports.ConditionText); Assert.IsTrue(supports.Condition.Check(device)); }
public void SupportsShadowVendorPrefixesRule() { var source = @"@supports ( box-shadow: 0 0 2px black ) or ( -moz-box-shadow: 0 0 2px black ) or ( -webkit-box-shadow: 0 0 2px black ) or ( -o-box-shadow: 0 0 2px black ) { }"; var sheet = ParseStyleSheet(source); var device = new DefaultRenderDevice(); Assert.AreEqual(1, sheet.Rules.Length); Assert.IsInstanceOf <CssSupportsRule>(sheet.Rules[0]); var supports = sheet.Rules[0] as CssSupportsRule; Assert.AreEqual("(box-shadow: 0 0 2px black) or (-moz-box-shadow: 0 0 2px black) or (-webkit-box-shadow: 0 0 2px black) or (-o-box-shadow: 0 0 2px black)", supports.ConditionText); Assert.IsTrue(supports.Condition.Check(device)); }
public void SupportsNegatedDisplayFlexRuleWithDeclarations() { var source = @"@supports not ( display: flex ) { body { width: 100%; height: 100%; background: white; color: black; } #navigation { width: 25%; } #article { width: 75%; } }"; var sheet = ParseStyleSheet(source); var device = new DefaultRenderDevice(); Assert.AreEqual(1, sheet.Rules.Length); Assert.IsInstanceOf <CssSupportsRule>(sheet.Rules[0]); var supports = sheet.Rules[0] as CssSupportsRule; Assert.AreEqual(3, supports.Rules.Length); Assert.AreEqual("not (display: flex)", supports.ConditionText); Assert.IsFalse(supports.Condition.Check(device)); }