// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.PowerToys.STATestExtension;
using Microsoft.PowerToys.ThumbnailHandler.Svg;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace SvgThumbnailProviderUnitTests
{
[STATestClass]
public class SvgThumbnailProviderTests
{
[TestMethod]
public void LoadSimpleSVGShouldReturnNonNullBitmap()
{
var svgBuilder = new StringBuilder();
svgBuilder.AppendLine("");
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider(null);
svgThumbnailProvider.SvgContents = svgBuilder.ToString();
svgThumbnailProvider.SvgContentsReady.Set();
Bitmap thumbnail = svgThumbnailProvider.GetThumbnail(256);
Assert.IsNotNull(thumbnail);
Assert.IsTrue(thumbnail.Width > 0);
Assert.IsTrue(thumbnail.Height > 0);
}
[TestMethod]
public void CheckBlockedElementsShouldReturnNonNullBitmapIfBlockedElementsIsPresentInNestedLevel()
{
var svgBuilder = new StringBuilder();
svgBuilder.AppendLine("");
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider(null);
svgThumbnailProvider.SvgContents = svgBuilder.ToString();
svgThumbnailProvider.SvgContentsReady.Set();
Bitmap thumbnail = svgThumbnailProvider.GetThumbnail(256);
Assert.IsTrue(thumbnail != null);
}
[TestMethod]
public void CheckThatWidthAndHeightAreParsedCorrectly1()
{
SvgThumbnailProvider svgThumbnailProvider = new SvgThumbnailProvider(null);
svgThumbnailProvider.SvgContents = @"