ImageTests.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // -----------------------------------------------------------------------
  2. // <copyright file="ImageTests.cs" company="Steven Kirk">
  3. // Copyright 2014 MIT Licence. See licence.md for more information.
  4. // </copyright>
  5. // -----------------------------------------------------------------------
  6. namespace Perspex.Direct2D1.RenderTests.Controls
  7. {
  8. using System.IO;
  9. using Perspex.Controls;
  10. using Perspex.Media;
  11. using Perspex.Media.Imaging;
  12. using Xunit;
  13. public class ImageTests : TestBase
  14. {
  15. private Bitmap bitmap;
  16. public ImageTests()
  17. : base(@"Controls\Image")
  18. {
  19. this.bitmap = new Bitmap(Path.Combine(this.OutputPath, "test.png"));
  20. }
  21. [Fact]
  22. public void Image_Stretch_None()
  23. {
  24. Decorator target = new Decorator
  25. {
  26. Padding = new Thickness(20, 8),
  27. Width = 200,
  28. Height = 200,
  29. Child = new Border
  30. {
  31. Background = Brushes.Red,
  32. Child = new Image
  33. {
  34. Source = this.bitmap,
  35. Stretch = Stretch.None,
  36. }
  37. }
  38. };
  39. this.RenderToFile(target);
  40. this.CompareImages();
  41. }
  42. [Fact]
  43. public void Image_Stretch_Fill()
  44. {
  45. Decorator target = new Decorator
  46. {
  47. Padding = new Thickness(20, 8),
  48. Width = 200,
  49. Height = 200,
  50. Child = new Border
  51. {
  52. Background = Brushes.Red,
  53. Child = new Image
  54. {
  55. Source = this.bitmap,
  56. Stretch = Stretch.Fill,
  57. }
  58. }
  59. };
  60. this.RenderToFile(target);
  61. this.CompareImages();
  62. }
  63. [Fact]
  64. public void Image_Stretch_Uniform()
  65. {
  66. Decorator target = new Decorator
  67. {
  68. Padding = new Thickness(20, 8),
  69. Width = 200,
  70. Height = 200,
  71. Child = new Border
  72. {
  73. Background = Brushes.Red,
  74. Child = new Image
  75. {
  76. Source = this.bitmap,
  77. Stretch = Stretch.Uniform,
  78. }
  79. }
  80. };
  81. this.RenderToFile(target);
  82. this.CompareImages();
  83. }
  84. [Fact]
  85. public void Image_Stretch_UniformToFill()
  86. {
  87. Decorator target = new Decorator
  88. {
  89. Padding = new Thickness(20, 8),
  90. Width = 200,
  91. Height = 200,
  92. Child = new Border
  93. {
  94. Background = Brushes.Red,
  95. Child = new Image
  96. {
  97. Source = this.bitmap,
  98. Stretch = Stretch.UniformToFill,
  99. }
  100. }
  101. };
  102. this.RenderToFile(target);
  103. this.CompareImages();
  104. }
  105. }
  106. }