diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs index e087b12bb3fc..380112c44db0 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs @@ -1,15 +1,18 @@ using System; +using System.ComponentModel; using System.Threading.Tasks; +using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; +using Xunit; namespace Microsoft.Maui.DeviceTests { - public partial class BoxViewTests - { - MauiShapeView GetNativeBoxView(ShapeViewHandler boxViewViewHandler) => - boxViewViewHandler.PlatformView; + public partial class BoxViewTests + { + MauiShapeView GetNativeBoxView(ShapeViewHandler boxViewViewHandler) => + boxViewViewHandler.PlatformView; Task GetPlatformOpacity(ShapeViewHandler handler) { @@ -19,5 +22,79 @@ Task GetPlatformOpacity(ShapeViewHandler handler) return nativeView.Alpha; }); } - } + + [Fact] + [Description("The ScaleX property of a BoxView should match with native ScaleX")] + public async Task ScaleXConsistent() + { + var boxView = new BoxView() { ScaleX = 0.45f }; + var expected = boxView.ScaleX; + var handler = await CreateHandlerAsync(boxView); + var platformBoxView = GetNativeBoxView(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => platformBoxView.ScaleX); + Assert.Equal(expected, platformScaleX); + } + + [Fact] + [Description("The ScaleY property of a BoxView should match with native ScaleY")] + public async Task ScaleYConsistent() + { + var boxView = new BoxView() { ScaleY = 1.23f }; + var expected = boxView.ScaleY; + var handler = await CreateHandlerAsync(boxView); + var platformBoxView = GetNativeBoxView(handler); + var platformScaleY = await InvokeOnMainThreadAsync(() => platformBoxView.ScaleY); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The Scale property of a BoxView should match with native Scale")] + public async Task ScaleConsistent() + { + var boxView = new BoxView() { Scale = 2.0f }; + var expected = boxView.Scale; + var handler = await CreateHandlerAsync(boxView); + var platformBoxView = GetNativeBoxView(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => platformBoxView.ScaleX); + var platformScaleY = await InvokeOnMainThreadAsync(() => platformBoxView.ScaleY); + Assert.Equal(expected, platformScaleX); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The RotationX property of a BoxView should match with native RotationX")] + public async Task RotationXConsistent() + { + var boxView = new BoxView() { RotationX = 33.0 }; + var expected = boxView.RotationX; + var handler = await CreateHandlerAsync(boxView); + var platformBoxView = GetNativeBoxView(handler); + var platformRotationX = await InvokeOnMainThreadAsync(() => platformBoxView.RotationX); + Assert.Equal(expected, platformRotationX); + } + + [Fact] + [Description("The RotationY property of a BoxView should match with native RotationY")] + public async Task RotationYConsistent() + { + var boxView = new BoxView() { RotationY = 87.0 }; + var expected = boxView.RotationY; + var handler = await CreateHandlerAsync(boxView); + var platformBoxView = GetNativeBoxView(handler); + var platformRotationY = await InvokeOnMainThreadAsync(() => platformBoxView.RotationY); + Assert.Equal(expected, platformRotationY); + } + + [Fact] + [Description("The Rotation property of a BoxView should match with native Rotation")] + public async Task RotationConsistent() + { + var boxView = new BoxView() { Rotation = 23.0 }; + var expected = boxView.Rotation; + var handler = await CreateHandlerAsync(boxView); + var platformBoxView = GetNativeBoxView(handler); + var platformRotation = await InvokeOnMainThreadAsync(() => platformBoxView.Rotation); + Assert.Equal(expected, platformRotation); + } + } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.Android.cs index b8b71fead772..1f0745178aea 100644 --- a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.Android.cs @@ -107,5 +107,79 @@ await InvokeOnMainThreadAsync(async () => Assert.Equal(expectedValue, nativeOpacityValue); }); } + + [Fact] + [Description("The ScaleX property of a Button should match with native ScaleX")] + public async Task ScaleXConsistent() + { + var button = new Button() { ScaleX = 0.45f }; + var expected = button.ScaleX; + var handler = await CreateHandlerAsync(button); + var platformButton = GetPlatformButton(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => platformButton.ScaleX); + Assert.Equal(expected, platformScaleX); + } + + [Fact] + [Description("The ScaleY property of a Button should match with native ScaleY")] + public async Task ScaleYConsistent() + { + var button = new Button() { ScaleY = 1.23f }; + var expected = button.ScaleY; + var handler = await CreateHandlerAsync(button); + var platformButton = GetPlatformButton(handler); + var platformScaleY = await InvokeOnMainThreadAsync(() => platformButton.ScaleY); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The Scale property of a Button should match with native Scale")] + public async Task ScaleConsistent() + { + var button = new Button() { Scale = 2.0f }; + var expected = button.Scale; + var handler = await CreateHandlerAsync(button); + var platformButton = GetPlatformButton(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => platformButton.ScaleX); + var platformScaleY = await InvokeOnMainThreadAsync(() => platformButton.ScaleY); + Assert.Equal(expected, platformScaleX); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The RotationX property of a Button should match with native RotationX")] + public async Task RotationXConsistent() + { + var button = new Button() { RotationX = 33.0 }; + var expected = button.RotationX; + var handler = await CreateHandlerAsync(button); + var platformButton = GetPlatformButton(handler); + var platformRotationX = await InvokeOnMainThreadAsync(() => platformButton.RotationX); + Assert.Equal(expected, platformRotationX); + } + + [Fact] + [Description("The RotationY property of a Button should match with native RotationY")] + public async Task RotationYConsistent() + { + var button = new Button() { RotationY = 87.0 }; + var expected = button.RotationY; + var handler = await CreateHandlerAsync(button); + var platformButton = GetPlatformButton(handler); + var platformRotationY = await InvokeOnMainThreadAsync(() => platformButton.RotationY); + Assert.Equal(expected, platformRotationY); + } + + [Fact] + [Description("The Rotation property of a Button should match with native Rotation")] + public async Task RotationConsistent() + { + var button = new Button() { Rotation = 23.0 }; + var expected = button.Rotation; + var handler = await CreateHandlerAsync(button); + var platformButton = GetPlatformButton(handler); + var platformRotation = await InvokeOnMainThreadAsync(() => platformButton.Rotation); + Assert.Equal(expected, platformRotation); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs index dd8faaa342a8..35346b08777e 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; using System.Threading.Tasks; using AndroidX.AppCompat.Widget; using Microsoft.Maui.Controls; @@ -8,11 +9,11 @@ namespace Microsoft.Maui.DeviceTests { - [Collection(RunInNewWindowCollection)] - public partial class CheckBoxTests - { - AppCompatCheckBox GetNativeCheckBox(CheckBoxHandler checkBoxHandler) => - checkBoxHandler.PlatformView; + [Collection(RunInNewWindowCollection)] + public partial class CheckBoxTests + { + AppCompatCheckBox GetNativeCheckBox(CheckBoxHandler checkBoxHandler) => + checkBoxHandler.PlatformView; Task GetPlatformOpacity(CheckBoxHandler CheckBoxHandler) { @@ -22,5 +23,79 @@ Task GetPlatformOpacity(CheckBoxHandler CheckBoxHandler) return nativeView.Alpha; }); } - } + + [Fact] + [Description("The ScaleX property of a CheckBox should match with native ScaleX")] + public async Task ScaleXConsistent() + { + var checkBox = new CheckBox() { ScaleX = 0.45f }; + var expected = checkBox.ScaleX; + var handler = await CreateHandlerAsync(checkBox); + var PlatformCheckBox = GetNativeCheckBox(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => PlatformCheckBox.ScaleX); + Assert.Equal(expected, platformScaleX); + } + + [Fact] + [Description("The ScaleY property of a CheckBox should match with native ScaleY")] + public async Task ScaleYConsistent() + { + var checkBox = new CheckBox() { ScaleY = 1.23f }; + var expected = checkBox.ScaleY; + var handler = await CreateHandlerAsync(checkBox); + var PlatformCheckBox = GetNativeCheckBox(handler); + var platformScaleY = await InvokeOnMainThreadAsync(() => PlatformCheckBox.ScaleY); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The Scale property of a CheckBox should match with native Scale")] + public async Task ScaleConsistent() + { + var checkBox = new CheckBox() { Scale = 2.0f }; + var expected = checkBox.Scale; + var handler = await CreateHandlerAsync(checkBox); + var PlatformCheckBox = GetNativeCheckBox(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => PlatformCheckBox.ScaleX); + var platformScaleY = await InvokeOnMainThreadAsync(() => PlatformCheckBox.ScaleY); + Assert.Equal(expected, platformScaleX); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The RotationX property of a CheckBox should match with native RotationX")] + public async Task RotationXConsistent() + { + var checkBox = new CheckBox() { RotationX = 33.0 }; + var expected = checkBox.RotationX; + var handler = await CreateHandlerAsync(checkBox); + var PlatformCheckBox = GetNativeCheckBox(handler); + var platformRotationX = await InvokeOnMainThreadAsync(() => PlatformCheckBox.RotationX); + Assert.Equal(expected, platformRotationX); + } + + [Fact] + [Description("The RotationY property of a CheckBox should match with native RotationY")] + public async Task RotationYConsistent() + { + var checkBox = new CheckBox() { RotationY = 87.0 }; + var expected = checkBox.RotationY; + var handler = await CreateHandlerAsync(checkBox); + var PlatformCheckBox = GetNativeCheckBox(handler); + var platformRotationY = await InvokeOnMainThreadAsync(() => PlatformCheckBox.RotationY); + Assert.Equal(expected, platformRotationY); + } + + [Fact] + [Description("The Rotation property of a CheckBox should match with native Rotation")] + public async Task RotationConsistent() + { + var checkBox = new CheckBox() { Rotation = 23.0 }; + var expected = checkBox.Rotation; + var handler = await CreateHandlerAsync(checkBox); + var PlatformCheckBox = GetNativeCheckBox(handler); + var platformRotation = await InvokeOnMainThreadAsync(() => PlatformCheckBox.Rotation); + Assert.Equal(expected, platformRotation); + } + } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs index b4fe33fd2a21..375544dbd9b1 100644 --- a/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.ComponentModel; +using System.Threading.Tasks; using AndroidX.AppCompat.Widget; using Microsoft.Maui.Controls; using Microsoft.Maui.Handlers; @@ -66,5 +67,79 @@ public async Task CursorPositionPreservedWhenTextTransformPresent() Assert.Equal(2, editor.CursorPosition); } + + [Fact] + [Description("The ScaleX property of a Editor should match with native ScaleX")] + public async Task ScaleXConsistent() + { + var editor = new Editor() { ScaleX = 0.45f }; + var expected = editor.ScaleX; + var handler = await CreateHandlerAsync(editor); + var PlatformEditor = GetPlatformControl(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => PlatformEditor.ScaleX); + Assert.Equal(expected, platformScaleX); + } + + [Fact] + [Description("The ScaleY property of a Editor should match with native ScaleY")] + public async Task ScaleYConsistent() + { + var editor = new Editor() { ScaleY = 1.23f }; + var expected = editor.ScaleY; + var handler = await CreateHandlerAsync(editor); + var PlatformEditor = GetPlatformControl(handler); + var platformScaleY = await InvokeOnMainThreadAsync(() => PlatformEditor.ScaleY); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The Scale property of a Editor should match with native Scale")] + public async Task ScaleConsistent() + { + var editor = new Editor() { Scale = 2.0f }; + var expected = editor.Scale; + var handler = await CreateHandlerAsync(editor); + var PlatformEditor = GetPlatformControl(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => PlatformEditor.ScaleX); + var platformScaleY = await InvokeOnMainThreadAsync(() => PlatformEditor.ScaleY); + Assert.Equal(expected, platformScaleX); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The RotationX property of a Editor should match with native RotationX")] + public async Task RotationXConsistent() + { + var editor = new Editor() { RotationX = 33.0 }; + var expected = editor.RotationX; + var handler = await CreateHandlerAsync(editor); + var PlatformEditor = GetPlatformControl(handler); + var platformRotationX = await InvokeOnMainThreadAsync(() => PlatformEditor.RotationX); + Assert.Equal(expected, platformRotationX); + } + + [Fact] + [Description("The RotationY property of a Editor should match with native RotationY")] + public async Task RotationYConsistent() + { + var editor = new Editor() { RotationY = 87.0 }; + var expected = editor.RotationY; + var handler = await CreateHandlerAsync(editor); + var PlatformEditor = GetPlatformControl(handler); + var platformRotationY = await InvokeOnMainThreadAsync(() => PlatformEditor.RotationY); + Assert.Equal(expected, platformRotationY); + } + + [Fact] + [Description("The Rotation property of a Editor should match with native Rotation")] + public async Task RotationConsistent() + { + var editor = new Editor() { Rotation = 23.0 }; + var expected = editor.Rotation; + var handler = await CreateHandlerAsync(editor); + var PlatformEditor = GetPlatformControl(handler); + var platformRotation = await InvokeOnMainThreadAsync(() => PlatformEditor.Rotation); + Assert.Equal(expected, platformRotation); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.Android.cs index bac4eaa334fe..a1ba18cd926d 100644 --- a/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.Android.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.ComponentModel; +using System.Threading.Tasks; using AndroidX.AppCompat.Widget; using Microsoft.Maui.Controls; using Microsoft.Maui.Handlers; @@ -80,5 +81,79 @@ public async Task UpdateTextWithTextLongerThanMaxLength() Assert.Equal(longText[..4], entry.Text); } + + [Fact] + [Description("The ScaleX property of a Entry should match with native ScaleX")] + public async Task ScaleXConsistent() + { + var entry = new Entry() { ScaleX = 0.45f }; + var expected = entry.ScaleX; + var handler = await CreateHandlerAsync(entry); + var platformEntry = GetPlatformControl(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => platformEntry.ScaleX); + Assert.Equal(expected, platformScaleX); + } + + [Fact] + [Description("The ScaleY property of a Entry should match with native ScaleY")] + public async Task ScaleYConsistent() + { + var entry = new Entry() { ScaleY = 1.23f }; + var expected = entry.ScaleY; + var handler = await CreateHandlerAsync(entry); + var platformEntry = GetPlatformControl(handler); + var platformScaleY = await InvokeOnMainThreadAsync(() => platformEntry.ScaleY); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The Scale property of a Entry should match with native Scale")] + public async Task ScaleConsistent() + { + var entry = new Entry() { Scale = 2.0f }; + var expected = entry.Scale; + var handler = await CreateHandlerAsync(entry); + var platformEntry = GetPlatformControl(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => platformEntry.ScaleX); + var platformScaleY = await InvokeOnMainThreadAsync(() => platformEntry.ScaleY); + Assert.Equal(expected, platformScaleX); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The RotationX property of a Entry should match with native RotationX")] + public async Task RotationXConsistent() + { + var entry = new Entry() { RotationX = 33.0 }; + var expected = entry.RotationX; + var handler = await CreateHandlerAsync(entry); + var platformEntry = GetPlatformControl(handler); + var platformRotationX = await InvokeOnMainThreadAsync(() => platformEntry.RotationX); + Assert.Equal(expected, platformRotationX); + } + + [Fact] + [Description("The RotationY property of a Entry should match with native RotationY")] + public async Task RotationYConsistent() + { + var entry = new Entry() { RotationY = 87.0 }; + var expected = entry.RotationY; + var handler = await CreateHandlerAsync(entry); + var platformEntry = GetPlatformControl(handler); + var platformRotationY = await InvokeOnMainThreadAsync(() => platformEntry.RotationY); + Assert.Equal(expected, platformRotationY); + } + + [Fact] + [Description("The Rotation property of a Entry should match with native Rotation")] + public async Task RotationConsistent() + { + var editor = new Entry() { Rotation = 23.0 }; + var expected = editor.Rotation; + var handler = await CreateHandlerAsync(editor); + var platformEntry = GetPlatformControl(handler); + var platformRotation = await InvokeOnMainThreadAsync(() => platformEntry.Rotation); + Assert.Equal(expected, platformRotation); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/Image/ImageTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Image/ImageTests.Android.cs index 2a5f40c37ba2..9a40fd8cb9c0 100644 --- a/src/Controls/tests/DeviceTests/Elements/Image/ImageTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Image/ImageTests.Android.cs @@ -99,6 +99,74 @@ Task GetPlatformOpacity(ImageHandler imageHandler) return (float)nativeView.Alpha; }); } + + [Fact] + [Description("The ScaleX property of a Image should match with native ScaleX")] + public async Task ScaleXConsistent() + { + var image = new Image() { ScaleX = 0.45f }; + var expected = image.ScaleX; + var handler = await CreateHandlerAsync(image); + var platformScaleX = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleX); + Assert.Equal(expected, platformScaleX); + } + + [Fact] + [Description("The ScaleY property of a Image should match with native ScaleY")] + public async Task ScaleYConsistent() + { + var image = new Image() { ScaleY = 1.23f }; + var expected = image.ScaleY; + var handler = await CreateHandlerAsync(image); + var platformScaleY = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleY); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The Scale property of a Image should match with native Scale")] + public async Task ScaleConsistent() + { + var image = new Image() { Scale = 2.0f }; + var expected = image.Scale; + var handler = await CreateHandlerAsync(image); + var platformScaleX = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleX); + var platformScaleY = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleY); + Assert.Equal(expected, platformScaleX); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The RotationX property of a Image should match with native RotationX")] + public async Task RotationXConsistent() + { + var image = new Image() { RotationX = 33.0 }; + var expected = image.RotationX; + var handler = await CreateHandlerAsync(image); + var platformRotationX = await InvokeOnMainThreadAsync(() => handler.PlatformView.RotationX); + Assert.Equal(expected, platformRotationX); + } + + [Fact] + [Description("The RotationY property of a Image should match with native RotationY")] + public async Task RotationYConsistent() + { + var image = new Image() { RotationY = 87.0 }; + var expected = image.RotationY; + var handler = await CreateHandlerAsync(image); + var platformRotationY = await InvokeOnMainThreadAsync(() => handler.PlatformView.RotationY); + Assert.Equal(expected, platformRotationY); + } + + [Fact] + [Description("The Rotation property of a Image should match with native Rotation")] + public async Task RotationConsistent() + { + var image = new Image() { Rotation = 23.0 }; + var expected = image.Rotation; + var handler = await CreateHandlerAsync(image); + var platformRotation = await InvokeOnMainThreadAsync(() => handler.PlatformView.Rotation); + Assert.Equal(expected, platformRotation); + } } // This subclass of memory stream is deliberately set up to trick Glide into using the cached image diff --git a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs index d750c7e21143..ca3b626cbf79 100644 --- a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -88,6 +89,79 @@ await InvokeOnMainThreadAsync((System.Action)(() => })); } + [Fact] + [Description("The ScaleX property of a Label should match with native ScaleX")] + public async Task ScaleXConsistent() + { + var label = new Label() { ScaleX = 0.45f }; + var expected = label.ScaleX; + var handler = await CreateHandlerAsync(label); + var platformLabel = GetPlatformLabel(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => platformLabel.ScaleX); + Assert.Equal(expected, platformScaleX); + } + + [Fact] + [Description("The ScaleY property of a Label should match with native ScaleY")] + public async Task ScaleYConsistent() + { + var label = new Label() { ScaleY = 1.23f }; + var expected = label.ScaleY; + var handler = await CreateHandlerAsync(label); + var platformLabel = GetPlatformLabel(handler); + var platformScaleY = await InvokeOnMainThreadAsync(() => platformLabel.ScaleY); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The Scale property of a Label should match with native Scale")] + public async Task ScaleConsistent() + { + var label = new Label() { Scale = 2.0f }; + var expected = label.Scale; + var handler = await CreateHandlerAsync(label); + var platformLabel = GetPlatformLabel(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => platformLabel.ScaleX); + var platformScaleY = await InvokeOnMainThreadAsync(() => platformLabel.ScaleY); + Assert.Equal(expected, platformScaleX); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The RotationX property of a Label should match with native RotationX")] + public async Task RotationXConsistent() + { + var label = new Label() { RotationX = 33.0 }; + var expected = label.RotationX; + var handler = await CreateHandlerAsync(label); + var platformLabel = GetPlatformLabel(handler); + var platformRotationX = await InvokeOnMainThreadAsync(() => platformLabel.RotationX); + Assert.Equal(expected, platformRotationX); + } + + [Fact] + [Description("The RotationY property of a Label should match with native RotationY")] + public async Task RotationYConsistent() + { + var label = new Label() { RotationY = 87.0 }; + var expected = label.RotationY; + var handler = await CreateHandlerAsync(label); + var platformLabel = GetPlatformLabel(handler); + var platformRotationY = await InvokeOnMainThreadAsync(() => platformLabel.RotationY); + Assert.Equal(expected, platformRotationY); + } + + [Fact] + [Description("The Rotation property of a Label should match with native Rotation")] + public async Task RotationConsistent() + { + var label = new Label() { Rotation = 23.0 }; + var expected = label.Rotation; + var handler = await CreateHandlerAsync(label); + var platformLabel = GetPlatformLabel(handler); + var platformRotation = await InvokeOnMainThreadAsync(() => platformLabel.Rotation); + Assert.Equal(expected, platformRotation); + } TextView GetPlatformLabel(LabelHandler labelHandler) => labelHandler.PlatformView; diff --git a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.cs b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.cs index 1d8f7e9345e2..78d5e10146ca 100644 --- a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.cs @@ -755,7 +755,6 @@ await InvokeOnMainThreadAsync(async () => Assert.Equal(expectedValue, nativeOpacityValue); }); } - Color TextColor(LabelHandler handler) { #if __IOS__ @@ -780,7 +779,7 @@ static void AssertEquivalentFont(LabelHandler handler, Font font) Assert.Equal(targetFontSize, platformTypeface.PointSize); #elif __ANDROID__ var targetTypeface = fontManager.GetTypeface(font); - var targetFontSize = handler.MauiContext.Context.ToPixels(fontManager.GetFontSize(font).Value); + var targetFontSize = handler.MauiContext.Context.ToPixels(fontManager.GetFontSize(font).Value); var platformTypeface = handler.PlatformView.Typeface; var platformFontSize = handler.PlatformView.TextSize; diff --git a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.iOS.cs index 733be10164a3..88d51f72dca2 100644 --- a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.iOS.cs @@ -29,7 +29,7 @@ await InvokeOnMainThreadAsync((System.Action)(() => Assert.Equal(LineBreakMode.TailTruncation.ToPlatform(), GetPlatformLineBreakMode(handler)); })); } - + UILabel GetPlatformLabel(LabelHandler labelHandler) => (UILabel)labelHandler.PlatformView; diff --git a/src/Controls/tests/DeviceTests/Elements/Picker/PickerTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Picker/PickerTests.Android.cs index 7633630ad563..50ac8aa24fc7 100644 --- a/src/Controls/tests/DeviceTests/Elements/Picker/PickerTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Picker/PickerTests.Android.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Threading.Tasks; using Android.Widget; using Microsoft.Maui.Controls; @@ -10,7 +11,6 @@ namespace Microsoft.Maui.DeviceTests { - [Category(TestCategory.Picker)] public partial class PickerTests : ControlsHandlerTestBase { protected Task GetPlatformControlText(MauiPicker platformView) @@ -29,5 +29,73 @@ Task GetPlatformOpacity(PickerHandler pickerHandler) return (float)nativeView.Alpha; }); } + + [Fact] + [Description("The ScaleX property of a Picker should match with native ScaleX")] + public async Task ScaleXConsistent() + { + var picker = new Picker() { ScaleX = 0.45f }; + var expected = picker.ScaleX; + var handler = await CreateHandlerAsync(picker); + var platformScaleX = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleX); + Assert.Equal(expected, platformScaleX); + } + + [Fact] + [Description("The ScaleY property of a Picker should match with native ScaleY")] + public async Task ScaleYConsistent() + { + var picker = new Picker() { ScaleY = 1.23f }; + var expected = picker.ScaleY; + var handler = await CreateHandlerAsync(picker); + var platformScaleY = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleY); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The Scale property of a Picker should match with native Scale")] + public async Task ScaleConsistent() + { + var picker = new Picker() { Scale = 2.0f }; + var expected = picker.Scale; + var handler = await CreateHandlerAsync(picker); + var platformScaleX = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleX); + var platformScaleY = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleY); + Assert.Equal(expected, platformScaleX); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The RotationX property of a Picker should match with native RotationX")] + public async Task RotationXConsistent() + { + var picker = new Picker() { RotationX = 33.0 }; + var expected = picker.RotationX; + var handler = await CreateHandlerAsync(picker); + var platformRotationX = await InvokeOnMainThreadAsync(() => handler.PlatformView.RotationX); + Assert.Equal(expected, platformRotationX); + } + + [Fact] + [Description("The RotationY property of a Picker should match with native RotationY")] + public async Task RotationYConsistent() + { + var picker = new Picker() { RotationY = 87.0 }; + var expected = picker.RotationY; + var handler = await CreateHandlerAsync(picker); + var platformRotationY = await InvokeOnMainThreadAsync(() => handler.PlatformView.RotationY); + Assert.Equal(expected, platformRotationY); + } + + [Fact] + [Description("The Rotation property of a Picker should match with native Rotation")] + public async Task RotationConsistent() + { + var picker = new Picker() { Rotation = 23.0 }; + var expected = picker.Rotation; + var handler = await CreateHandlerAsync(picker); + var platformRotation = await InvokeOnMainThreadAsync(() => handler.PlatformView.Rotation); + Assert.Equal(expected, platformRotation); + } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs index 63fe3c327277..c290f9bd76f7 100644 --- a/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs @@ -1,8 +1,11 @@ -using System.Linq; +using System.ComponentModel; +using System.Linq; using System.Threading.Tasks; using Android.Widget; +using Microsoft.Maui.Controls; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; +using Xunit; using SearchView = AndroidX.AppCompat.Widget.SearchView; namespace Microsoft.Maui.DeviceTests @@ -39,5 +42,79 @@ Task GetPlatformOpacity(SearchBarHandler searchBarHandler) return nativeView.Alpha; }); } + + [Fact] + [Description("The ScaleX property of a SearchBar should match with native ScaleX")] + public async Task ScaleXConsistent() + { + var searchBar = new SearchBar() { ScaleX = 0.45f }; + var expected = searchBar.ScaleX; + var handler = await CreateHandlerAsync(searchBar); + var platformSearchBar = GetPlatformControl(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => platformSearchBar.ScaleX); + Assert.Equal(expected, platformScaleX); + } + + [Fact] + [Description("The ScaleY property of a SearchBar should match with native ScaleY")] + public async Task ScaleYConsistent() + { + var searchBar = new SearchBar() { ScaleY = 1.23f }; + var expected = searchBar.ScaleY; + var handler = await CreateHandlerAsync(searchBar); + var platformSearchBar = GetPlatformControl(handler); + var platformScaleY = await InvokeOnMainThreadAsync(() => platformSearchBar.ScaleY); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The Scale property of a SearchBar should match with native Scale")] + public async Task ScaleConsistent() + { + var searchBar = new SearchBar() { Scale = 2.0f }; + var expected = searchBar.Scale; + var handler = await CreateHandlerAsync(searchBar); + var platformSearchBar = GetPlatformControl(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => platformSearchBar.ScaleX); + var platformScaleY = await InvokeOnMainThreadAsync(() => platformSearchBar.ScaleY); + Assert.Equal(expected, platformScaleX); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The RotationX property of a SearchBar should match with native RotationX")] + public async Task RotationXConsistent() + { + var searchBar = new SearchBar() { RotationX = 33.0 }; + var expected = searchBar.RotationX; + var handler = await CreateHandlerAsync(searchBar); + var platformSearchBar = GetPlatformControl(handler); + var platformRotationX = await InvokeOnMainThreadAsync(() => platformSearchBar.RotationX); + Assert.Equal(expected, platformRotationX); + } + + [Fact] + [Description("The RotationY property of a SearchBar should match with native RotationY")] + public async Task RotationYConsistent() + { + var searchBar = new SearchBar() { RotationY = 87.0 }; + var expected = searchBar.RotationY; + var handler = await CreateHandlerAsync(searchBar); + var platformSearchBar = GetPlatformControl(handler); + var platformRotationY = await InvokeOnMainThreadAsync(() => platformSearchBar.RotationY); + Assert.Equal(expected, platformRotationY); + } + + [Fact] + [Description("The Rotation property of a SearchBar should match with native Rotation")] + public async Task RotationConsistent() + { + var searchBar = new SearchBar() { Rotation = 23.0 }; + var expected = searchBar.Rotation; + var handler = await CreateHandlerAsync(searchBar); + var platformSearchBar = GetPlatformControl(handler); + var platformRotation = await InvokeOnMainThreadAsync(() => platformSearchBar.Rotation); + Assert.Equal(expected, platformRotation); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs index de8afa21e8ec..f0a4a635bc78 100644 --- a/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.ComponentModel; +using System.Threading.Tasks; using Android.Views; using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; @@ -6,11 +7,9 @@ using Microsoft.Maui.Platform; using Xunit; using static Microsoft.Maui.DeviceTests.AssertHelpers; -using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { - [Category(TestCategory.SwipeView)] public partial class SwipeViewTests : ControlsHandlerTestBase { [Fact(DisplayName = "SwipeItem Size Initializes Correctly")] @@ -71,6 +70,79 @@ await AttachAndRun(swipeView, async (handler) => }); } + [Fact] + [Description("The ScaleX property of a SwipeView should match with native ScaleX")] + public async Task ScaleXConsistent() + { + var swipeView = new SwipeView() { ScaleX = 0.45f }; + var expected = swipeView.ScaleX; + var handler = await CreateHandlerAsync(swipeView); + var platformSwipeView = GetPlatformControl(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => platformSwipeView.ScaleX); + Assert.Equal(expected, platformScaleX); + } + + [Fact] + [Description("The ScaleY property of a SwipeView should match with native ScaleY")] + public async Task ScaleYConsistent() + { + var swipeView = new SwipeView() { ScaleY = 1.23f }; + var expected = swipeView.ScaleY; + var handler = await CreateHandlerAsync(swipeView); + var platformSwipeView = GetPlatformControl(handler); + var platformScaleY = await InvokeOnMainThreadAsync(() => platformSwipeView.ScaleY); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The Scale property of a SwipeView should match with native Scale")] + public async Task ScaleConsistent() + { + var swipeView = new SwipeView() { Scale = 2.0f }; + var expected = swipeView.Scale; + var handler = await CreateHandlerAsync(swipeView); + var platformSwipeView = GetPlatformControl(handler); + var platformScaleX = await InvokeOnMainThreadAsync(() => platformSwipeView.ScaleX); + var platformScaleY = await InvokeOnMainThreadAsync(() => platformSwipeView.ScaleY); + Assert.Equal(expected, platformScaleX); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The RotationX property of a SwipeView should match with native RotationX")] + public async Task RotationXConsistent() + { + var swipeView = new SwipeView() { RotationX = 33.0 }; + var expected = swipeView.RotationX; + var handler = await CreateHandlerAsync(swipeView); + var platformSwipeView = GetPlatformControl(handler); + var platformRotationX = await InvokeOnMainThreadAsync(() => platformSwipeView.RotationX); + Assert.Equal(expected, platformRotationX); + } + + [Fact] + [Description("The RotationY property of a SwipeView should match with native RotationY")] + public async Task RotationYConsistent() + { + var swipeView = new SwipeView() { RotationY = 87.0 }; + var expected = swipeView.RotationY; + var handler = await CreateHandlerAsync(swipeView); + var platformSwipeView = GetPlatformControl(handler); + var platformRotationY = await InvokeOnMainThreadAsync(() => platformSwipeView.RotationY); + Assert.Equal(expected, platformRotationY); + } + + [Fact] + [Description("The Rotation property of a SwipeView should match with native Rotation")] + public async Task RotationConsistent() + { + var swipeView = new SwipeView() { Rotation = 23.0 }; + var expected = swipeView.Rotation; + var handler = await CreateHandlerAsync(swipeView); + var platformSwipeView = GetPlatformControl(handler); + var platformRotation = await InvokeOnMainThreadAsync(() => platformSwipeView.Rotation); + Assert.Equal(expected, platformRotation); + } MauiSwipeView GetPlatformControl(SwipeViewHandler handler) => handler.PlatformView; diff --git a/src/Controls/tests/DeviceTests/Elements/TabbedPage/TabbedPageTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/TabbedPage/TabbedPageTests.Android.cs index 59512ce7d243..5261a76554b9 100644 --- a/src/Controls/tests/DeviceTests/Elements/TabbedPage/TabbedPageTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/TabbedPage/TabbedPageTests.Android.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -22,7 +23,6 @@ namespace Microsoft.Maui.DeviceTests { - [Category(TestCategory.TabbedPage)] public partial class TabbedPageTests : ControlsHandlerTestBase { [Fact(DisplayName = "Using SelectedTab Color doesnt crash")] @@ -142,6 +142,73 @@ await CreateHandlerAndAddToWindow(new Window(tabbedPage), asy }); } + [Fact] + [Description("The ScaleX property of a TabbedPage should match with native ScaleX")] + public async Task ScaleXConsistent() + { + var tabbedPage = new TabbedPage() { ScaleX = 0.45f }; + var expected = tabbedPage.ScaleX; + var handler = await CreateHandlerAsync(tabbedPage); + var platformScaleX = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleX); + Assert.Equal(expected, platformScaleX); + } + + [Fact] + [Description("The ScaleY property of a TabbedPage should match with native ScaleY")] + public async Task ScaleYConsistent() + { + var tabbedPage = new TabbedPage() { ScaleY = 1.23f }; + var expected = tabbedPage.ScaleY; + var handler = await CreateHandlerAsync(tabbedPage); + var platformScaleY = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleY); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The Scale property of a TabbedPage should match with native Scale")] + public async Task ScaleConsistent() + { + var tabbedPage = new TabbedPage() { Scale = 2.0f }; + var expected = tabbedPage.Scale; + var handler = await CreateHandlerAsync(tabbedPage); + var platformScaleX = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleX); + var platformScaleY = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleY); + Assert.Equal(expected, platformScaleX); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The RotationX property of a TabbedPage should match with native RotationX")] + public async Task RotationXConsistent() + { + var tabbedPage = new TabbedPage() { RotationX = 33.0 }; + var expected = tabbedPage.RotationX; + var handler = await CreateHandlerAsync(tabbedPage); + var platformRotationX = await InvokeOnMainThreadAsync(() => handler.PlatformView.RotationX); + Assert.Equal(expected, platformRotationX); + } + + [Fact] + [Description("The RotationY property of a TabbedPage should match with native RotationY")] + public async Task RotationYConsistent() + { + var tabbedPage = new TabbedPage() { RotationY = 87.0 }; + var expected = tabbedPage.RotationY; + var handler = await CreateHandlerAsync(tabbedPage); + var platformRotationY = await InvokeOnMainThreadAsync(() => handler.PlatformView.RotationY); + Assert.Equal(expected, platformRotationY); + } + + [Fact] + [Description("The Rotation property of a TabbedPage should match with native Rotation")] + public async Task RotationConsistent() + { + var tabbedPage = new TabbedPage() { Rotation = 23.0 }; + var expected = tabbedPage.Rotation; + var handler = await CreateHandlerAsync(tabbedPage); + var platformRotation = await InvokeOnMainThreadAsync(() => handler.PlatformView.Rotation); + Assert.Equal(expected, platformRotation); + } BottomNavigationView GetBottomNavigationView(IPlatformViewHandler tabViewHandler) { var layout = tabViewHandler.PlatformView.FindParent((view) => view is CoordinatorLayout) diff --git a/src/Controls/tests/DeviceTests/Elements/TemplatedView/TemplatedViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/TemplatedView/TemplatedViewTests.Android.cs index 5271b304853b..3633ae606278 100644 --- a/src/Controls/tests/DeviceTests/Elements/TemplatedView/TemplatedViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/TemplatedView/TemplatedViewTests.Android.cs @@ -1,15 +1,87 @@ -using Android.Views; +using System.ComponentModel; +using System.Threading.Tasks; +using Android.Views; +using Microsoft.Maui.Controls; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; +using Xunit; namespace Microsoft.Maui.DeviceTests { - public partial class TemplatedViewTests - { - static int GetChildCount(ContentViewHandler contentViewHandler) => - contentViewHandler.PlatformView.ChildCount; - - static View GetChild(ContentViewHandler contentViewHandler, int index = 0) => - contentViewHandler.PlatformView.GetChildAt(index); - } + public partial class TemplatedViewTests + { + static int GetChildCount(ContentViewHandler contentViewHandler) => + contentViewHandler.PlatformView.ChildCount; + + static Android.Views.View GetChild(ContentViewHandler contentViewHandler, int index = 0) => + contentViewHandler.PlatformView.GetChildAt(index); + + [Fact] + [Description("The ScaleX property of a TemplatedView should match with native ScaleX")] + public async Task ScaleXConsistent() + { + var templatedView = new TemplatedView() { ScaleX = 0.45f }; + var expected = templatedView.ScaleX; + var handler = await CreateHandlerAsync(templatedView); + var platformScaleX = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleX); + Assert.Equal(expected, platformScaleX); + } + + [Fact] + [Description("The ScaleY property of a TemplatedView should match with native ScaleY")] + public async Task ScaleYConsistent() + { + var templatedView = new TemplatedView() { ScaleY = 1.23f }; + var expected = templatedView.ScaleY; + var handler = await CreateHandlerAsync(templatedView); + var platformScaleY = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleY); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The Scale property of a TemplatedView should match with native Scale")] + public async Task ScaleConsistent() + { + var templatedView = new TemplatedView() { Scale = 2.0f }; + var expected = templatedView.Scale; + var handler = await CreateHandlerAsync(templatedView); + var platformScaleX = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleX); + var platformScaleY = await InvokeOnMainThreadAsync(() => handler.PlatformView.ScaleY); + Assert.Equal(expected, platformScaleX); + Assert.Equal(expected, platformScaleY); + } + + [Fact] + [Description("The RotationX property of a TemplatedView should match with native RotationX")] + public async Task RotationXConsistent() + { + var templatedView = new TemplatedView() { RotationX = 33.0 }; + var expected = templatedView.RotationX; + var handler = await CreateHandlerAsync(templatedView); + var platformRotationX = await InvokeOnMainThreadAsync(() => handler.PlatformView.RotationX); + Assert.Equal(expected, platformRotationX); + } + + [Fact] + [Description("The RotationY property of a TemplatedView should match with native RotationY")] + public async Task RotationYConsistent() + { + var templatedView = new TemplatedView() { RotationY = 87.0 }; + var expected = templatedView.RotationY; + var handler = await CreateHandlerAsync(templatedView); + var platformRotationY = await InvokeOnMainThreadAsync(() => handler.PlatformView.RotationY); + Assert.Equal(expected, platformRotationY); + } + + [Fact] + [Description("The Rotation property of a TemplatedView should match with native Rotation")] + public async Task RotationConsistent() + { + var templatedView = new TemplatedView() { Rotation = 23.0 }; + var expected = templatedView.Rotation; + var handler = await CreateHandlerAsync(templatedView); + var platformRotation = await InvokeOnMainThreadAsync(() => handler.PlatformView.Rotation); + Assert.Equal(expected, platformRotation); + } + } }