forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix wrong conversions between Graphics RectF and Android RectF (dotne…
- Loading branch information
1 parent
e6644ae
commit 27ffdfd
Showing
4 changed files
with
156 additions
and
8 deletions.
There are no files selected for viewing
143 changes: 143 additions & 0 deletions
143
src/Core/tests/DeviceTests/Graphics/GraphicsTests.Android.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
using Xunit; | ||
|
||
namespace Microsoft.Maui.DeviceTests; | ||
|
||
[Category(TestCategory.Graphics)] | ||
public partial class GraphicsTests : TestBase | ||
{ | ||
[Theory] | ||
[InlineData(0, 0, 0, 0)] | ||
[InlineData(10, 10, 100, 100)] | ||
[InlineData(0, 0, 10, 100)] | ||
[InlineData(0, 0, 100, 10)] | ||
[InlineData(50, 100, 100, 50)] | ||
[InlineData(15, 15, 50, 50)] | ||
public void RectFImplicitConversionTest(float x, float y, float width, float height) | ||
{ | ||
var rectF = new Microsoft.Maui.Graphics.RectF(x, y, width, height); | ||
Android.Graphics.RectF aRectF = rectF; | ||
|
||
Assert.Equal(rectF.X, aRectF.Left); | ||
Assert.Equal(rectF.Y, aRectF.Top); | ||
Assert.Equal(rectF.Width, aRectF.Width()); | ||
Assert.Equal(rectF.Height, aRectF.Height()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0, 0, 0, 0)] | ||
[InlineData(10, 10, 100, 100)] | ||
[InlineData(0, 0, 10, 100)] | ||
[InlineData(0, 0, 100, 10)] | ||
[InlineData(50, 100, 100, 50)] | ||
[InlineData(15, 15, 50, 50)] | ||
public void RectFExplicitConversionTest(float x, float y, float width, float height) | ||
{ | ||
var rectF = new Microsoft.Maui.Graphics.RectF(x, y, width, height); | ||
var aRectF = (Android.Graphics.RectF)rectF; | ||
|
||
Assert.Equal(rectF.X, aRectF.Left); | ||
Assert.Equal(rectF.Y, aRectF.Top); | ||
Assert.Equal(rectF.Width, aRectF.Width()); | ||
Assert.Equal(rectF.Height, aRectF.Height()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0, 0, 0, 0)] | ||
[InlineData(10, 10, 100, 100)] | ||
[InlineData(0, 0, 10, 100)] | ||
[InlineData(0, 0, 100, 10)] | ||
[InlineData(50, 100, 100, 50)] | ||
[InlineData(15, 15, 50, 50)] | ||
public void RectImplicitConversionTest(double x, double y, double width, double height) | ||
{ | ||
var rect = new Microsoft.Maui.Graphics.Rect(x, y, width, height); | ||
Android.Graphics.Rect aRect = rect; | ||
|
||
Assert.Equal(rect.X, aRect.Left); | ||
Assert.Equal(rect.Y, aRect.Top); | ||
Assert.Equal(rect.Width, aRect.Width()); | ||
Assert.Equal(rect.Height, aRect.Height()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0, 0, 0, 0)] | ||
[InlineData(10, 10, 100, 100)] | ||
[InlineData(0, 0, 10, 100)] | ||
[InlineData(0, 0, 100, 10)] | ||
[InlineData(50, 100, 100, 50)] | ||
[InlineData(15, 15, 50, 50)] | ||
public void RectExplicitConversionTest(float x, float y, float width, float height) | ||
{ | ||
var rect = new Microsoft.Maui.Graphics.Rect(x, y, width, height); | ||
var aRect = (Android.Graphics.Rect)rect; | ||
|
||
Assert.Equal(rect.X, aRect.Left); | ||
Assert.Equal(rect.Y, aRect.Top); | ||
Assert.Equal(rect.Width, aRect.Width()); | ||
Assert.Equal(rect.Height, aRect.Height()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0, 0)] | ||
[InlineData(100, 100)] | ||
[InlineData(10, 100)] | ||
[InlineData(100, 10)] | ||
[InlineData(50, 100)] | ||
[InlineData(15, 15)] | ||
public void PointFImplicitConversionTest(float x, float y) | ||
{ | ||
var pointF = new Microsoft.Maui.Graphics.PointF(x, y); | ||
Android.Graphics.PointF aPointF = pointF; | ||
|
||
Assert.Equal(pointF.X, aPointF.X); | ||
Assert.Equal(pointF.Y, aPointF.Y); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0, 0)] | ||
[InlineData(100, 100)] | ||
[InlineData(10, 100)] | ||
[InlineData(100, 10)] | ||
[InlineData(50, 100)] | ||
[InlineData(15, 15)] | ||
public void PointFExplicitConversionTest(float x, float y) | ||
{ | ||
var pointF = new Microsoft.Maui.Graphics.PointF(x, y); | ||
var aPointF = (Android.Graphics.PointF)pointF; | ||
|
||
Assert.Equal(pointF.X, aPointF.X); | ||
Assert.Equal(pointF.Y, aPointF.Y); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0, 0)] | ||
[InlineData(100, 100)] | ||
[InlineData(10, 100)] | ||
[InlineData(100, 10)] | ||
[InlineData(50, 100)] | ||
[InlineData(15, 15)] | ||
public void PointImplicitConversionTest(float x, float y) | ||
{ | ||
var point = new Microsoft.Maui.Graphics.Point(x, y); | ||
Android.Graphics.Point aPoint = point; | ||
|
||
Assert.Equal(point.X, aPoint.X); | ||
Assert.Equal(point.Y, aPoint.Y); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0, 0)] | ||
[InlineData(100, 100)] | ||
[InlineData(10, 100)] | ||
[InlineData(100, 10)] | ||
[InlineData(50, 100)] | ||
[InlineData(15, 15)] | ||
public void PointExplicitConversionTest(float x, float y) | ||
{ | ||
var point = new Microsoft.Maui.Graphics.Point(x, y); | ||
var aPoint = (Android.Graphics.Point)point; | ||
|
||
Assert.Equal(point.X, aPoint.X); | ||
Assert.Equal(point.Y, aPoint.Y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Microsoft.Maui.DeviceTests; | ||
|
||
[Category(TestCategory.Graphics)] | ||
public partial class GraphicsTests : TestBase | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters