mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
Enable PDF files in preview pane (#9088)
## Summary of the Pull Request This PR enables user to preview PDF files in the Explorer preview pane and in Outlook. **What is this about:** Windows does not support out of the box experience for previewing PDF files in the preview pane. Users need to install third-party software like Adobe Acrobat reader. The PdfPreviewHandler module enbales the user to preview PDF files. **How does someone test / validate:** Run the installer, open Explorer and select a PDF file, enable the preview pane. Maybe need to remove third-party PDF software. ## Quality Checklist - [X] **Linked issue:** #3548 - [ ] **Communication:** I've discussed this with core contributors in the issue. - [X] **Tests:** Added/updated and all pass - [X] **Installer:** Added/updated and all pass - [X] **Localization:** All end user facing strings can be localized - [ ] **Docs:** Added/ updated - [x] **Binaries:** Any new files are added to WXS / YML - [ ] No new binaries - [x] YML for signing - [x] WXS for installer
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
// 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 Markdig;
|
||||
using Microsoft.PowerToys.PreviewHandler.Markdown;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace PreviewPaneUnitTests
|
||||
{
|
||||
[TestClass]
|
||||
public class HTMLParsingExtensionTest
|
||||
{
|
||||
private static MarkdownPipeline BuidPipeline(IMarkdownExtension extension)
|
||||
{
|
||||
MarkdownPipelineBuilder pipelineBuilder = new MarkdownPipelineBuilder().UseAdvancedExtensions();
|
||||
pipelineBuilder.Extensions.Add(extension);
|
||||
|
||||
return pipelineBuilder.Build();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExtensionUpdatesTablesClassWhenUsed()
|
||||
{
|
||||
// Arrange
|
||||
string mdString = "| A | B |\n| -- | -- | ";
|
||||
HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(() => { });
|
||||
MarkdownPipeline markdownPipeline = BuidPipeline(htmlParsingExtension);
|
||||
|
||||
// Act
|
||||
string html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
|
||||
// Assert
|
||||
const string expected = "<table class=\"table table-striped table-bordered\">\n<thead>\n<tr>\n<th>A</th>\n<th>B</th>\n</tr>\n</thead>\n</table>\n";
|
||||
Assert.AreEqual(expected, html);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExtensionUpdatesBlockQuotesClassWhenUsed()
|
||||
{
|
||||
// Arrange
|
||||
string mdString = "> Blockquotes.";
|
||||
HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(() => { });
|
||||
MarkdownPipeline markdownPipeline = BuidPipeline(htmlParsingExtension);
|
||||
|
||||
// Act
|
||||
string html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
|
||||
// Assert
|
||||
const string expected = "<blockquote class=\"blockquote\">\n<p>Blockquotes.</p>\n</blockquote>\n";
|
||||
Assert.AreEqual(expected, html);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExtensionUpdatesFigureClassAndBlocksRelativeUrlWhenUsed()
|
||||
{
|
||||
// arrange
|
||||
string mdString = "";
|
||||
HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(() => { }, "C:\\Users\\");
|
||||
MarkdownPipeline markdownPipeline = BuidPipeline(htmlParsingExtension);
|
||||
|
||||
// Act
|
||||
string html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
|
||||
// Assert
|
||||
const string expected = "<p><img src=\"#\" class=\"img-fluid\" alt=\"text\" title=\"Figure\" /></p>\n";
|
||||
Assert.AreEqual(expected, html);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExtensionAddsClassToFigureCaptionWhenUsed()
|
||||
{
|
||||
// arrange
|
||||
string mdString = "^^^ This is a caption";
|
||||
HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(() => { }, "C:/Users/");
|
||||
MarkdownPipeline markdownPipeline = BuidPipeline(htmlParsingExtension);
|
||||
|
||||
// Act
|
||||
string html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
|
||||
// Assert
|
||||
const string expected = "<figure class=\"figure\">\n<figcaption class=\"figure-caption\">This is a caption</figcaption>\n</figure>\n";
|
||||
Assert.AreEqual(expected, html);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExtensionRemovesExternalImageUrlAndMakeCallbackWhenUsed()
|
||||
{
|
||||
// arrange
|
||||
int count = 0;
|
||||
string mdString = "";
|
||||
HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(() => { count++; });
|
||||
MarkdownPipeline markdownPipeline = BuidPipeline(htmlParsingExtension);
|
||||
|
||||
// Act
|
||||
string html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, count);
|
||||
const string expected = "<p><img src=\"#\" class=\"img-fluid\" alt=\"text\" title=\"Figure\" /></p>\n";
|
||||
Assert.AreEqual(expected, html);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user