-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathRotationTests.cs
76 lines (70 loc) · 2.27 KB
/
RotationTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System.Collections;
using System.Threading.Tasks;
using NUnit.Framework;
namespace Microsoft.Maui.Controls.Compatibility.Platform.iOS.UnitTests
{
[TestFixture]
public class RotationTests : PlatformTestFixture
{
static IEnumerable RotationXCases
{
get
{
foreach (var element in BasicViews)
{
element.RotationX = 33.0;
yield return CreateTestCase(element);
}
}
}
static IEnumerable RotationYCases
{
get
{
foreach (var element in BasicViews)
{
element.RotationY = 87.0;
yield return CreateTestCase(element);
}
}
}
static IEnumerable RotationCases
{
get
{
foreach (var element in BasicViews)
{
element.Rotation = 23.0;
yield return CreateTestCase(element);
}
}
}
[Test, Category("RotationX"), TestCaseSource(nameof(RotationXCases))]
[Description("VisualElement X rotation should match renderer X rotation")]
public async Task RotationXConsistent(View view)
{
var transform = await GetRendererProperty(view, r => r.NativeView.Layer.Transform, requiresLayout: true);
var actual = ParseCATransform3D(transform.ToString());
var expected = CalculateRotationMatrixForDegrees((float)view.RotationX, UITests.Axis.X);
Assert.That(actual, Is.EqualTo(expected));
}
[Test, Category("RotationY"), TestCaseSource(nameof(RotationYCases))]
[Description("VisualElement Y rotation should match renderer Y rotation")]
public async Task RotationYConsistent(View view)
{
var transform = await GetRendererProperty(view, r => r.NativeView.Layer.Transform, requiresLayout: true);
var actual = ParseCATransform3D(transform.ToString());
var expected = CalculateRotationMatrixForDegrees((float)view.RotationY, UITests.Axis.Y);
Assert.That(actual, Is.EqualTo(expected));
}
[Test, Category("Rotation"), TestCaseSource(nameof(RotationCases))]
[Description("VisualElement rotation should match renderer rotation")]
public async Task RotationConsistent(View view)
{
var transform = await GetRendererProperty(view, r => r.NativeView.Layer.Transform, requiresLayout: true);
var actual = ParseCATransform3D(transform.ToString());
var expected = CalculateRotationMatrixForDegrees((float)view.Rotation, UITests.Axis.Z);
Assert.That(actual, Is.EqualTo(expected));
}
}
}