@@ -166,6 +166,38 @@ public async Task ShouldConvertHtmlToPngScreenshotOptions(string testFileName, b
166166 await ChromiumProcessDisposedAsserter . AssertNoChromiumProcessIsRunning ( ) ;
167167 }
168168
169+ [ Theory ]
170+ [ InlineData ( "BasicTextFormatedInlineBackground.html" , false , 15000 ) ]
171+ [ InlineData ( "BasicTextFormatedInlineBackground.html" , true , 9500 ) ]
172+ public async Task ShouldConvertHtmlToPngBufferOptions ( string testFileName , bool omitBackground , int allowedPixelDiff )
173+ {
174+ var sourceHtmlFilePath = $ "../../../TestInput/{ testFileName } ";
175+ var actualFilePath = Path . Combine ( Path . GetTempPath ( ) , $ "ActualConvertHtmlToPng{ testFileName } .{ omitBackground } .png") ;
176+ var expectReferenceFilePath = $ "../../../ExpectedTestOutcome/ExpectedConvertHtmlToPng{ testFileName } .{ omitBackground } .png";
177+
178+ if ( File . Exists ( actualFilePath ) )
179+ {
180+ File . Delete ( actualFilePath ) ;
181+ }
182+
183+ await using ( var chromiumRenderer = await Renderer . CreateAsync ( ) )
184+ {
185+ ScreenshotOptions screenshotOptions = new ScreenshotOptions
186+ {
187+ OmitBackground = omitBackground
188+ } ;
189+
190+ var fileContent = await File . ReadAllTextAsync ( sourceHtmlFilePath ) ;
191+ var pngData = await chromiumRenderer . ConvertHtmlStringToPngData ( fileContent , screenshotOptions ) ;
192+ // File.Copy(actualFilePath, expectReferenceFilePath, true);
193+ await File . WriteAllBytesAsync ( actualFilePath , pngData ) ;
194+ DocumentAsserter . AssertImageIsEqual ( actualFilePath , expectReferenceFilePath , allowedPixelDiff ) ;
195+ }
196+
197+ File . Delete ( actualFilePath ) ;
198+ await ChromiumProcessDisposedAsserter . AssertNoChromiumProcessIsRunning ( ) ;
199+ }
200+
169201 [ Fact ]
170202 public async Task ShouldDisposeGracefull ( )
171203 {
0 commit comments