Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Test case for create BitmapDecoder with async file stream. #14

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Microsoft.DotNet.Wpf.Test.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DrtStartupUriXamlNavigation
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommonData", "src\Test\BranchCommon\data\CommonData.csproj", "{D5F8FF19-BE50-49D3-9343-EEF2182611B7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DrtBitmapDecoder", "src\Test\AppModel\DRT\Imaging\BitmapDecoder\DrtBitmapDecoder.csproj", "{2D51BB8E-29D7-4CB7-8AB4-DA37FE14A99F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestServices", "src\Test\Common\DRT\TestServices\TestServices.csproj", "{12B6B1C0-A834-4223-B5F4-5813F2D73FAA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DrtTools", "src\Test\Common\DRT\Tools\DrtTools.csproj", "{AB52B060-FE86-4630-937D-368C7945F0F0}"
Expand Down
53 changes: 53 additions & 0 deletions src/Test/AppModel/DRT/Imaging/BitmapDecoder/DrtBitmapDecoder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;

namespace DRT
{
public class DrtBitmapDecoder
{
static int Main(string[] args)
{
var logger = new Logger("DrtBitmapDecoder", "Microsoft",
"Testing decode the image file that created with Asynchronous");

var imageFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Image.png");

using var fileStream = new FileStream(imageFile,
FileMode.Open,
FileAccess.Read,
FileShare.Read,
4096,
FileOptions.Asynchronous);

var passed = false;

try
{
// See https://github.com/dotnet/wpf/issues/4355
_ = BitmapDecoder.Create(fileStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None);
passed = true;
}
catch (ArgumentException)
{
passed = false;
}

if (passed)
{
logger.Log("Passed");
return 0;
}
else
{
logger.Log("ERROR: - DrtBitmapDecoder. Can not decode the async file stream.");
return 1;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>DrtBitmapDecoder</AssemblyName>
<LinkSubsystem>console</LinkSubsystem>
<AssemblyIdentityVersionName>WCP</AssemblyIdentityVersionName>
<OutputType>EXE</OutputType>
<GenerateAssemblyAttribute>false</GenerateAssemblyAttribute>
<TestCode>true</TestCode>
<RootNamespace>DRT</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\Logger\Logger.cs" />
<Compile Include="DrtBitmapDecoder.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Image.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/Test/BranchCommon/data/DrtList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Rundrtlist
<Drt Executable="DrtWindowHeightWidthTopLeft.exe" Architecture="all" OS="all" Owner="Microsoft" Team="AppModel" />
<Drt Executable="DrtWindowDragMove.exe" Architecture="all" OS="all" Owner="Microsoft" Team="AppModel" />
<Drt Executable="DrtAppShutdown.exe" Architecture="all" OS="all" Owner="Microsoft" Team="AppModel" />
<Drt Executable="DrtBitmapDecoder.exe" Architecture="all" OS="all" Owner="Microsoft" Team="AppModel" />
<Drt Executable="DrtAppThreadingModel.exe" Architecture="all" OS="all" Owner="Microsoft" Team="AppModel" />
<Drt Executable="DrtApplicationEvents.cmd" Architecture="all" OS="all" Owner="Microsoft" Team="AppModel" >
<SupportFiles>
Expand Down