Пример #1
0
        public virtual void NotExistingXValueTest()
        {
            String shorthandExpression = "30jacoco 50pt";
            ICollection <String> expectedResolvedProperties = new HashSet <String>();
            IShorthandResolver   backgroundResolver         = ShorthandResolverFactory.GetShorthandResolver(CommonCssConstants.BACKGROUND_POSITION
                                                                                                            );

            NUnit.Framework.Assert.IsNotNull(backgroundResolver);
            IList <CssDeclaration> resolvedShorthandProps = backgroundResolver.ResolveShorthand(shorthandExpression);

            CssShorthandResolverTest.CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
        public virtual void BorderStyleTest01()
        {
            String shorthandExpression = "dotted solid double dashed";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-top-style: dotted"
                                                                                                         , "border-right-style: solid", "border-bottom-style: double", "border-left-style: dashed"));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BORDER_STYLE);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
Пример #3
0
        public virtual void BorderTopTest01()
        {
            String shorthandExpression = "10px hidden rgba(12,225,100,0.7)";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-top-width: 10px"
                                                                                                         , "border-top-style: hidden", "border-top-color: rgba(12,225,100,0.7)"));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CommonCssConstants.BORDER_TOP);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
        public virtual void BorderColorTest02()
        {
            String shorthandExpression = "red";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-top-color: red"
                                                                                                         , "border-right-color: red", "border-bottom-color: red", "border-left-color: red"));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BORDER_COLOR);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
Пример #5
0
        public virtual void InvalidDoubleHorizontalWithCenterAndVerticalValueTest()
        {
            String shorthandExpression = "center top left";
            ICollection <String> expectedResolvedProperties = new HashSet <String>();
            IShorthandResolver   backgroundResolver         = ShorthandResolverFactory.GetShorthandResolver(CommonCssConstants.BACKGROUND_POSITION
                                                                                                            );

            NUnit.Framework.Assert.IsNotNull(backgroundResolver);
            IList <CssDeclaration> resolvedShorthandProps = backgroundResolver.ResolveShorthand(shorthandExpression);

            CssShorthandResolverTest.CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
Пример #6
0
        public virtual void OutlineTest01()
        {
            String shorthandExpression = "#00ff00 dashed medium";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("outline-color: #00ff00"
                                                                                                         , "outline-style: dashed", "outline-width: medium"));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CommonCssConstants.OUTLINE);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
Пример #7
0
        public virtual void PaddingTest03()
        {
            String shorthandExpression = "inherit";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("padding-top: inherit"
                                                                                                         , "padding-right: inherit", "padding-bottom: inherit", "padding-left: inherit"));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CommonCssConstants.PADDING);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
        public virtual void BorderRightTest01()
        {
            String shorthandExpression = "10px double rgb(12,220,100)";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-right-width: 10px"
                                                                                                         , "border-right-style: double", "border-right-color: rgb(12,220,100)"));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BORDER_RIGHT);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
Пример #9
0
        public virtual void MarginTest02()
        {
            String shorthandExpression = "2cm auto 4cm";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("margin-top: 2cm"
                                                                                                         , "margin-right: auto", "margin-bottom: 4cm", "margin-left: auto"));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CommonCssConstants.MARGIN);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
        public virtual void BorderWidthTest01()
        {
            String shorthandExpression = "thin medium thick 10px";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-top-width: thin"
                                                                                                         , "border-right-width: medium", "border-bottom-width: thick", "border-left-width: 10px"));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BORDER_WIDTH);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
        public virtual void BorderLeftTest01()
        {
            String shorthandExpression = "10px solid #ff0000";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-left-width: 10px"
                                                                                                         , "border-left-style: solid", "border-left-color: #ff0000"));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BORDER_LEFT);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
        public virtual void BorderBottomTest01()
        {
            String shorthandExpression = "15px dotted blue";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-bottom-width: 15px"
                                                                                                         , "border-bottom-style: dotted", "border-bottom-color: blue"));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BORDER_BOTTOM);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
Пример #13
0
        public virtual void NoneInlistStyleImageTest()
        {
            String shorthandExpression = "circle none inside";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("list-style-type: circle"
                                                                                                         , "list-style-position: inside", "list-style-image: none"));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CommonCssConstants.LIST_STYLE);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
        public virtual void ListStyleTest02()
        {
            String shorthandExpression = "inside url('sqpurple.gif')";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("list-style-type: initial"
                                                                                                         , "list-style-position: inside", "list-style-image: url('sqpurple.gif')"));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.LIST_STYLE);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
Пример #15
0
        public virtual void RepeatingLinearGradientInlistStyleImageTest()
        {
            String shorthandExpression = "square inside repeating-linear-gradient(45deg, blue 7%, red 10%)";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("list-style-type: square"
                                                                                                         , "list-style-position: inside", "list-style-image: repeating-linear-gradient(45deg,blue 7%,red 10%)")
                                                                                   );
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CommonCssConstants.LIST_STYLE);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
Пример #16
0
        public virtual void FontTest09()
        {
            String shorthandExpression = "Georgia  ,   'Times New Roman', serif";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("font-style: initial"
                                                                                                         , "font-variant: initial", "font-weight: initial", "font-size: initial", "line-height: initial", "font-family: georgia,'Times New Roman',serif"
                                                                                                         ));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CommonCssConstants.FONT);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
Пример #17
0
        public virtual void MultiValueMissedValueTest()
        {
            String shorthandExpression = "left,top";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("background-position-x: left,center"
                                                                                                         , "background-position-y: center,top"));
            IShorthandResolver backgroundResolver = ShorthandResolverFactory.GetShorthandResolver(CommonCssConstants.BACKGROUND_POSITION
                                                                                                  );

            NUnit.Framework.Assert.IsNotNull(backgroundResolver);
            IList <CssDeclaration> resolvedShorthandProps = backgroundResolver.ResolveShorthand(shorthandExpression);

            CssShorthandResolverTest.CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
