mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-27 14:59:16 +08:00
[ci] Fix pdf thumbnail unit tests flakiness (#13248)
* [ci] reduce pdf preview and thumbnail flakiness * [ci] run pdf thumbnail tests * [meta] add pdf modules to new issue template
This commit is contained in:
parent
8115a709e9
commit
323f41d14b
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -39,6 +39,8 @@ body:
|
||||
- Image Resizer
|
||||
- Keyboard Manager
|
||||
- MD Preview
|
||||
- PDF Preview
|
||||
- PDF Thumbnail
|
||||
- PowerRename
|
||||
- PowerToys Run
|
||||
- Shortcut Guide
|
||||
|
@ -121,6 +121,7 @@ steps:
|
||||
testSelector: 'testAssemblies'
|
||||
testAssemblyVer2: |
|
||||
**\UnitTests-SvgThumbnailProvider.dll
|
||||
**\UnitTests-PdfThumbnailProvider.dll
|
||||
**\Microsoft.PowerToys.Settings.UI.UnitTests.dll
|
||||
**\UnitTests-MarkdownPreviewHandler.dll
|
||||
**\UnitTests-PdfPreviewHandler.dll
|
||||
|
@ -66,16 +66,18 @@ namespace PdfPreviewHandlerUnitTests
|
||||
private static IStream GetMockStream(byte[] sourceArray)
|
||||
{
|
||||
var streamMock = new Mock<IStream>();
|
||||
var firstCall = true;
|
||||
int bytesRead = 0;
|
||||
|
||||
streamMock
|
||||
.Setup(x => x.Read(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<IntPtr>()))
|
||||
.Callback<byte[], int, IntPtr>((buffer, countToRead, bytesReadPtr) =>
|
||||
{
|
||||
if (firstCall)
|
||||
int actualCountToRead = Math.Min(sourceArray.Length - bytesRead, countToRead);
|
||||
if (actualCountToRead > 0)
|
||||
{
|
||||
Array.Copy(sourceArray, 0, buffer, 0, sourceArray.Length);
|
||||
Marshal.WriteInt32(bytesReadPtr, sourceArray.Length);
|
||||
firstCall = false;
|
||||
Array.Copy(sourceArray, bytesRead, buffer, 0, actualCountToRead);
|
||||
Marshal.WriteInt32(bytesReadPtr, actualCountToRead);
|
||||
bytesRead += actualCountToRead;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -70,16 +70,18 @@ namespace PdfThumbnailProviderUnitTests
|
||||
private static IStream GetMockStream(byte[] sourceArray)
|
||||
{
|
||||
var streamMock = new Mock<IStream>();
|
||||
var firstCall = true;
|
||||
int bytesRead = 0;
|
||||
|
||||
streamMock
|
||||
.Setup(x => x.Read(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<IntPtr>()))
|
||||
.Callback<byte[], int, IntPtr>((buffer, countToRead, bytesReadPtr) =>
|
||||
{
|
||||
if (firstCall)
|
||||
int actualCountToRead = Math.Min(sourceArray.Length - bytesRead, countToRead);
|
||||
if (actualCountToRead > 0)
|
||||
{
|
||||
Array.Copy(sourceArray, 0, buffer, 0, sourceArray.Length);
|
||||
Marshal.WriteInt32(bytesReadPtr, sourceArray.Length);
|
||||
firstCall = false;
|
||||
Array.Copy(sourceArray, bytesRead, buffer, 0, actualCountToRead);
|
||||
Marshal.WriteInt32(bytesReadPtr, actualCountToRead);
|
||||
bytesRead += actualCountToRead;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user