Skip to content

Commit

Permalink
Added test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast committed May 22, 2023
1 parent e1eb4f9 commit 83580c6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

<ItemGroup>
<MauiImage Include="Resources\Images\*" />
<MauiImage Remove="Resources\Images\red-embedded.png" />
<None Remove="Resources\Images\red-embedded.png" />
<EmbeddedResource Include="Resources\Images\red-embedded.png" LogicalName="red-embedded.png" />
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4" />
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" BaseSize="128,128" />
</ItemGroup>
Expand Down
24 changes: 24 additions & 0 deletions src/Controls/tests/DeviceTests/Elements/Image/ImageTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;
Expand Down Expand Up @@ -46,5 +47,28 @@ await InvokeOnMainThreadAsync(async () =>
await handler.ToPlatform().AssertContainsColor(Colors.Red, MauiContext);
});
}

[Fact]
public async Task ImageSetFromStreamRenders()
{
SetupBuilder();
var layout = new VerticalStackLayout();

using var stream = GetType().Assembly.GetManifestResourceStream("red-embedded.png");

var image = new Image
{
Source = ImageSource.FromStream(() => stream)
};

layout.Add(image);

await InvokeOnMainThreadAsync(async () =>
{
var handler = CreateHandler<LayoutHandler>(layout);
await image.Wait();
await handler.ToPlatform().AssertContainsColor(Colors.Red, MauiContext);
});
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 83580c6

Please sign in to comment.