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 Tests for System.Drawing.Common #22130
Comments
Hi I can grab some part of those tests for example System.Drawing.Printing, on start. Then when all will be fine i can port next part. What do you think? |
@norek Splitting up the work sounds like a good idea to me. I've created separate items above for each of the folders in mono's test bed. I've put your name next to System.Drawing.Printing. Looking over the tests in that folder, I think they are fairly straightforward, with a couple of exceptions. I would ignore the following tests for now:
We don't care about any of this permissions stuff in .NET Core, nor do we enforce it.
This one isn't going to work outside of Unix or the libgdiplus implemetation, so don't bother with it for now. |
@mellinoe in |
@norek Oops -- it was a mistake to include it in the solution file. I had a couple of tests written on my local machine, but they weren't worth merging. |
I have little question about moving tests from Nunit to Xunit. In mono tests, very often |
Yes -- remove the description. If really necessary, just provide the message in a comment next to the assertion. |
@norek a test project has been merged so feel free to get started. Mind if I ask what you're working on so we avoid conflicts? Note that I'm gonna put some effort into beautifying and modernising these tests using xunit's features like parameter names in exceptions and theory/member data Keep me up to date :) |
@hughbe Thanks! Im working on System.Drawing.Printing namespace. In description of this issue You can see list of assigned items. |
How about testing
I dont know what to do with this. |
@norek We certainly don't have any printers attached to the machines that run our CI tests, if that is what you are alluding to. You can just keep that check in the test code. Are you asking about something else? |
@hughbe Could you post something here as you start writing/porting tests for individual components? It would be good to have a list of "in-progress" work so that we know what's being covered. |
@mellinoe yup, this is what I meant. Thanks |
@hughbe Can you tell me what is this? second: In my machine after pull your changes, I have failing your tests for example:
|
Those are |
@norek As for the test failure: what language settings does your computer use? We might be assuming that English is used, and number parsing could fail with other culture settings. |
@mellinoe oh my god...of course you are right, VS17 is answer in this case. That was easy... I dont know what is happening to me this night! Thanks alot. |
@norek Yep, the tests fail if your computer's language is Polish. This also happens on .NET Framework: string htmlColor = "1,256,3";
var color = ColorTranslator.FromHtml(htmlColor);
Console.WriteLine("Color: " + color);
We should override the current culture in the tests that check this stuff. |
If it's not pressing I can do this by tomorrow |
I have a fix here: dotnet/corefx#21016 |
@norek No problem. I have seen enough problems exactly like this that I've come to expect it 😄 |
In PrinterUnitConvert.cs -> method UnitsPerDisplay have this default block in switch statement:
I know that for backward compatibility it shouldn't be converted to Exception but i think we can just remove this Debug.Fail. Otherwise we cannot test this block. What do you think? |
We should delete Debug statements that are failing, I agree. They were written before there were any unit tests. |
Eric, I've also given a stab at cleaning up some of the codebase with a view to use modern C# features etc. etc. It's a big change but fairly montonous - removing devdocs, inline variables, fixup usings etc. If you take a look here I've done an attempt for System.Drawing.Drawing2D. Do you think I should submit a PR? |
@hughbe it should be different PR or can I attach this change to dotnet/corefx#21015? |
Due waiting on dotnet/corefx#21015 feedback I can grab System.Drawing.Common.Imaging. |
Yeah I'll submit a PR linking to that issue |
@mellinoe Do you mean I can do something like <PropertyGroup>
<TestsDataVersion>1.0.3</TestsDataVersion>
</PropertyGroup> in the |
@KostaVlev Yes, that's right. For now, though, just go ahead and hard-code the new version. I may actually want to create a property all the way up in https://github.com/dotnet/corefx/blob/master/dependencies.props, and use that property everywhere in the repo, including the test-runtime project file. That way it would only be specified once. |
…tnet#21866) * Adding System.Drawing.Common.Drawing2D GraphicsPath tests. #20711 * Adding ConditionalFact and ConditionalTheory. Tests will run if IsNotWindowsNanoServer. (dotnet#21866) * Removing dead comments. Removing skips, they don't work. Wrapping GraphicsPath in using block. Adding param names to argument exceptions. Use Assert.Equal(IEnumerable<T>, IEnumerable<T> instead of asserting each element one by one in an array. dotnet#21866 * Pluralizing the name GraphicsPathTest.cs dotnet#21866 * Changing the namespace to System.Drawing.Drawing2D.Tests * Some spelling corrections. Removing unnecessary float casts. Removing single InlineData attributes. (dotnet#21866) * Removing arguments from test methods that are not [Theory]. * Adding System.Drawing.Common.Drawing2D GraphicsPathIteratorTests tests. Test CopyData_StartEndIndexesOutOfRange_ReturnsExpeced() fails with exception System.EntryPointNotFoundException : Unable to find an entry point named 'ZeroMemory' in DLL 'kernel32.dll' , issue is tracked in (#22026). (#20711) * Updating System.Drawing.Common.Tests.csproj. * Removing not related change to dotnet#21866. I will commit this when the pull request is merged. * Reverting changes to System.Drawing.Common.Tests.csproj.
…0711 (dotnet#22157) * Adding System.Drawing.Common.Drawing2D GraphicsPathIteratorTests tests. Test CopyData_StartEndIndexesOutOfRange_ReturnsExpeced() fails with exception System.EntryPointNotFoundException : Unable to find an entry point named 'ZeroMemory' in DLL 'kernel32.dll' , issue is tracked in (#22026). (#20711) * Adding [ActiveIssue(22026)] attribute to CopyData_StartEndIndexesOutOfRange_ReturnsExpeced()
dotnet#22199) * Adding System.Drawing.Common.Drawing2D PathGradientBrush tests. #20711 * Adding test for Dispose(). * Fixing some spellings and splinting long statement to multiple lines. * Completing tests for Disposed. * Spelling correction. * Spelling correction.
Hi, the next one which isn't tested in I wrote this test: [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))]
public void Ctor_IntPtrWmfPlaceableFileHeader_Success()
{
using (var bufferGraphics = Graphics.FromHwndInternal(IntPtr.Zero))
using (var metafile = new Metafile(bufferGraphics.GetHdc(), new WmfPlaceableFileHeader()))
{
Assert.Equal(new Rectangle(0, 0, 0, 0), metafile.GetMetafileHeader().Bounds);
}
} My idea is to create blank The exception occurs on every platform. Any hints how to make this to work? |
@KostaVlev Which call is throwing the exception? I'm pretty sure it is not valid to call |
@mellinoe The graphics object is created successfully It tried this way too but still getting exception. [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))]
public void Ctor_IntPtrWmfPlaceableFileHeader_Success()
{
using (var bitmap = new Bitmap(_rectangle.Width, _rectangle.Height))
using (var bufferGraphics = Graphics.FromImage(bitmap))
using (var metafile = new Metafile(bufferGraphics.GetHdc(), new WmfPlaceableFileHeader()))
{
Assert.Equal(new Rectangle(0, 0, 0, 0), metafile.GetMetafileHeader().Bounds);
}
} Since we have same behavior for netfx and netcoreapp should I skip this test for now? |
Yes |
…22491) * Adding System.Drawing.Common.Imaging ImageAttributesTests tests. #20711 * Reverting some not related changes. * Updating XUnit.Runtime.depproj System.Drawing.Common.TestData version to 1.0.3 * Fixing SetOutputChannelColorProfile_InvalidPath_ThrowsOutOfMemoryException() test. * Renaming _colorMap to _greenCmponentToZeroColorMap. Removing commented out code. Updating Ctor_Default_Success() test. * Renaming _colorMap to _yellowToRedColorMap and _greenCmponentToZeroColorMap to _greenComponentToZeroColorMatrix
* Adding System.Drawing.Common.Imaging Metafile tests. (#20711) * Changing [ConditionalTheory(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] to [ConditionalTheory(Helpers.GdiplusIsAvailable)] * Changing [ConditionalTheory(Helpers.GdiplusIsAvailable)] to [ConditionalFact(Helpers.IsNotLinuxAndGdiplusIsAvailable)] * Changing the way tests will skip Unix.
I moved on System.Drawing.Printing. |
<3 good stuff |
* Adding System.Drawing.Printing PrintDocument tests. (#20711) * Disabling some tests on Unix and making some Facts/Theories conditional. * Fix tests conditional attributes. * Fix tests conditional attributes. * Adding missed test attributes. * Fixing test attributes. * Changing Assertion in AssertDefaultPageSettings() to expect PaperKind Letter. And skipping tests that fail on Unix. * Updating PageSettings.PrintableArea assertions. * Moving the check for PrinterSettings.InstalledPrinters.Count == 0 to Helpers.cs and updating test attributes.
Code coverage numbers are looking really good to me (updated at the top), considering there are a few large files full of dead code (or code that doesn't really need to be tested). Thanks for all of the contributions, everyone! |
How nice, a lot of work was made since my "vacation". I just bought new computer and i'm ready to go! |
Some more steady progress was made in the past month. I think @qmfrederik's current effort will give us enough coverage to fill in the remaining gaps and let us close this issue out. |
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process. This process is part of our issue cleanup automation. |
This issue will now be closed since it had been marked |
This issue tracks porting some set of tests from mono's test suite, covering the portions of System.Drawing that we support on .NET Core.
Mono's test cases are in this folder: https://github.com/mono/mono/tree/master/mcs/class/System.Drawing/Test
We most likely want to convert the most useful tests from all of the sections here, with the exception of System.Drawing.Design, which we aren't going to support right now on .NET Core (it is mainly related to designer / WinForms support).
Mono's tests use NUnit, so we will need to convert them to Xunit when copying them.
Additionally, I've identified that there will need to be some functional changes made to the tests themselves, as they do not pass against the .NET Framework implementation. We consider the .NET Framework implementation to be the compatibility baseline, so we should change the tests to accomodate it, rather than the other way around. The test failures seemed mainly related to very small, subtle differences in things like floating-point precision, color values, offsets, etc. We should do the following when we have both Windows and Unix implementations up and running:
@hughbe @qmfrederik @marek-safar
Current Status
Code coverage:
Note that there is a large amount of internal and debug-only code which distorts these numbers. When the coverage is generally high, we can clean out a lot of dead code and then get more accurate data.
Namespaces and coverage, as of 9/21/2017:
The text was updated successfully, but these errors were encountered: