Skip to content
Merged
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue29898.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.Collections.ObjectModel;

namespace Maui.Controls.Sample.Issues;
[Issue(IssueTracker.Github, 29898, "[iOS, macOS] StrokeDashArray on Border does not reset when set to null", PlatformAffected.iOS)]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[minor] UI Test Coverage - The issue metadata scopes this page to PlatformAffected.iOS, but this PR changes Windows and iOS/MacCatalyst code and adds Windows/Mac/Android snapshots. Update the attribute/description to match the intended coverage, e.g. PlatformAffected.All if this should run everywhere, or PlatformAffected.iOS | PlatformAffected.macOS | PlatformAffected.UWP if Android coverage is not intended.

public class Issue29898 : ContentPage
{
public Issue29898()
{
var border = new Border
{
HeightRequest = 200,
WidthRequest = 200,
BackgroundColor = Colors.LightGray,
Stroke = Colors.Blue,
StrokeThickness = 5,
StrokeDashArray = new DoubleCollection { 10, 5 }
};

var button = new Button
{
Text = "Clear StrokeDashArray",
AutomationId = "ClearDashButton",
HorizontalOptions = LayoutOptions.Center
};

var button2 = new Button
{
Text = "Set StrokeDashArray",
AutomationId = "SetDashButton",
HorizontalOptions = LayoutOptions.Center
};

button.Clicked += (s, e) =>
{
border.StrokeDashArray = null;
Comment thread
devanathan-vaithiyanathan marked this conversation as resolved.
};

button2.Clicked += (s, e) =>
{
border.StrokeDashArray = new DoubleCollection { 5, 2 };
};

var layout = new VerticalStackLayout
{
Spacing = 25,
Padding = new Thickness(30, 60, 30, 30),
VerticalOptions = LayoutOptions.Center,
Children = { border, button, button2 }
};

Content = layout;
}

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue29898 : _IssuesUITest
{
public override string Issue => "[iOS, macOS] StrokeDashArray on Border does not reset when set to null";

public Issue29898(TestDevice device)
: base(device)
{ }

[Test, Order(1)]
[Category(UITestCategories.Border)]
public void VerifyBorderWithNullStrokeDashArray()
{
App.WaitForElement("ClearDashButton");
App.Tap("ClearDashButton");
VerifyScreenshot();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[moderate] Regression Prevention and Test Coverage - This screenshot is taken immediately after tapping a button that changes StrokeDashArray. The platform update schedules redraw work (SetNeedsDisplay on iOS/macOS and WinUI render invalidation on Windows), so the screenshot can race the visual update; the failed gate's screenshot diffs are consistent with this kind of timing sensitivity. Please use VerifyScreenshot(retryTimeout: TimeSpan.FromSeconds(2)) here and in VerifyBorderWithStrokeDashArrayValue.

}

[Test, Order(2)]
[Category(UITestCategories.Border)]
public void VerifyBorderWithStrokeDashArrayValue()
{
App.WaitForElement("SetDashButton");
App.Tap("SetDashButton");
VerifyScreenshot();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pending snapshots. Running a build.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Snapshots available in the latest build.
image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz , I have added the pending snapshot.

}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/Core/src/Platform/Windows/BorderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public static void UpdateStrokeDashPattern(this Path borderPath, float[]? border
borderPath.StrokeDashArray.Add(value);
}
}
else if (borderDashArray is null || borderDashArray.Length == 0)
{
borderPath.StrokeDashArray = null;
}
}

public static void UpdateBorderDashOffset(this Path borderPath, double borderDashOffset)
Expand Down
3 changes: 0 additions & 3 deletions src/Core/src/Platform/Windows/StrokeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ public static void UpdateStrokeDashPattern(this ContentPanel platformView, IBord
{
var strokeDashPattern = border.StrokeDashPattern;

if (strokeDashPattern == null)
return;

platformView.BorderPath?.UpdateStrokeDashPattern(strokeDashPattern);
}

Expand Down
4 changes: 4 additions & 0 deletions src/Core/src/Platform/iOS/MauiCALayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ public void SetBorderDash(float[]? borderDashArray, double borderDashOffset)

_strokeDash = dashArray;
}
else if (borderDashArray is null || borderDashArray.Length == 0)
{
_strokeDash = null;
}

SetNeedsDisplay();
}
Expand Down
Loading