Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public static partial class PlatformDetection
public static bool IsNotRedHat { get { throw null; } }
public static bool IsRedHat69 { get { throw null; } }
public static bool IsNotRedHat69 { get { throw null; } }
public static bool IsRedHat73 { get { throw null; } }
public static bool IsUap { get { throw null; } }
public static Version ICUVersion { get { return null; } }
public static bool IsUbuntu { get { throw null; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static partial class PlatformDetection
public static bool IsNotRedHat => !IsRedHat;
public static bool IsRedHat69 => IsDistroAndVersion("rhel", "6.9") || IsDistroAndVersion("rhl", "6.9");
public static bool IsNotRedHat69 => !IsRedHat69;
public static bool IsRedHat73 => IsDistroAndVersion("rhel", "7.3") || IsDistroAndVersion("rhl", "7.3");

public static Version OSXKernelVersion { get; } = GetOSXKernelVersion();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static partial class PlatformDetection
public static bool IsNotRedHat => true;
public static bool IsRedHat69 => false;
public static bool IsNotRedHat69 => true;
public static bool IsRedHat73 => false;

public static bool IsWindows10Version1607OrGreater =>
GetWindowsVersion() == 10 && GetWindowsMinorVersion() == 0 && GetWindowsBuildNumber() >= 14393;
Expand Down
43 changes: 43 additions & 0 deletions src/System.Drawing.Common/tests/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,53 @@ public static class Helpers
public const string GdiplusIsAvailable = nameof(Helpers) + "." + nameof(GetGdiplusIsAvailable);
public const string RecentGdiplusIsAvailable = nameof(Helpers) + "." + nameof(GetRecentGdiPlusIsAvailable);
public const string RecentGdiplusIsAvailable2 = nameof(Helpers) + "." + nameof(GetRecentGdiPlusIsAvailable2);
public const string GdiplusIsAvailableOnWindows = nameof(Helpers) + "." + nameof(GetGdiPlusIsAvailableOnWindows);
public const string GdiPlusIsAvailableNotRedhat73 = nameof(Helpers) + "." + nameof(GetGdiPlusIsAvailableNotRedhat73);
public const string GdiPlusIsAvailableNotWindows7 = nameof(Helpers) + "." + nameof(GetGdiPlusIsAvailableNotWindows7);
public const string AnyInstalledPrinters = nameof(Helpers) + "." + nameof(IsAnyInstalledPrinters);

public static bool GetRecentGdiPlusIsAvailable()
{
// CentOS 7, RHEL 7 and Ubuntu 14.04 are running outdated versions of libgdiplus
if (PlatformDetection.IsCentos7 || PlatformDetection.IsRedHat || PlatformDetection.IsUbuntu1404)
{
return false;
}

return GetGdiplusIsAvailable();
}

public static bool GetRecentGdiPlusIsAvailable2()
{
// CentOS 7, RHEL 7 and Ubuntu 14.04, as well as Fedora 25 and OpenSUSE 4.22 are running outdated versions of libgdiplus
if (PlatformDetection.IsCentos7 || PlatformDetection.IsRedHat || PlatformDetection.IsUbuntu1404 || PlatformDetection.IsFedora || PlatformDetection.IsOpenSUSE)
{
return false;
}

return GetGdiplusIsAvailable();
}

public static bool GetGdiPlusIsAvailableOnWindows()
{
if (!PlatformDetection.IsWindows)
{
return false;
}

return GetGdiplusIsAvailable();
}

public static bool GetGdiPlusIsAvailableNotRedhat73()
{
if (PlatformDetection.IsRedHat)
{
return false;
}

return GetGdiplusIsAvailable();
}

public static bool GetGdiplusIsAvailable()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
Expand Down
37 changes: 37 additions & 0 deletions src/System.Drawing.Common/tests/System.Drawing.Common.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,40 @@
<Compile Include="mono\System.Drawing\GraphicsTests.cs" />
<Compile Include="mono\System.Imaging\MetafileTest.cs" />
<Compile Include="mono\System.Drawing\BitmapTests.cs" />
<Compile Include="mono\System.Drawing.Drawing2D\GraphicsPathIteratorTest.cs" />
<Compile Include="mono\System.Drawing.Drawing2D\GraphicsPathTest.cs" />
<Compile Include="mono\System.Drawing.Drawing2D\LinearGradientBrushTest.cs" />
<Compile Include="mono\System.Drawing.Drawing2D\PathDataTest.cs" />
<Compile Include="mono\System.Drawing.Drawing2D\PathGradientBrushTest.cs" />
<Compile Include="mono\System.Drawing.Drawing2D\TestBlend.cs" />
<Compile Include="mono\System.Drawing.Drawing2D\TestColorBlend.cs" />
<Compile Include="mono\System.Drawing.Drawing2D\TestHatchBrush.cs" />
<Compile Include="mono\System.Drawing.Drawing2D\TestMatrix.cs" />
<Compile Include="mono\System.Drawing.Imaging\EmfPlusRecordTypeTest.cs" />
<Compile Include="mono\System.Drawing.Imaging\FrameDimensionTest.cs" />
<Compile Include="mono\System.Drawing.Imaging\TestColorMatrix.cs" />
<Compile Include="mono\System.Drawing.Imaging\TestImageAttributes.cs" />
<Compile Include="mono\System.Drawing.Imaging\TestImageCodecInfo.cs" />
<Compile Include="mono\System.Drawing.Printing\PrintingServicesUnixTest.cs" />
<Compile Include="mono\System.Drawing\ColorTranslator.cs" />
<Compile Include="mono\System.Drawing\FontFamilyTest.cs" />
<Compile Include="mono\System.Drawing\PenTest.cs" />
<Compile Include="mono\System.Drawing\RegionDataTest.cs" />
<Compile Include="mono\System.Drawing\RegionNonRectTest.cs" />
<Compile Include="mono\System.Drawing\SolidBrushTest.cs" />
<Compile Include="mono\System.Drawing\SystemFontsTest.cs" />
<Compile Include="mono\System.Drawing\SystemIconsTest.cs" />
<Compile Include="mono\System.Drawing\TestBitmap.cs" />
<Compile Include="mono\System.Drawing\TestBrushes.cs" />
<Compile Include="mono\System.Drawing\TestFont.cs" />
<Compile Include="mono\System.Drawing\TestIcon.cs" />
<Compile Include="mono\System.Drawing\TestImage.cs" />
<Compile Include="mono\System.Drawing\TestPens.cs" />
<Compile Include="mono\System.Drawing\TestRegion.cs" />
<Compile Include="mono\System.Drawing\TestStringFormat.cs" />
<Compile Include="mono\System.Drawing\TestSystemBrushes.cs" />
<Compile Include="mono\System.Drawing\TestSystemPens.cs" />
<Compile Include="mono\System.Drawing\TextureBrushTest.cs" />
<Compile Include="PenTests.cs" />
<Compile Include="PensTests.cs" />
<Compile Include="Imaging\BitmapDataTests.cs" />
Expand Down Expand Up @@ -108,5 +142,8 @@
<Name>RemoteExecutorConsoleApp</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="mono\resources\" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
// Licensed to the .NET Foundation under one or more agreements.
// See the LICENSE file in the project root for more information.
//
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to include a 2-line header in all of these new files.

// Licensed to the .NET Foundation under one or more agreements.
// See the LICENSE file in the project root for more information.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear, do you need this header in addition to the existing header or does it replace the existing header?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is in addition to the existing header -- it just goes at the very top.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The files under System.Drawing.Common/src/Unix show what it should look like. Those are files pulled in from the mono codebase.

// System.Drawing.Drawing2D.GraphicPathIterator unit tests
//
// Authors:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Security.Permissions;
using Xunit;

namespace MonoTests.System.Drawing.Drawing2D
{

public class GraphicsPathIteratorTest
{

private PointF[] pts_2f = new PointF[2] { new PointF(1, 2), new PointF(20, 30) };

[ConditionalFact(Helpers.GdiplusIsAvailable)]
public void Ctor_Null()
{
using (GraphicsPathIterator gpi = new GraphicsPathIterator(null))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
Assert.Equal(0, gpi.Count);
}
}

[ConditionalFact(Helpers.GdiplusIsAvailable)]
public void NextMarker_Null()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is identical to an existing test.

{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLines(pts_2f);
using (GraphicsPathIterator gpi = new GraphicsPathIterator(gp))
{
Assert.Equal(0, gpi.NextMarker(null));
}
}
}

[ActiveIssue(20844)]
public void NextSubpath_Null()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is identical to an existing test

{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLines(pts_2f);
using (GraphicsPathIterator gpi = new GraphicsPathIterator(gp))
{
bool closed;
Assert.Equal(0, gpi.NextSubpath(null, out closed));
Assert.True(closed);
}
}
}

[ConditionalFact(Helpers.GdiplusIsAvailable)]
public void CopyData_NullPoints()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is identical to an existing test.

{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLines(pts_2f);
using (GraphicsPathIterator gpi = new GraphicsPathIterator(gp))
{
PointF[] points = null;
byte[] types = new byte[1];
Assert.Throws<NullReferenceException>(() => gpi.CopyData(ref points, ref types, 0, 1));
}
}
}

