TestImageCodecInfo.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // ImageCodecInfo class testing unit
  3. //
  4. // Author:
  5. //
  6. // Jordi Mas i Hernàndez ([email protected])
  7. //
  8. // (C) 2004 Ximian, Inc. http://www.ximian.com
  9. //
  10. //
  11. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  12. //
  13. // Permission is hereby granted, free of charge, to any person obtaining
  14. // a copy of this software and associated documentation files (the
  15. // "Software"), to deal in the Software without restriction, including
  16. // without limitation the rights to use, copy, modify, merge, publish,
  17. // distribute, sublicense, and/or sell copies of the Software, and to
  18. // permit persons to whom the Software is furnished to do so, subject to
  19. // the following conditions:
  20. //
  21. // The above copyright notice and this permission notice shall be
  22. // included in all copies or substantial portions of the Software.
  23. //
  24. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  28. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  29. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  30. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  31. //
  32. using System;
  33. using System.Drawing;
  34. using System.Drawing.Imaging;
  35. using NUnit.Framework;
  36. using System.IO;
  37. namespace MonoTests.System.Drawing
  38. {
  39. [TestFixture]
  40. public class TestImageCodecInfo
  41. {
  42. [TearDown]
  43. public void Clean() {}
  44. [SetUp]
  45. public void GetReady()
  46. {
  47. }
  48. internal void isPresent (ImageCodecInfo[] codecs, string clsid, string formatID)
  49. {
  50. for (int i = 0; i < codecs.Length; i++) {
  51. if (codecs[i].FormatID.ToString() == formatID) {
  52. Assert.AreEqual (codecs[i].Clsid.ToString(), clsid);
  53. return;
  54. }
  55. }
  56. Assert.IsTrue (false);
  57. }
  58. /*
  59. This test makes sure that we deliver at least the BMP, GIF, JPEG
  60. and PNG encoders
  61. */
  62. [Test]
  63. public void Encoders()
  64. {
  65. ImageCodecInfo[] decoders = ImageCodecInfo.GetImageDecoders();
  66. ImageCodecInfo[] encoders = ImageCodecInfo.GetImageEncoders();
  67. /* BMP */
  68. isPresent (encoders, "557cf400-1a04-11d3-9a73-0000f81ef32e",
  69. "b96b3cab-0728-11d3-9d7b-0000f81ef32e");
  70. /* GIF */
  71. isPresent (encoders, "557cf402-1a04-11d3-9a73-0000f81ef32e",
  72. "b96b3cb0-0728-11d3-9d7b-0000f81ef32e");
  73. /* JPEG */
  74. isPresent (encoders, "557cf401-1a04-11d3-9a73-0000f81ef32e",
  75. "b96b3cae-0728-11d3-9d7b-0000f81ef32e");
  76. /* PNG */
  77. isPresent (encoders, "557cf406-1a04-11d3-9a73-0000f81ef32e",
  78. "b96b3caf-0728-11d3-9d7b-0000f81ef32e");
  79. }
  80. /*
  81. This test makes sure that we deliver at least the BMP, GIF, JPEG
  82. and PNG decoders
  83. */
  84. [Test]
  85. public void Decoders()
  86. {
  87. ImageCodecInfo[] decoders = ImageCodecInfo.GetImageDecoders();
  88. /* BMP */
  89. isPresent (decoders, "557cf400-1a04-11d3-9a73-0000f81ef32e",
  90. "b96b3cab-0728-11d3-9d7b-0000f81ef32e");
  91. /* GIF */
  92. isPresent (decoders, "557cf402-1a04-11d3-9a73-0000f81ef32e",
  93. "b96b3cb0-0728-11d3-9d7b-0000f81ef32e");
  94. /* JPEG */
  95. isPresent (decoders, "557cf401-1a04-11d3-9a73-0000f81ef32e",
  96. "b96b3cae-0728-11d3-9d7b-0000f81ef32e");
  97. /* PNG */
  98. isPresent (decoders, "557cf406-1a04-11d3-9a73-0000f81ef32e",
  99. "b96b3caf-0728-11d3-9d7b-0000f81ef32e");
  100. }
  101. }
  102. }