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.
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.
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.
235 changes: 235 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue32731.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
using System.Collections.ObjectModel;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 32731, "Applying Shadow property affects the properties in Visual Transform Matrix", PlatformAffected.Android)]

public class Issue32731 : ContentPage
{
Border _border;
double _scale = 1;
double _scaleX = 1;
double _scaleY = 1;
double _translationX = 0;
double _translationY = 0;
double _rotation = 0;
double _rotationX = 0;
double _rotationY = 0;
double _anchorX = 0.5;
double _anchorY = 0.5;
bool _shadowApplied = false;

public Issue32731()
{
_border = new Border
{
BackgroundColor = Colors.Red,
HeightRequest = 120,
WidthRequest = 120,
HorizontalOptions = LayoutOptions.Center
};

var btnScale = CreateButton("Scale +", OnScaleClicked, "ScaleButton");
var btnScaleX = CreateButton("ScaleX", OnScaleXClicked, "ScaleXButton");
var btnScaleY = CreateButton("ScaleY", OnScaleYClicked, "ScaleYButton");
var btnTranslationX = CreateButton("TranslationX", OnTranslationXClicked, "TranslationXButton");
var btnTranslationY = CreateButton("TranslationY", OnTranslationYClicked, "TranslationYButton");
var btnRot = CreateButton("Rotation +", OnRotationClicked, "RotationButton");
var btnRotX = CreateButton("RotationX +", OnRotationXClicked, "RotationXButton");
var btnRotY = CreateButton("RotationY +", OnRotationYClicked, "RotationYButton");
var btnAnchorX = CreateButton("AnchorX +", OnAnchorXClicked, "AnchorXButton");
var btnAnchorY = CreateButton("AnchorY +", OnAnchorYClicked, "AnchorYButton");
var btnShadow = CreateButton("Toggle Shadow", OnToggleShadowClicked, "ToggleShadowButton");
var btnReset = CreateButton("Reset", OnResetClicked, "ResetButton");

var buttonsScrollView = new ScrollView
{
VerticalOptions = LayoutOptions.Center,
Content = new VerticalStackLayout
{
Padding = 20,
Spacing = 20,
Children =
{
new HorizontalStackLayout
{
Spacing = 10,
HorizontalOptions = LayoutOptions.Center,
Children = {btnScale,btnScaleX, btnScaleY }
},

new HorizontalStackLayout
{
Spacing = 10,
HorizontalOptions = LayoutOptions.Center,
Children = { btnTranslationX, btnTranslationY }
},

new HorizontalStackLayout
{
Spacing = 10,
HorizontalOptions = LayoutOptions.Center,
Children = {btnRot, btnRotX, btnRotY }
},

new HorizontalStackLayout
{
Spacing = 10,
HorizontalOptions = LayoutOptions.Center,
Children = { btnAnchorX, btnAnchorY }
},

new HorizontalStackLayout
{
Spacing = 10,
HorizontalOptions = LayoutOptions.Center,
Children = { btnShadow, btnReset }
}
}
}
};

var grid = new Grid
{
RowDefinitions =
{
new RowDefinition { Height = new GridLength(2, GridUnitType.Star) },
new RowDefinition { Height = GridLength.Auto }
}
};

Grid.SetRow(_border, 0);
Grid.SetRow(buttonsScrollView, 1);
grid.Children.Add(_border);
grid.Children.Add(buttonsScrollView);
Content = grid;
}

Button CreateButton(string text, EventHandler clicked, string automationId)
{
var button = new Button { Text = text, Padding = 10, AutomationId = automationId };
button.Clicked += clicked;
return button;
}

void OnScaleClicked(object sender, EventArgs e)
{
_scale += 0.5;
_border.Scale = _scale;
}

void OnScaleXClicked(object sender, EventArgs e)
{
_scaleX += 0.5;
_border.ScaleX = _scaleX;
}

void OnScaleYClicked(object sender, EventArgs e)
{
_scaleY += 0.5;
_border.ScaleY = _scaleY;
}

void OnTranslationXClicked(object sender, EventArgs e)
{
_translationX += 50;
_border.TranslationX = _translationX;
}

void OnTranslationYClicked(object sender, EventArgs e)
{
_translationY += 50;
_border.TranslationY = _translationY;
}

void OnRotationClicked(object sender, EventArgs e)
{
_rotation += 45;
if (_rotation >= 360)
_rotation = 0;
_border.Rotation = _rotation;
}

void OnRotationXClicked(object sender, EventArgs e)
{
_rotationX += 45;
if (_rotationX >= 360)
_rotationX = 0;
_border.RotationX = _rotationX;
}

void OnRotationYClicked(object sender, EventArgs e)
{
_rotationY += 45;
if (_rotationY >= 360)
_rotationY = 0;
_border.RotationY = _rotationY;
}

void OnAnchorXClicked(object sender, EventArgs e)
{
_anchorX += 0.25;
if (_anchorX > 1)
_anchorX = 0;
_border.AnchorX = _anchorX;
}

void OnAnchorYClicked(object sender, EventArgs e)
{
_anchorY += 0.25;
if (_anchorY > 1)
_anchorY = 0;
_border.AnchorY = _anchorY;
}

void OnToggleShadowClicked(object sender, EventArgs e)
{
if (_shadowApplied)
{
_border.Shadow = null;
_shadowApplied = false;
}
else
{
_border.Shadow = new Shadow
{
Brush = Brush.Black,
Opacity = 0.8f,
Offset = new Point(10, 10)
};
_shadowApplied = true;
}
}

void OnResetClicked(object sender, EventArgs e)
{
_scale = 1;
_scaleX = 1;
_scaleY = 1;
_translationX = 0;
_translationY = 0;
_rotation = 0;
_rotationX = 0;
_rotationY = 0;
_anchorX = 0.5;
_anchorY = 0.5;
_shadowApplied = false;

_border.Scale = _scale;
_border.ScaleX = _scaleX;
_border.ScaleY = _scaleY;
_border.TranslationX = _translationX;
_border.TranslationY = _translationY;
_border.Rotation = _rotation;
_border.RotationX = _rotationX;
_border.RotationY = _rotationY;
_border.AnchorX = _anchorX;
_border.AnchorY = _anchorY;
_border.Shadow = new Shadow
{
Brush = Brush.Transparent,
Opacity = 0f,
Offset = new Point(0, 0)
};
}
}
132 changes: 132 additions & 0 deletions src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32731.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#if TEST_FAILS_ON_IOS && TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST //More Info: https://github.com/dotnet/maui/issues/32731
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue32731 : _IssuesUITest
{
public Issue32731(TestDevice device) : base(device) { }

public override string Issue => "Applying Shadow property affects the properties in Visual Transform Matrix";

[Test, Order(1)]
[Category(UITestCategories.Border)]
public void VerifyScaleAndShadow()
{
App.WaitForElement("ScaleButton");
App.Tap("ScaleButton");
App.Tap("ToggleShadowButton");
VerifyScreenshot();
}

[Test, Order(2)]
[Category(UITestCategories.Border)]
public void VerifyScaleXAndShadow()
{
App.Tap("ResetButton");
App.WaitForElement("ScaleXButton");
App.Tap("ScaleXButton");
App.Tap("ToggleShadowButton");
VerifyScreenshot();
}

[Test, Order(3)]
[Category(UITestCategories.Border)]
public void VerifyScaleYAndShadow()
{
App.Tap("ResetButton");
App.WaitForElement("ScaleYButton");
App.Tap("ScaleYButton");
App.Tap("ToggleShadowButton");
VerifyScreenshot();
}

[Test, Order(4)]
[Category(UITestCategories.Border)]
public void VerifyTranslationXAndShadow()
{
App.Tap("ResetButton");
App.WaitForElement("TranslationXButton");
App.Tap("TranslationXButton");
App.Tap("ToggleShadowButton");
VerifyScreenshot();
}

[Test, Order(5)]
[Category(UITestCategories.Border)]
public void VerifyTranslationYAndShadow()
{
App.Tap("ResetButton");
App.WaitForElement("TranslationYButton");
App.Tap("TranslationYButton");
App.Tap("ToggleShadowButton");
VerifyScreenshot();
}

[Test, Order(6)]
[Category(UITestCategories.Border)]
public void VerifyRotationAndShadow()
{
App.Tap("ResetButton");
App.Tap("RotationButton");
App.Tap("ToggleShadowButton");
VerifyScreenshot();
}

[Test, Order(7)]
[Category(UITestCategories.Border)]
public void VerifyRotationXAndShadow()
{
App.Tap("ResetButton");
App.Tap("RotationXButton");
App.Tap("ToggleShadowButton");
VerifyScreenshot();
}

[Test, Order(8)]
[Category(UITestCategories.Border)]
public void VerifyRotationYAndShadow()
{
App.Tap("ResetButton");
App.Tap("RotationYButton");
App.Tap("ToggleShadowButton");
VerifyScreenshot();
}

[Test, Order(9)]
[Category(UITestCategories.Border)]
public void VerifyAnchorXAndShadow()
{
App.Tap("ResetButton");
App.Tap("AnchorXButton");
App.Tap("RotationButton");
App.Tap("ToggleShadowButton");
VerifyScreenshot();
}

[Test, Order(10)]
[Category(UITestCategories.Border)]
public void VerifyAnchorYAndShadow()
{
App.Tap("ResetButton");
App.Tap("AnchorYButton");
App.Tap("RotationButton");
App.Tap("ToggleShadowButton");
VerifyScreenshot();
}

[Test, Order(11)]
[Category(UITestCategories.Border)]
public void VerifyAnchorXAndAnchorYShadow()
{
App.Tap("ResetButton");
App.Tap("AnchorXButton");
App.Tap("AnchorYButton");
App.Tap("RotationButton");
App.Tap("ToggleShadowButton");
VerifyScreenshot();
}
}
#endif
2 changes: 2 additions & 0 deletions src/Core/src/Handlers/View/ViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ private protected sealed override object OnCreatePlatformElement() =>
static void MapInitializeBatchedProperties(IViewHandler handler, IView view)
{
if (handler.PlatformView is PlatformView pv)
{
pv.Initialize(view);
}
}
#endif

Expand Down
Loading
Loading