Skip to content

Commit fd2bf70

Browse files
committed
Adding missing test coverage for FlattenAuto
1 parent c2e8c78 commit fd2bf70

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Assets/MRTK/Tests/PlayModeTests/BoundsControlTests.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,6 +2034,45 @@ public IEnumerator PerAxisHandleFlattenTest([ValueSource("perAxisHandleTestData"
20342034
yield return null;
20352035
}
20362036

2037+
/// <summary>
2038+
/// Test for verifying that per axis handles are properly switched off/on when
2039+
/// FlattenAuto mode is used.
2040+
/// </summary>
2041+
[UnityTest]
2042+
public IEnumerator FlattenAutoTest([ValueSource("perAxisHandleTestData")] PerAxisHandleTestData testData)
2043+
{
2044+
// test flatten mode of per axis handle
2045+
var boundsControl = InstantiateSceneAndDefaultBoundsControl();
2046+
yield return VerifyInitialBoundsCorrect(boundsControl);
2047+
boundsControl.TranslationHandlesConfig.ShowHandleForX = true; // make sure translation handle test handle is enabled for per axis tests
2048+
2049+
// Make cube very flat on X axis.
2050+
boundsControl.transform.localScale = new Vector3(0.01f, 1f, 1f);
2051+
boundsControl.HideElementsInInspector = false;
2052+
2053+
// cache rig root for verifying that we're not recreating the rig on config changes
2054+
GameObject rigRoot = boundsControl.transform.Find("rigRoot").gameObject;
2055+
Assert.IsNotNull(rigRoot, "rigRoot couldn't be found");
2056+
2057+
// get handle and make sure it's active per default
2058+
Transform handle = rigRoot.transform.Find(testData.handleName + "_0");
2059+
Assert.IsNotNull(handle, "couldn't find handle");
2060+
Assert.IsTrue(handle.gameObject.activeSelf, "handle wasn't enabled by default");
2061+
2062+
// Set FlattenModeType to FlattenAuto
2063+
boundsControl.FlattenAxis = FlattenModeType.FlattenAuto;
2064+
2065+
Assert.IsFalse(handle.gameObject.activeSelf, "handle wasn't disabled when FlattenAuto was used");
2066+
Assert.IsNotNull(rigRoot, "rigRoot got destroyed while configuring bounds control during runtime");
2067+
2068+
// unflatten the control again and make sure handle gets activated accordingly
2069+
boundsControl.FlattenAxis = FlattenModeType.DoNotFlatten;
2070+
Assert.IsTrue(handle.gameObject.activeSelf, "handle wasn't enabled on unflatten");
2071+
Assert.IsNotNull(rigRoot, "rigRoot got destroyed while configuring bounds control during runtime");
2072+
2073+
yield return null;
2074+
}
2075+
20372076
/// <summary>
20382077
/// Test for verifying changing the per axis handle prefabs during runtime
20392078
/// and making sure the entire rig won't be recreated

0 commit comments

Comments
 (0)