<commit_before>// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.

using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Controls.Shapes;
using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Xunit;

#if AVALONIA_CAIRO
namespace Avalonia.Cairo.RenderTests.Media
#elif AVALONIA_SKIA
namespace Avalonia.Skia.RenderTests
#else
namespace Avalonia.Direct2D1.RenderTests.Media
#endif
{
    public class ImageBrushTests : TestBase
    {
        public ImageBrushTests()
            : base(@"Media\ImageBrush")
        {
        }

        private string BitmapPath
        {
            get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
        }

        private string SmallBitmapPath
        {
            get { return System.IO.Path.Combine(OutputPath, "github_icon_small.png"); }
        }

        [Fact]
        public void ImageBrush_Tile_Fill()
        {
            Decorator target = new Decorator
            {
                Width = 200,
                Height = 200,
                Child = new Rectangle
                {
                    Margin = new Thickness(8),
                    Fill = new ImageBrush
                    {
                        Stretch = Stretch.Fill,
                        TileMode = TileMode.Tile,
                        DestinationRect = new RelativeRect(0, 0, 25, 30, RelativeUnit.Absolute),
                        Source = new Bitmap(BitmapPath),
                    }
                }
            };

            RenderToFile(target);
            CompareImages();
        }

        [Fact]
        public void ImageBrush_Tile_UniformToFill()
        {
            Decorator target = new Decorator
            {
                Width = 200,
                Height = 200,
                Child = new Rectangle
                {
                    Margin = new Thickness(8),
                    Fill = new ImageBrush
                    {
                        Stretch = Stretch.Uniform,
                        TileMode = TileMode.Tile,
                        DestinationRect = new RelativeRect(0, 0, 25, 30, RelativeUnit.Absolute),
                        Source = new Bitmap(BitmapPath),
                    }
                }
            };

            RenderToFile(target);
            CompareImages();
        }

        [Fact]
        public void ImageBrush_Tile_Small_Image()
        {
            Decorator target = new Decorator
            {
                Width = 200,
                Height = 200,
                Child = new Rectangle
                {
                    Margin = new Thickness(8),
                    Fill = new ImageBrush
                    {
                        Stretch = Stretch.None,
                        TileMode = TileMode.Tile,
                        Source = new Bitmap(SmallBitmapPath),
                    }
                }
            };

            RenderToFile(target);
            CompareImages();
        }<commit_msg>Newly merged tests must be async.<commit_after>// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.

using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Controls.Shapes;
using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Xunit;

#if AVALONIA_CAIRO
namespace Avalonia.Cairo.RenderTests.Media
#elif AVALONIA_SKIA
namespace Avalonia.Skia.RenderTests
#else
namespace Avalonia.Direct2D1.RenderTests.Media
#endif
{
    public class ImageBrushTests : TestBase
    {
        public ImageBrushTests()
            : base(@"Media\ImageBrush")
        {
        }

        private string BitmapPath
        {
            get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
        }

        private string SmallBitmapPath
        {
            get { return System.IO.Path.Combine(OutputPath, "github_icon_small.png"); }
        }

        [Fact]
        public async Task ImageBrush_Tile_Fill()
        {
            Decorator target = new Decorator
            {
                Width = 200,
                Height = 200,
                Child = new Rectangle
                {
                    Margin = new Thickness(8),
                    Fill = new ImageBrush
                    {
                        Stretch = Stretch.Fill,
                        TileMode = TileMode.Tile,
                        DestinationRect = new RelativeRect(0, 0, 25, 30, RelativeUnit.Absolute),
                        Source = new Bitmap(BitmapPath),
                    }
                }
            };

            await RenderToFile(target);
            CompareImages();
        }

        [Fact]
        public async Task ImageBrush_Tile_UniformToFill()
        {
            Decorator target = new Decorator
            {
                Width = 200,
                Height = 200,
                Child = new Rectangle
                {
                    Margin = new Thickness(8),
                    Fill = new ImageBrush
                    {
                        Stretch = Stretch.Uniform,
                        TileMode = TileMode.Tile,
                        DestinationRect = new RelativeRect(0, 0, 25, 30, RelativeUnit.Absolute),
                        Source = new Bitmap(BitmapPath),
                    }
                }
            };

            await RenderToFile(target);
            CompareImages();
        }

        [Fact]
        public async Task ImageBrush_Tile_Small_Image()
        {
            Decorator target = new Decorator
            {
                Width = 200,
                Height = 200,
                Child = new Rectangle
                {
                    Margin = new Thickness(8),
                    Fill = new ImageBrush
                    {
                        Stretch = Stretch.None,
                        TileMode = TileMode.Tile,
                        Source = new Bitmap(SmallBitmapPath),
                    }
                }
            };

            await RenderToFile(target);
            CompareImages();
        }
{'fraction_non_alphanumeric': 0.07095025510204081, 'fraction_numerical': 0.011160714285714286, 'mean_word_length': 1.1803962460896766, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7053978', 'n_tokens_mistral': 1709, 'n_tokens_neox': 1487, 'n_words': 363}