Skip to content

Commit e5362a4

Browse files
ci: [NGOv2.X] Fixing WhenAnticipating_ValueChangesImmediately test (#3331)
This PR focuses on addressing disabled WhenAnticipating_ValueChangesImmediately on Android devices which is located in `com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransformAnticipationTests.cs` and tracked via MTT-11341 The error that is happening says `name: Unity.Netcode.RuntimeTests.NetworkTransformAnticipationTests.WhenAnticipating_ValueChangesImmediately result: FAILED message: Expected: (-0.28337, 0.21980, 0.06689, 0.93108) But was: (-0.28337, 0.21980, 0.06689, 0.93108) stackTrace: at Unity.Netcode.RuntimeTests.NetworkTransformAnticipationTests.WhenAnticipating_ValueChangesImmediately () [0x00000] in <00000000000000000000000000000000>:0 duration: 0.023017 seconds` Which seems to be an FP comparison problem (since the values seem to be correct). The approach is to use quaternion comparer with default error value of 0.000001 to mitigate this issue ([DOCS](https://docs.unity3d.com/Packages/[email protected]/manual/reference-comparer-quaternion.html))
1 parent 429b256 commit e5362a4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransformAnticipationTests.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using Unity.Netcode.Components;
66
using Unity.Netcode.TestHelpers.Runtime;
77
using UnityEngine;
8-
using UnityEngine.TestTools;
8+
using UnityEngine.TestTools.Utils;
99
using Object = UnityEngine.Object;
1010

1111
namespace Unity.Netcode.RuntimeTests
@@ -115,23 +115,22 @@ public AnticipatedNetworkTransform GetOtherClientComponent()
115115
}
116116

117117
[Test]
118-
[UnityPlatform(exclude = new[] { RuntimePlatform.Android })] // TODO: this ignored test is tracked in MTT-11341
119118
public void WhenAnticipating_ValueChangesImmediately()
120119
{
121120
var testComponent = GetTestComponent();
121+
var quaternionComparer = new QuaternionEqualityComparer(0.000001f);
122122

123123
testComponent.AnticipateMove(new Vector3(0, 1, 2));
124124
testComponent.AnticipateScale(new Vector3(1, 2, 3));
125125
testComponent.AnticipateRotate(Quaternion.LookRotation(new Vector3(2, 3, 4)));
126126

127127
Assert.AreEqual(new Vector3(0, 1, 2), testComponent.transform.position);
128128
Assert.AreEqual(new Vector3(1, 2, 3), testComponent.transform.localScale);
129-
Assert.AreEqual(Quaternion.LookRotation(new Vector3(2, 3, 4)), testComponent.transform.rotation);
129+
Assert.That(testComponent.transform.rotation, Is.EqualTo(Quaternion.LookRotation(new Vector3(2, 3, 4))).Using(quaternionComparer)); // Quaternion comparer added due to FP precision problems on Android devices.
130130

131131
Assert.AreEqual(new Vector3(0, 1, 2), testComponent.AnticipatedState.Position);
132132
Assert.AreEqual(new Vector3(1, 2, 3), testComponent.AnticipatedState.Scale);
133-
Assert.AreEqual(Quaternion.LookRotation(new Vector3(2, 3, 4)), testComponent.AnticipatedState.Rotation);
134-
133+
Assert.That(testComponent.AnticipatedState.Rotation, Is.EqualTo(Quaternion.LookRotation(new Vector3(2, 3, 4))).Using(quaternionComparer)); // Quaternion comparer added due to FP precision problems on Android devices.
135134
}
136135

137136
[Test]

0 commit comments

Comments
 (0)