[ConditionalFact(Helpers.GdiplusIsAvailable)]
public void CopyData_NullTypes()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLines(pts_2f);
using (GraphicsPathIterator gpi = new GraphicsPathIterator(gp))
{
PointF[] points = new PointF[1];
byte[] types = null;
Assert.Throws<NullReferenceException>(() => gpi.CopyData(ref points, ref types, 0, 1));
}
}
}

[ConditionalFact(Helpers.GdiplusIsAvailable)]
public void CopyData_DifferentSize()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLines(pts_2f);
using (GraphicsPathIterator gpi = new GraphicsPathIterator(gp))
{
PointF[] points = new PointF[1];
byte[] types = new byte[2];
Assert.Throws<ArgumentException>(() => gpi.CopyData(ref points, ref types, 0, 1));
}
}
}

[ConditionalFact(Helpers.GdiplusIsAvailable)]
public void Enumerate_NullPoints()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLines(pts_2f);
using (GraphicsPathIterator gpi = new GraphicsPathIterator(gp))
{
PointF[] points = null;
byte[] types = new byte[2];
Assert.Throws<NullReferenceException>(() => gpi.Enumerate(ref points, ref types));
}
}
}

[ConditionalFact(Helpers.GdiplusIsAvailable)]
public void Enumerate_NullTypes()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLines(pts_2f);
using (GraphicsPathIterator gpi = new GraphicsPathIterator(gp))
{
PointF[] points = new PointF[1];
byte[] types = null;
Assert.Throws<NullReferenceException>(() => gpi.Enumerate(ref points, ref types));
}
}
}

[ConditionalFact(Helpers.GdiplusIsAvailable)]
public void Enumerate_DifferentSize()
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLines(pts_2f);
using (GraphicsPathIterator gpi = new GraphicsPathIterator(gp))
{
PointF[] points = new PointF[1];
byte[] types = new byte[2];
Assert.Throws<ArgumentException>(() => gpi.Enumerate(ref points, ref types));
}
}
}
}
}
Loading