You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.175
Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
parent
4bdbaf4a88
commit
966bba02bb
@@ -36,7 +36,9 @@ using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
#if !NETCOREAPP2_0
|
||||
using System.Runtime.Serialization.Formatters.Soap;
|
||||
#endif
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Permissions;
|
||||
using System.Text;
|
||||
@@ -46,7 +48,6 @@ using NUnit.Framework;
|
||||
namespace MonoTests.System.Drawing {
|
||||
|
||||
[TestFixture]
|
||||
[SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
|
||||
public class TestBitmap {
|
||||
|
||||
[Test]
|
||||
@@ -121,30 +122,24 @@ namespace MonoTests.System.Drawing {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void LockBits_IndexedWrite_NonIndexed ()
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap (100, 100, PixelFormat.Format8bppIndexed)) {
|
||||
Rectangle rect = new Rectangle (0, 0, bmp.Width, bmp.Height);
|
||||
bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
|
||||
Assert.Throws<ArgumentException> (() => bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void LockBits_NonIndexedWrite_ToIndexed ()
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap (100, 100, PixelFormat.Format32bppRgb)) {
|
||||
BitmapData bd = new BitmapData ();
|
||||
Rectangle rect = new Rectangle (0, 0, bmp.Width, bmp.Height);
|
||||
BitmapData bd = new BitmapData ();
|
||||
try {
|
||||
bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed, bd);
|
||||
}
|
||||
catch (ArgumentException) {
|
||||
// test to see if there's a leak or not in this case
|
||||
Assert.AreEqual (IntPtr.Zero, bd.Scan0, "Scan0");
|
||||
throw;
|
||||
}
|
||||
Assert.Throws<ArgumentException> (() => bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed, bd));
|
||||
|
||||
// test to see if there's a leak or not in this case
|
||||
Assert.AreEqual (IntPtr.Zero, bd.Scan0, "Scan0");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,14 +177,13 @@ namespace MonoTests.System.Drawing {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (InvalidOperationException))]
|
||||
public void LockBits_Double ()
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap (10, 10, PixelFormat.Format24bppRgb)) {
|
||||
Rectangle r = new Rectangle (4, 4, 4, 4);
|
||||
BitmapData data = bmp.LockBits (r, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
|
||||
try {
|
||||
bmp.LockBits (r, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
|
||||
Assert.Throws<InvalidOperationException> (() => bmp.LockBits (r, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb));
|
||||
}
|
||||
finally {
|
||||
bmp.UnlockBits (data);
|
||||
@@ -198,17 +192,15 @@ namespace MonoTests.System.Drawing {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void LockBits_Disposed ()
|
||||
{
|
||||
Bitmap bmp = new Bitmap (100, 100, PixelFormat.Format32bppRgb);
|
||||
Rectangle rect = new Rectangle (0, 0, bmp.Width, bmp.Height);
|
||||
bmp.Dispose ();
|
||||
bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
|
||||
Assert.Throws<ArgumentException> (() => bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
[Category ("Valgrind")] // this test is known to leak memory (API design limitation)
|
||||
public void UnlockBits_Disposed ()
|
||||
{
|
||||
@@ -216,26 +208,24 @@ namespace MonoTests.System.Drawing {
|
||||
Rectangle rect = new Rectangle (0, 0, bmp.Width, bmp.Height);
|
||||
BitmapData data = bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppRgb);
|
||||
bmp.Dispose ();
|
||||
bmp.UnlockBits (data);
|
||||
Assert.Throws<ArgumentException> (() => bmp.UnlockBits (data));
|
||||
// and that results in something like this when executed under Valgrind
|
||||
// "40,000 bytes in 1 blocks are possibly lost in loss record 88 of 92"
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void UnlockBits_Null ()
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap (100, 100, PixelFormat.Format32bppRgb)) {
|
||||
bmp.UnlockBits (null);
|
||||
Assert.Throws<ArgumentException> (() => bmp.UnlockBits (null));
|
||||
}
|
||||
}
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void LockBits_BitmapData_Null ()
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap (100, 100, PixelFormat.Format32bppRgb)) {
|
||||
Rectangle rect = new Rectangle (0, 0, bmp.Width, bmp.Height);
|
||||
bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb, null);
|
||||
Assert.Throws<ArgumentException> (() => bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,46 +290,42 @@ namespace MonoTests.System.Drawing {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (InvalidOperationException))]
|
||||
public void Format1bppIndexed ()
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap (1, 1, PixelFormat.Format1bppIndexed)) {
|
||||
Color c = bmp.GetPixel (0, 0);
|
||||
Assert.AreEqual (-16777216, c.ToArgb (), "Color");
|
||||
bmp.SetPixel (0, 0, c);
|
||||
Assert.Throws<InvalidOperationException> (() => bmp.SetPixel (0, 0, c));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (InvalidOperationException))]
|
||||
public void Format4bppIndexed ()
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap (1, 1, PixelFormat.Format4bppIndexed)) {
|
||||
Color c = bmp.GetPixel (0, 0);
|
||||
Assert.AreEqual (-16777216, c.ToArgb (), "Color");
|
||||
bmp.SetPixel (0, 0, c);
|
||||
Assert.Throws<InvalidOperationException> (() => bmp.SetPixel (0, 0, c));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (InvalidOperationException))]
|
||||
public void Format8bppIndexed ()
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap (1, 1, PixelFormat.Format8bppIndexed)) {
|
||||
Color c = bmp.GetPixel (0, 0);
|
||||
Assert.AreEqual (-16777216, c.ToArgb (), "Color");
|
||||
bmp.SetPixel (0, 0, c);
|
||||
Assert.Throws<InvalidOperationException> (() => bmp.SetPixel (0, 0, c));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
[Category ("NotWorking")] // libgdiplus doesn't support this format
|
||||
public void Format16bppGrayScale ()
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap (1, 1, PixelFormat.Format16bppGrayScale)) {
|
||||
// and MS GDI+ support seems quite limited too
|
||||
bmp.GetPixel (0, 0);
|
||||
Assert.Throws<ArgumentException> (() => bmp.GetPixel (0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,10 +573,9 @@ namespace MonoTests.System.Drawing {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void FileDoesNotExists ()
|
||||
{
|
||||
Bitmap bmp = new Bitmap ("FileDoesNotExists.jpg");
|
||||
Assert.Throws<ArgumentException> (() => new Bitmap ("FileDoesNotExists.jpg"));
|
||||
}
|
||||
|
||||
static string ByteArrayToString(byte[] arrInput)
|
||||
@@ -623,7 +608,7 @@ namespace MonoTests.System.Drawing {
|
||||
}
|
||||
}
|
||||
|
||||
hash = new MD5CryptoServiceProvider().ComputeHash (pixels);
|
||||
hash = MD5.Create ().ComputeHash (pixels);
|
||||
return ByteArrayToString (hash);
|
||||
}
|
||||
public string RotateIndexedBmp (Bitmap src, RotateFlipType type)
|
||||
@@ -673,7 +658,7 @@ namespace MonoTests.System.Drawing {
|
||||
if (pixel_data == null)
|
||||
return "--ERROR--";
|
||||
|
||||
byte[] hash = new MD5CryptoServiceProvider().ComputeHash (pixel_data);
|
||||
byte[] hash = MD5.Create ().ComputeHash (pixel_data);
|
||||
return ByteArrayToString (hash);
|
||||
}
|
||||
|
||||
@@ -1110,6 +1095,7 @@ namespace MonoTests.System.Drawing {
|
||||
}
|
||||
}
|
||||
|
||||
#if !NETCOREAPP2_0
|
||||
private Stream SoapSerialize (object o)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream ();
|
||||
@@ -1176,6 +1162,7 @@ namespace MonoTests.System.Drawing {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")] // http://bugzilla.ximian.com/show_bug.cgi?id=80558
|
||||
@@ -1513,87 +1500,75 @@ namespace MonoTests.System.Drawing {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (NullReferenceException))]
|
||||
public void BitmapImageCtor ()
|
||||
{
|
||||
new Bitmap ((Image) null);
|
||||
Assert.Throws<NullReferenceException> (() => new Bitmap ((Image) null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void BitmapImageSizeCtor ()
|
||||
{
|
||||
new Bitmap ((Image) null, Size.Empty);
|
||||
Assert.Throws<ArgumentException> (() => new Bitmap ((Image) null, Size.Empty));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void BitmapImageIntIntCtor ()
|
||||
{
|
||||
new Bitmap ((Image) null, Int32.MinValue, Int32.MaxValue);
|
||||
Assert.Throws<ArgumentException> (() => new Bitmap ((Image) null, Int32.MinValue, Int32.MaxValue));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void BitmapIntIntCtor ()
|
||||
{
|
||||
new Bitmap (Int32.MinValue, Int32.MaxValue);
|
||||
Assert.Throws<ArgumentException> (() => new Bitmap (Int32.MinValue, Int32.MaxValue));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentNullException))]
|
||||
public void BitmapIntIntGraphicCtor ()
|
||||
{
|
||||
new Bitmap (1, 1, null);
|
||||
Assert.Throws<ArgumentNullException> (() => new Bitmap (1, 1, null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void BitmapIntIntPixelFormatCtor ()
|
||||
{
|
||||
new Bitmap (Int32.MinValue, Int32.MaxValue, PixelFormat.Format1bppIndexed);
|
||||
Assert.Throws<ArgumentException> (() => new Bitmap (Int32.MinValue, Int32.MaxValue, PixelFormat.Format1bppIndexed));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void BitmapStreamCtor ()
|
||||
{
|
||||
new Bitmap ((Stream) null);
|
||||
Assert.Throws<ArgumentException> (() => new Bitmap ((Stream) null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void BitmapStreamBoolCtor ()
|
||||
{
|
||||
new Bitmap ((Stream) null, true);
|
||||
Assert.Throws<ArgumentException> (() => new Bitmap ((Stream) null, true));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentNullException))]
|
||||
public void BitmapStringCtor ()
|
||||
{
|
||||
new Bitmap ((string) null);
|
||||
Assert.Throws<ArgumentNullException> (() => new Bitmap ((string) null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentNullException))]
|
||||
public void BitmapStringBoolCtor ()
|
||||
{
|
||||
new Bitmap ((string) null, false);
|
||||
Assert.Throws<ArgumentNullException> (() => new Bitmap ((string) null, false));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (NullReferenceException))]
|
||||
public void BitmapTypeStringCtor1 ()
|
||||
{
|
||||
new Bitmap ((Type) null, "mono");
|
||||
Assert.Throws<NullReferenceException> (() => new Bitmap ((Type) null, "mono"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void BitmapTypeStringCtor2 ()
|
||||
{
|
||||
new Bitmap (typeof (Bitmap), null);
|
||||
Assert.Throws<ArgumentException> (() => new Bitmap (typeof (Bitmap), null));
|
||||
}
|
||||
|
||||
private void SetResolution (float x, float y)
|
||||
@@ -1604,24 +1579,21 @@ namespace MonoTests.System.Drawing {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void SetResolution_Zero ()
|
||||
{
|
||||
SetResolution (0.0f, 0.0f);
|
||||
Assert.Throws<ArgumentException> (() => SetResolution (0.0f, 0.0f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void SetResolution_Negative_X ()
|
||||
{
|
||||
SetResolution (-1.0f, 1.0f);
|
||||
Assert.Throws<ArgumentException> (() => SetResolution (-1.0f, 1.0f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void SetResolution_Negative_Y ()
|
||||
{
|
||||
SetResolution (1.0f, -1.0f);
|
||||
Assert.Throws<ArgumentException> (() => SetResolution (1.0f, -1.0f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -1637,17 +1609,15 @@ namespace MonoTests.System.Drawing {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void SetResolution_NaN ()
|
||||
{
|
||||
SetResolution (Single.NaN, Single.NaN);
|
||||
Assert.Throws<ArgumentException> (() => SetResolution (Single.NaN, Single.NaN));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void SetResolution_NegativeInfinity ()
|
||||
{
|
||||
SetResolution (Single.NegativeInfinity, Single.NegativeInfinity);
|
||||
Assert.Throws<ArgumentException> (() => SetResolution (Single.NegativeInfinity, Single.NegativeInfinity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1710,13 +1680,12 @@ namespace MonoTests.System.Drawing {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
[Category ("NotWorking")] // libgdiplus has lost track of the original 1bpp state
|
||||
public void Hicon48 ()
|
||||
{
|
||||
using (Icon icon = new Icon (TestBitmap.getInFile ("bitmaps/48x48x1.ico"))) {
|
||||
// looks like 1bbp icons aren't welcome as bitmaps ;-)
|
||||
Bitmap.FromHicon (icon.Handle);
|
||||
Assert.Throws<ArgumentException> (() => Bitmap.FromHicon (icon.Handle));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user