-
Notifications
You must be signed in to change notification settings - Fork 4.8k
[System.Drawing] Add unit tests based on Mono's test suite #23797
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. | ||
| // | ||
| // 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)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is identical to an existing test that we already have checked in |
||
| { | ||
| Assert.Equal(0, gpi.Count); | ||
| } | ||
| } | ||
|
|
||
| [ConditionalFact(Helpers.GdiplusIsAvailable)] | ||
| public void NextMarker_Null() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is basically covered by an existing test. https://github.com/dotnet/corefx/blob/master/src/System.Drawing.Common/tests/Drawing2D/GraphicsPathIteratorTests.cs#L351 |
||
| { | ||
| 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)); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.