Пример #1
0
        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));
        }
Пример #2
0
        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));
        }
Пример #3
0
        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));
        }
Пример #4
0
        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));
        }
Пример #5
0
        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));
        }
Пример #6
0
        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));
        }
Пример #7
0
        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));
        }
Пример #8
0
        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));
        }
Пример #9
0
        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));
        }
Пример #10
0
        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));
        }
Пример #11
0
        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));
        }
Пример #12
0
        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));
        }
Пример #13
0
        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));
        }
Пример #14
0
        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));
        }
Пример #15
0
        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));
        }
Пример #16
0
        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));
        }
Пример #17
0
        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));
        }
Пример #18
0
        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));
        }
Пример #19
0
        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));
        }