Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -10049,6 +10049,7 @@
<Content Include="$(MSBuildThisFileDirectory)Assets\rating_placeholder _hc.png" />
<Content Include="$(MSBuildThisFileDirectory)Assets\rating_placeholder.png" />
<Content Include="$(MSBuildThisFileDirectory)Assets\rating_set.png" />
<Content Include="$(MSBuildThisFileDirectory)Assets\image with space in path.png" />
<Content Include="$(MSBuildThisFileDirectory)Assets\rating_set_hc.png" />
<Content Include="$(MSBuildThisFileDirectory)Assets\rating_unset.png" />
<Content Include="$(MSBuildThisFileDirectory)Assets\rating_unset_hc.png" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,34 @@ public async Task When_Transitive_Asset_With_Link_Loaded()
Assert.IsTrue(img.ActualHeight > 0);
}

#if HAS_UNO
[TestMethod]
[RunsOnUIThread]
public async Task When_Path_Contains_Space()
{
var img = new Image { Source = "ms-appx:///Assets/image with space in path.png" };

var imageOpened = false;
var imageFailed = false;

img.ImageOpened += (sender, args) => imageOpened = true;
img.ImageFailed += (sender, args) => imageFailed = true;

await UITestHelper.Load(img);
await UITestHelper.WaitFor(() => imageOpened, 3000);
await UITestHelper.WaitForIdle();

Assert.IsTrue(img.ActualHeight > 0);
Assert.IsTrue(imageOpened);
Assert.IsFalse(imageFailed);
if (ApiInformation.IsTypePresent("Microsoft.UI.Xaml.Media.Imaging.RenderTargetBitmap, Uno.UI"))
{
var screenshot = await UITestHelper.ScreenShot(img);
ImageAssert.HasColorAt(screenshot, screenshot.Width / 2, screenshot.Height / 2, Microsoft.UI.Colors.Blue);
}
}
#endif

[TestMethod]
[RunsOnUIThread]
public async Task When_Explicit_BitmapImage_Relative_NonRooted()
Expand Down
5 changes: 3 additions & 2 deletions src/Uno.UWP/Helpers/PlatformImageHelpers.skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ internal static partial class PlatformImageHelpers

internal static Task<string> GetScaledPath(Uri uri, ResolutionScale? scaleOverride)
{
var path = uri.PathAndQuery;
// Unescaping is necessary for things like spaces that are valid in a file system path but not in a URI
var path = Uri.UnescapeDataString(uri.AbsolutePath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, no need for the query here? (PathAndQuery vs AbsolutePath)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is specifically for local paths, so the query should always be empty.

if (uri.Host is { Length: > 0 } host)
{
path = host + "/" + path.TrimStart('/');
Expand All @@ -32,7 +33,7 @@ internal static Task<string> GetScaledPath(Uri uri, ResolutionScale? scaleOverri
);

#pragma warning disable RS0030 // Do not use banned APIs // TODO MZ: Avoid this by using XamlRoot
var resolutionScale = (int)DisplayInformation.GetForCurrentView().ResolutionScale;
var resolutionScale = (int)(scaleOverride ?? DisplayInformation.GetForCurrentView().ResolutionScale);
#pragma warning restore RS0030 // Do not use banned APIs
var baseDirectory = Path.GetDirectoryName(originalLocalPath);
var baseFileName = Path.GetFileNameWithoutExtension(originalLocalPath);
Expand Down
Loading