Skip to content

Commit ef22fa8

Browse files
Added testcase
1 parent f69f8be commit ef22fa8

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@
6666
<MauiFont Include="Resources\Fonts\**" />
6767
<MauiFont Remove="Resources\Fonts\Dokdo-Regular.ttf" />
6868
<EmbeddedResource Include="Resources\Fonts\Dokdo-Regular.ttf" />
69+
<EmbeddedResource Include="Resources\Images\groceries.png" />
6970
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
7071
</ItemGroup>
7172

7273
<ItemGroup>
7374
<Compile Include="..\CustomAttributes\*.cs" />
75+
<MauiImage Remove="Resources\Images\groceries.png" />
7476
<Using Include="Microsoft.Maui.Controls.CustomAttributes" />
7577
</ItemGroup>
7678

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System.Reflection;
2+
using Microsoft.Maui.Graphics.Platform;
3+
using IImage = Microsoft.Maui.Graphics.IImage;
4+
5+
namespace Controls.TestCases.HostApp.Issues;
6+
7+
[Issue(IssueTracker.Github, 28725, "ImagePaint is not rendering in View", PlatformAffected.UWP)]
8+
public class Issue28725 : ContentPage
9+
{
10+
public Issue28725()
11+
{
12+
VerticalStackLayout _stackLayout = new VerticalStackLayout();
13+
GraphicsView _graphicsView = new GraphicsView
14+
{
15+
Drawable = new Issue28725_ImagePaint(),
16+
HeightRequest = 500,
17+
WidthRequest = 400
18+
};
19+
20+
Label _label = new Label
21+
{
22+
AutomationId = "Label",
23+
Text = "The image should be rendered properly, otherwise the test fails"
24+
};
25+
26+
_stackLayout.Children.Add(_graphicsView);
27+
_stackLayout.Children.Add(_label);
28+
Content = _stackLayout;
29+
}
30+
}
31+
32+
public class Issue28725_ImagePaint : IDrawable
33+
{
34+
public void Draw(ICanvas canvas, RectF dirtyRect)
35+
{
36+
IImage image;
37+
Assembly assembly = GetType().GetTypeInfo().Assembly;
38+
using (Stream stream = assembly.GetManifestResourceStream("Controls.TestCases.HostApp.Resources.Images.groceries.png"))
39+
{
40+
image = PlatformImage.FromStream(stream);
41+
}
42+
43+
if (image != null)
44+
{
45+
canvas.SetFillImage(image.Downsize(100));
46+
canvas.FillRectangle(0, 0, 240, 300);
47+
}
48+
}
49+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues;
6+
public class Issue28725 : _IssuesUITest
7+
{
8+
public Issue28725(TestDevice testDevice) : base(testDevice)
9+
{
10+
}
11+
12+
public override string Issue => "ImagePaint is not rendering in View";
13+
14+
[Test]
15+
[Category(UITestCategories.GraphicsView)]
16+
public void GraphicsViewImagePaint()
17+
{
18+
App.WaitForElement("Label");
19+
VerifyScreenshot();
20+
}
21+
}

0 commit comments

Comments
 (0)