Пример #18
0
        public virtual void BorderTest01()
        {
            String shorthandExpression = "thick groove black";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-top-width: thick"
                                                                                                         , "border-right-width: thick", "border-bottom-width: thick", "border-left-width: thick", "border-top-style: groove"
                                                                                                         , "border-right-style: groove", "border-bottom-style: groove", "border-left-style: groove", "border-top-color: black"
                                                                                                         , "border-right-color: black", "border-bottom-color: black", "border-left-color: black"));
            IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CommonCssConstants.BORDER);

            NUnit.Framework.Assert.IsNotNull(resolver);
            IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
        public virtual void BackgroundTest03()
        {
            String shorthandExpression = "url('img.gif') 25%/50px 150px fixed border-box";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("background-color: initial"
                                                                                                         , "background-image: url('img.gif')", "background-position: 25%", "background-size: 50px 150px", "background-repeat: initial"
                                                                                                         , "background-origin: border-box", "background-clip: initial", "background-attachment: fixed"));
            IShorthandResolver backgroundResolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BACKGROUND
                                                                                                  );

            NUnit.Framework.Assert.IsNotNull(backgroundResolver);
            IList <CssDeclaration> resolvedShorthandProps = backgroundResolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
        public virtual void BackgroundTest05()
        {
            String shorthandExpression = "rgdbq(150,90,60) url'smiley.gif') repeat-x scroll 20 60%";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("background-color: initial"
                                                                                                         , "background-image: initial", "background-position: 20 60%", "background-size: initial", "background-repeat: repeat-x"
                                                                                                         , "background-origin: initial", "background-clip: initial", "background-attachment: scroll"));
            IShorthandResolver backgroundResolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BACKGROUND
                                                                                                  );

            NUnit.Framework.Assert.IsNotNull(backgroundResolver);
            IList <CssDeclaration> resolvedShorthandProps = backgroundResolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
        public virtual void BackgroundTest06()
        {
            String shorthandExpression = "DarkOliveGreen fixed center";
            ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("background-color: darkolivegreen"
                                                                                                         , "background-image: initial", "background-position: center", "background-size: initial", "background-repeat: initial"
                                                                                                         , "background-origin: initial", "background-clip: initial", "background-attachment: fixed"));
            IShorthandResolver backgroundResolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BACKGROUND
                                                                                                  );

            NUnit.Framework.Assert.IsNotNull(backgroundResolver);
            IList <CssDeclaration> resolvedShorthandProps = backgroundResolver.ResolveShorthand(shorthandExpression);

            CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties);
        }
Пример #22
0
 /// <summary>Populates the CSS declarations map.</summary>
 /// <param name="declarations">the declarations</param>
 /// <param name="map">the map</param>
 private static void PopulateDeclarationsMap(IList <CssDeclaration> declarations, IDictionary <String, CssDeclaration
                                                                                               > map)
 {
     foreach (CssDeclaration declaration in declarations)
     {
         IShorthandResolver shorthandResolver = ShorthandResolverFactory.GetShorthandResolver(declaration.GetProperty
                                                                                                  ());
         if (shorthandResolver == null)
         {
             PutDeclarationInMapIfValid(map, declaration);
         }
         else
         {
             IList <CssDeclaration> resolvedShorthandProps = shorthandResolver.ResolveShorthand(declaration.GetExpression
                                                                                                    ());
             PopulateDeclarationsMap(resolvedShorthandProps, map);
         }
     }
 }
        /* (non-Javadoc)
         * @see com.itextpdf.styledxmlparser.css.resolve.shorthand.impl.AbstractBorderShorthandResolver#resolveShorthand(java.lang.String)
         */
        public override IList <CssDeclaration> ResolveShorthand(String shorthandExpression)
        {
            IList <CssDeclaration> preResolvedProps = base.ResolveShorthand(shorthandExpression);
            IList <CssDeclaration> resolvedProps    = new List <CssDeclaration>();

            foreach (CssDeclaration prop in preResolvedProps)
            {
                IShorthandResolver shorthandResolver = ShorthandResolverFactory.GetShorthandResolver(prop.GetProperty());
                if (shorthandResolver != null)
                {
                    resolvedProps.AddAll(shorthandResolver.ResolveShorthand(prop.GetExpression()));
                }
                else
                {
                    ILog logger = LogManager.GetLogger(typeof(BorderShorthandResolver));
                    logger.Error(MessageFormatUtil.Format("Cannot find a shorthand resolver for the \"{0}\" property. " + "Expected border-width, border-style or border-color properties."
                                                          , prop.GetProperty()));
                }
            }
            return(resolvedProps);
        }
Пример #24
0
 private static bool CheckProperties(IDictionary <CssBackgroundUtils.BackgroundPropertyType, String> resolvedProps
                                     )
 {
     foreach (KeyValuePair <CssBackgroundUtils.BackgroundPropertyType, String> property in resolvedProps)
     {
         if (!CssDeclarationValidationMaster.CheckDeclaration(new CssDeclaration(CssBackgroundUtils.GetBackgroundPropertyNameFromType
                                                                                     (property.Key), property.Value)))
         {
             LOGGER.Error(MessageFormatUtil.Format(iText.StyledXmlParser.LogMessageConstant.INVALID_CSS_PROPERTY_DECLARATION
                                                   , property.Value));
             return(false);
         }
         IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssBackgroundUtils.GetBackgroundPropertyNameFromType
                                                                                         (property.Key));
         if (resolver != null && resolver.ResolveShorthand(property.Value).IsEmpty())
         {
             return(false);
         }
     }
     return(true);
 }