@@ -47,9 +47,12 @@ This file is part of the iText (R) project.
47
47
import com .itextpdf .styledxmlparser .CommonAttributeConstants ;
48
48
import com .itextpdf .styledxmlparser .LogMessageConstant ;
49
49
import com .itextpdf .styledxmlparser .css .CommonCssConstants ;
50
+ import com .itextpdf .styledxmlparser .css .pseudo .CssPseudoElementNode ;
50
51
import com .itextpdf .styledxmlparser .exceptions .StyledXMLParserException ;
51
52
import com .itextpdf .styledxmlparser .jsoup .nodes .Element ;
52
53
import com .itextpdf .styledxmlparser .jsoup .parser .Tag ;
54
+ import com .itextpdf .styledxmlparser .node .IElementNode ;
55
+ import com .itextpdf .styledxmlparser .node .INode ;
53
56
import com .itextpdf .styledxmlparser .node .impl .jsoup .node .JsoupElementNode ;
54
57
import com .itextpdf .test .ExtendedITextTest ;
55
58
import com .itextpdf .test .annotations .LogMessage ;
@@ -465,4 +468,129 @@ public void isNegativeValueTest() {
465
468
Assert .assertTrue (CssUtils .isNegativeValue ("-0.123" ));
466
469
Assert .assertTrue (CssUtils .isNegativeValue ("-.34" ));
467
470
}
471
+
472
+ @ Test
473
+ public void testWrongAttrTest01 () {
474
+ String strToParse = "attr((href))" ;
475
+ String result = CssUtils .extractAttributeValue (strToParse , null );
476
+ Assert .assertNull (result );
477
+ }
478
+
479
+ @ Test
480
+ public void testWrongAttrTest02 () {
481
+ String strToParse = "attr('href')" ;
482
+ String result = CssUtils .extractAttributeValue (strToParse , null );
483
+ Assert .assertNull (result );
484
+ }
485
+
486
+ @ Test
487
+ public void testWrongAttrTest03 () {
488
+ String strToParse = "attrrname)" ;
489
+ String result = CssUtils .extractAttributeValue (strToParse , null );
490
+ Assert .assertNull (result );
491
+ }
492
+
493
+ @ Test
494
+ public void testExtractingAttrTest01 () {
495
+ IElementNode iNode = new CssPseudoElementNode (null , "url" );
496
+ String strToParse = "attr(url)" ;
497
+ String result = CssUtils .extractAttributeValue (strToParse , iNode );
498
+ Assert .assertEquals ("" , result );
499
+ }
500
+
501
+ @ Test
502
+ public void testExtractingAttrTest02 () {
503
+ IElementNode iNode = new CssPseudoElementNode (null , "test" );
504
+ String strToParse = "attr(url url)" ;
505
+ String result = CssUtils .extractAttributeValue (strToParse , iNode );
506
+ Assert .assertNull (result );
507
+ }
508
+
509
+ @ Test
510
+ public void testExtractingAttrTest03 () {
511
+ IElementNode iNode = new CssPseudoElementNode (null , "test" );
512
+ String strToParse = "attr(url url,#one)" ;
513
+ String result = CssUtils .extractAttributeValue (strToParse , iNode );
514
+ Assert .assertEquals ("#one" , result );
515
+ }
516
+
517
+ @ Test
518
+ public void testExtractingAttrTest04 () {
519
+ IElementNode iNode = new CssPseudoElementNode (null , "test" );
520
+ String strToParse = "attr()" ;
521
+ String result = CssUtils .extractAttributeValue (strToParse , iNode );
522
+ Assert .assertNull (result );
523
+ }
524
+
525
+ @ Test
526
+ public void testExtractingAttrTest05 () {
527
+ IElementNode iNode = new CssPseudoElementNode (null , "test" );
528
+ String strToParse = "attr('\' )" ;
529
+ String result = CssUtils .extractAttributeValue (strToParse , iNode );
530
+ Assert .assertNull (result );
531
+ }
532
+
533
+ @ Test
534
+ public void testExtractingAttrTest06 () {
535
+ IElementNode iNode = new CssPseudoElementNode (null , "test" );
536
+ String strToParse = "attr(str,\" hey\" )" ;
537
+ String result = CssUtils .extractAttributeValue (strToParse , iNode );
538
+ Assert .assertEquals ("hey" , result );
539
+ }
540
+
541
+ @ Test
542
+ public void testExtractingAttrTest07 () {
543
+ IElementNode iNode = new CssPseudoElementNode (null , "test" );
544
+ String strToParse = "attr(str string)" ;
545
+ String result = CssUtils .extractAttributeValue (strToParse , iNode );
546
+ Assert .assertEquals ("" , result );
547
+ }
548
+
549
+ @ Test
550
+ public void testExtractingAttrTest08 () {
551
+ IElementNode iNode = new CssPseudoElementNode (null , "test" );
552
+ String strToParse = "attr(str string,\" value\" )" ;
553
+ String result = CssUtils .extractAttributeValue (strToParse , iNode );
554
+ Assert .assertEquals ("value" , result );
555
+ }
556
+
557
+ @ Test
558
+ public void testExtractingAttrTest09 () {
559
+ IElementNode iNode = new CssPseudoElementNode (null , "test" );
560
+ String strToParse = "attr(str string,\" val,ue\" )" ;
561
+ String result = CssUtils .extractAttributeValue (strToParse , iNode );
562
+ Assert .assertEquals ("val,ue" , result );
563
+ }
564
+
565
+ @ Test
566
+ public void testExtractingAttrTest10 () {
567
+ IElementNode iNode = new CssPseudoElementNode (null , "test" );
568
+ String strToParse = "attr(str string,'val,ue')" ;
569
+ String result = CssUtils .extractAttributeValue (strToParse , iNode );
570
+ Assert .assertEquals ("val,ue" , result );
571
+ }
572
+
573
+ @ Test
574
+ public void testExtractingAttrTest11 () {
575
+ IElementNode iNode = new CssPseudoElementNode (null , "test" );
576
+ String strToParse = "attr(name, \" value\" , \" value\" , \" value\" )" ;
577
+ String result = CssUtils .extractAttributeValue (strToParse , iNode );
578
+ Assert .assertNull (result );
579
+ }
580
+
581
+ @ Test
582
+ public void wrongAttributeTypeTest () {
583
+ IElementNode iNode = new CssPseudoElementNode (null , "test" );
584
+ String strToParse = "attr(str mem)" ;
585
+ String result = CssUtils .extractAttributeValue (strToParse , iNode );
586
+ Assert .assertNull (result );
587
+ }
588
+
589
+ @ Test
590
+ public void wrongParamsInAttrFunctionTest () {
591
+ IElementNode iNode = new CssPseudoElementNode (null , "test" );
592
+ String strToParse = "attr(str mem lol)" ;
593
+ String result = CssUtils .extractAttributeValue (strToParse , iNode );
594
+ Assert .assertNull (result );
595
+ }
468
596
}
0 commit comments