Skip to content
Original file line number Diff line number Diff line change
@@ -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<float> GetPlatformOpacity(ShapeViewHandler handler)
{
Expand All @@ -19,5 +22,79 @@ Task<float> 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<ShapeViewHandler>(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<ShapeViewHandler>(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<ShapeViewHandler>(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<ShapeViewHandler>(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<ShapeViewHandler>(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<ShapeViewHandler>(boxView);
var platformBoxView = GetNativeBoxView(handler);
var platformRotation = await InvokeOnMainThreadAsync(() => platformBoxView.Rotation);
Assert.Equal(expected, platformRotation);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ButtonHandler>(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<ButtonHandler>(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<ButtonHandler>(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<ButtonHandler>(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<ButtonHandler>(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<ButtonHandler>(button);
var platformButton = GetPlatformButton(handler);
var platformRotation = await InvokeOnMainThreadAsync(() => platformButton.Rotation);
Assert.Equal(expected, platformRotation);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.Threading.Tasks;
using AndroidX.AppCompat.Widget;
using Microsoft.Maui.Controls;
Expand All @@ -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<float> GetPlatformOpacity(CheckBoxHandler CheckBoxHandler)
{
Expand All @@ -22,5 +23,79 @@ Task<float> 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<CheckBoxHandler>(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<CheckBoxHandler>(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<CheckBoxHandler>(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<CheckBoxHandler>(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<CheckBoxHandler>(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<CheckBoxHandler>(checkBox);
var PlatformCheckBox = GetNativeCheckBox(handler);
var platformRotation = await InvokeOnMainThreadAsync(() => PlatformCheckBox.Rotation);
Assert.Equal(expected, platformRotation);
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<EditorHandler>(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<EditorHandler>(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<EditorHandler>(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<EditorHandler>(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<EditorHandler>(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<EditorHandler>(editor);
var PlatformEditor = GetPlatformControl(handler);
var platformRotation = await InvokeOnMainThreadAsync(() => PlatformEditor.Rotation);
Assert.Equal(expected, platformRotation);
}
}
}
Loading
Loading