Browse Source

Implement styled boxes conformance test with semantic structure

Marcin Ziąbek 1 month ago
parent
commit
4454e76475
1 changed files with 71 additions and 2 deletions
  1. 71 2
      Source/QuestPDF.ConformanceTests/StyledBoxTests.cs

+ 71 - 2
Source/QuestPDF.ConformanceTests/StyledBoxTests.cs

@@ -1,6 +1,8 @@
 using QuestPDF.ConformanceTests.TestEngine;
 using QuestPDF.ConformanceTests.TestEngine;
 using QuestPDF.Drawing;
 using QuestPDF.Drawing;
 using QuestPDF.Fluent;
 using QuestPDF.Fluent;
+using QuestPDF.Helpers;
+using QuestPDF.Infrastructure;
 
 
 namespace QuestPDF.ConformanceTests;
 namespace QuestPDF.ConformanceTests;
 
 
@@ -8,11 +10,78 @@ internal class StyledBoxTests : ConformanceTestBase
 {
 {
     protected override Document GetDocumentUnderTest()
     protected override Document GetDocumentUnderTest()
     {
     {
-        throw new NotImplementedException();
+        var avoidTransparency = TestContext.CurrentContext.Test.Arguments.FirstOrDefault() is PDFA_Conformance.PDFA_1A or PDFA_Conformance.PDFA_1B;
+        
+        return Document
+            .Create(document =>
+            {
+                document.Page(page =>
+                {
+                    page.Margin(60);
+
+                    page.Content()
+                        .PaddingVertical(30)
+                        .SemanticSection()
+                        .Column(column =>
+                        {
+                            column.Spacing(30);
+
+                            column.Item()
+                                .SemanticHeader1()
+                                .Text("Conformance Test: Styled Boxes")
+                                .FontSize(36)
+                                .Bold()
+                                .FontColor(Colors.Blue.Darken2);
+
+                            column.Item()
+                                .Background(Colors.Blue.Lighten4)
+                                .Padding(20)
+                                .Text("Background only")
+                                .FontSize(16);
+
+                            column.Item()
+                                .Border(2, Colors.Blue.Darken2)
+                                .Padding(20)
+                                .Text("Border only")
+                                .FontSize(16);
+
+                            column.Item()
+                                .Background(Colors.White)
+                                .Shadow(new BoxShadowStyle
+                                {
+                                    OffsetX = 5,
+                                    OffsetY = 5,
+                                    Blur = avoidTransparency ? 0 : 10,
+                                    Spread = 5,
+                                    Color = Colors.Grey.Medium
+                                })
+                                .Padding(20)
+                                .Text("Simple shadow")
+                                .FontSize(16);
+
+                            column.Item()
+                                .Border(1, Colors.Purple.Lighten4)
+                                .Background(Colors.Purple.Lighten5)
+                                .CornerRadius(15)
+                                .Padding(20)
+                                .Text("Rounded corners")
+                                .FontSize(16);
+                        });
+                });
+            });
     }
     }
 
 
     protected override SemanticTreeNode? GetExpectedSemanticTree()
     protected override SemanticTreeNode? GetExpectedSemanticTree()
     {
     {
-        throw new NotImplementedException();
+        return ExpectedSemanticTree.DocumentRoot(root =>
+        {
+            root.Child("Sect", sect =>
+            {
+                sect.Child("H1", h1 => h1.Alt("Conformance Test: Styled Boxes"));
+
+                foreach (var i in Enumerable.Range(1, 4))
+                    sect.Child("P");
+            });
+        });
     }
     }
 }
 }