Skip to content

Commit

Permalink
fix: Adjust inertia unit tests to use microseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Jan 9, 2025
1 parent 82dece8 commit 598e7a9
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions src/Uno.UI.Tests/Windows_UI_Input/Given_GestureRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace Uno.UI.Tests.Windows_UI_Input
[TestClass]
public class Given_GestureRecognizer
{
private const int MicrosecondsPerMillisecond = 1000;

private const GestureSettings ManipulationsWithoutInertia = GestureSettings.ManipulationTranslateX
| GestureSettings.ManipulationTranslateY
| GestureSettings.ManipulationTranslateRailsX
Expand Down Expand Up @@ -1002,8 +1004,8 @@ public void Manipulation_Inertia_Translate()

// flick at 2 px/ms
sut.ProcessDownEvent(10, 10, ts: 0);
sut.ProcessMoveEvent(100, 100, ts: 100 * TimeSpan.TicksPerMillisecond);
sut.ProcessUpEvent(102, 102, ts: 101 * TimeSpan.TicksPerMillisecond);
sut.ProcessMoveEvent(100, 100, ts: 100 * MicrosecondsPerMillisecond);
sut.ProcessUpEvent(102, 102, ts: 101 * MicrosecondsPerMillisecond);

sut.RunInertiaSync();

Expand Down Expand Up @@ -1049,8 +1051,8 @@ public void Manipulation_Inertia_TranslateXOnly()

// flick at 2 px/ms
sut.ProcessDownEvent(10, 10, ts: 0);
sut.ProcessMoveEvent(100, 100, ts: 100 * TimeSpan.TicksPerMillisecond);
sut.ProcessUpEvent(102, 102, ts: 101 * TimeSpan.TicksPerMillisecond);
sut.ProcessMoveEvent(100, 100, ts: 100 * MicrosecondsPerMillisecond);
sut.ProcessUpEvent(102, 102, ts: 101 * MicrosecondsPerMillisecond);

sut.RunInertiaSync();

Expand Down Expand Up @@ -1096,8 +1098,8 @@ public void Manipulation_Inertia_TranslateYOnly()

// flick at 2 px/ms
sut.ProcessDownEvent(10, 10, ts: 0);
sut.ProcessMoveEvent(100, 100, ts: 100 * TimeSpan.TicksPerMillisecond);
sut.ProcessUpEvent(102, 102, ts: 101 * TimeSpan.TicksPerMillisecond);
sut.ProcessMoveEvent(100, 100, ts: 100 * MicrosecondsPerMillisecond);
sut.ProcessUpEvent(102, 102, ts: 101 * MicrosecondsPerMillisecond);

sut.RunInertiaSync();

Expand Down Expand Up @@ -1143,8 +1145,8 @@ public void Manipulation_Inertia_Translate_Negative()

// flick at 2 px/ms
sut.ProcessDownEvent(10, 10, ts: 0);
sut.ProcessMoveEvent(100, 100, ts: 100 * TimeSpan.TicksPerMillisecond);
sut.ProcessUpEvent(98, 98, ts: 101 * TimeSpan.TicksPerMillisecond);
sut.ProcessMoveEvent(100, 100, ts: 100 * MicrosecondsPerMillisecond);
sut.ProcessUpEvent(98, 98, ts: 101 * MicrosecondsPerMillisecond);

sut.RunInertiaSync();

Expand Down Expand Up @@ -1192,8 +1194,8 @@ public void Manipulation_Inertia_RotateOnly_Trigonometric_InFirstQuadrant()

// Rotate of pi/2 in a quarter of second
sut.ProcessDownEvent(50, -25, id: 2, ts: 1); // Angle = 0
sut.ProcessMoveEvent(50, -50, id: 2, ts: 100 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(25, -50, id: 2, ts: 600 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/2
sut.ProcessMoveEvent(50, -50, id: 2, ts: 100 * MicrosecondsPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(25, -50, id: 2, ts: 600 * MicrosecondsPerMillisecond); // Angle = -Pi/2

sut.RunInertiaSync();

Expand Down Expand Up @@ -1222,8 +1224,8 @@ public void Manipulation_Inertia_RotateOnly_Trigonometric_InSecondQuadrant()

// Rotate of Pi/4 in a quarter of second
sut.ProcessDownEvent(-25, -50, id: 2, ts: 1); // Angle = 0
sut.ProcessMoveEvent(-50, -50, id: 2, ts: 100 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(-50, -25, id: 2, ts: 600 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/2
sut.ProcessMoveEvent(-50, -50, id: 2, ts: 100 * MicrosecondsPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(-50, -25, id: 2, ts: 600 * MicrosecondsPerMillisecond); // Angle = -Pi/2

sut.RunInertiaSync();

Expand Down Expand Up @@ -1252,8 +1254,8 @@ public void Manipulation_Inertia_RotateOnly_Trigonometric_InThirdQuadrant()

// Rotate of pi/2 in a quarter of second
sut.ProcessDownEvent(-50, 25, id: 2, ts: 1); // Angle = 0
sut.ProcessMoveEvent(-50, 50, id: 2, ts: 100 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(-25, 50, id: 2, ts: 600 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/2
sut.ProcessMoveEvent(-50, 50, id: 2, ts: 100 * MicrosecondsPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(-25, 50, id: 2, ts: 600 * MicrosecondsPerMillisecond); // Angle = -Pi/2

sut.RunInertiaSync();

Expand Down Expand Up @@ -1282,8 +1284,8 @@ public void Manipulation_Inertia_RotateOnly_Trigonometric_InForthQuadrant()

// Rotate of pi/2 in a quarter of second
sut.ProcessDownEvent(25, 50, id: 2, ts: 1); // Angle = 0
sut.ProcessMoveEvent(50, 50, id: 2, ts: 100 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(50, 25, id: 2, ts: 600 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/2
sut.ProcessMoveEvent(50, 50, id: 2, ts: 100 * MicrosecondsPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(50, 25, id: 2, ts: 600 * MicrosecondsPerMillisecond); // Angle = -Pi/2

sut.RunInertiaSync();

Expand Down Expand Up @@ -1312,8 +1314,8 @@ public void Manipulation_Inertia_RotateOnly_AntiTrigonometric_InFirstQuadrant()
sut.ProcessDownEvent(25, -25, id: 1, ts: 0);

sut.ProcessDownEvent(25, -50, id: 2, ts: 1); // Angle = 0
sut.ProcessMoveEvent(50, -50, id: 2, ts: 100 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(50, -25, id: 2, ts: 600 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/2
sut.ProcessMoveEvent(50, -50, id: 2, ts: 100 * MicrosecondsPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(50, -25, id: 2, ts: 600 * MicrosecondsPerMillisecond); // Angle = -Pi/2

sut.RunInertiaSync();

Expand Down Expand Up @@ -1341,8 +1343,8 @@ public void Manipulation_Inertia_RotateOnly_AntiTrigonometric_InSecondQuadrant()
sut.ProcessDownEvent(-25, -25, id: 1, ts: 0);

sut.ProcessDownEvent(-50, -25, id: 2, ts: 1); // Angle = 0
sut.ProcessMoveEvent(-50, -50, id: 2, ts: 100 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(-25, -50, id: 2, ts: 600 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/2
sut.ProcessMoveEvent(-50, -50, id: 2, ts: 100 * MicrosecondsPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(-25, -50, id: 2, ts: 600 * MicrosecondsPerMillisecond); // Angle = -Pi/2

sut.RunInertiaSync();

Expand Down Expand Up @@ -1371,8 +1373,8 @@ public void Manipulation_Inertia_RotateOnly_AntiTrigonometric_InThirdQuadrant()
sut.ProcessDownEvent(-25, 25, id: 1, ts: 0);

sut.ProcessDownEvent(-25, 50, id: 2, ts: 1); // Angle = 0
sut.ProcessMoveEvent(-50, 50, id: 2, ts: 100 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(-50, 25, id: 2, ts: 600 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/2
sut.ProcessMoveEvent(-50, 50, id: 2, ts: 100 * MicrosecondsPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(-50, 25, id: 2, ts: 600 * MicrosecondsPerMillisecond); // Angle = -Pi/2

sut.RunInertiaSync();

Expand Down Expand Up @@ -1401,8 +1403,8 @@ public void Manipulation_Inertia_RotateOnly_AntiTrigonometric_InForthQuadrant()
sut.ProcessDownEvent(25, 25, id: 1, ts: 0);

sut.ProcessDownEvent(50, 25, id: 2, ts: 1); // Angle = 0
sut.ProcessMoveEvent(50, 50, id: 2, ts: 100 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(25, 50, id: 2, ts: 600 * TimeSpan.TicksPerMillisecond); // Angle = -Pi/2
sut.ProcessMoveEvent(50, 50, id: 2, ts: 100 * MicrosecondsPerMillisecond); // Angle = -Pi/4
sut.ProcessUpEvent(25, 50, id: 2, ts: 600 * MicrosecondsPerMillisecond); // Angle = -Pi/2

sut.RunInertiaSync();

Expand Down

0 comments on commit 598e7a9

Please sign in to comment.