From 923f2b3b80e0971233617954d2fa5ecaa5ea2b75 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Wed, 26 Jun 2024 11:12:55 +0200 Subject: [PATCH] Fix tests compilation without speech package (#593) (#792) --- .../Runtime/SeeItSayItLabelEnablerTests.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/org.mixedrealitytoolkit.uxcore/Tests/Runtime/SeeItSayItLabelEnablerTests.cs b/org.mixedrealitytoolkit.uxcore/Tests/Runtime/SeeItSayItLabelEnablerTests.cs index 4d9c576c5..c150b290c 100644 --- a/org.mixedrealitytoolkit.uxcore/Tests/Runtime/SeeItSayItLabelEnablerTests.cs +++ b/org.mixedrealitytoolkit.uxcore/Tests/Runtime/SeeItSayItLabelEnablerTests.cs @@ -26,19 +26,19 @@ public class SeeItSayItLabelEnablerTests : BaseRuntimeInputTests [UnityTest] public IEnumerator TestEnableAndSetLabel() { + GameObject testButton = SetUpButton(true, Control.None); + Transform label = testButton.transform.GetChild(0); + #if MRTK_INPUT_PRESENT && MRTK_SPEECH_PRESENT SpeechInteractor interactor = FindObjectUtility.FindAnyObjectByType(true); interactor.gameObject.SetActive(true); - GameObject testButton = SetUpButton(true, Control.None); yield return null; if (Application.isBatchMode) { LogAssert.Expect(LogType.Exception, new Regex("Speech recognition is not supported on this machine")); } - Transform label = testButton.transform.GetChild(0); - Transform sublabel = label.transform.GetChild(0); Assert.IsTrue(label.gameObject.activeSelf, "Label is enabled"); Assert.IsTrue(!sublabel.gameObject.activeSelf, "Child objects are disabled"); @@ -56,19 +56,19 @@ public IEnumerator TestEnableAndSetLabel() [UnityTest] public IEnumerator TestAutoUpdateLabel() { + GameObject testButton = SetUpButton(true, Control.None); + Transform label = testButton.transform.GetChild(0); + #if MRTK_INPUT_PRESENT && MRTK_SPEECH_PRESENT SpeechInteractor interactor = FindObjectUtility.FindAnyObjectByType(true); interactor.gameObject.SetActive(true); - GameObject testButton = SetUpButton(true, Control.None); yield return null; if (Application.isBatchMode) { LogAssert.Expect(LogType.Exception, new Regex("Speech recognition is not supported on this machine")); } - Transform label = testButton.transform.GetChild(0); - Transform sublabel = label.transform.GetChild(0); TMP_Text text = label.gameObject.GetComponentInChildren(true); Assert.AreEqual(text.text, "Say 'test'", "Label text was set to voice command keyword."); @@ -102,18 +102,19 @@ public IEnumerator TestVoiceCommandsUnavailable() [UnityTest] public IEnumerator TestPositionCanvasLabel() { + GameObject testButton = SetUpButton(true, Control.Canvas); + Transform label = testButton.transform.GetChild(0); + #if MRTK_INPUT_PRESENT && MRTK_SPEECH_PRESENT SpeechInteractor interactor = FindObjectUtility.FindAnyObjectByType(true); interactor.gameObject.SetActive(true); - GameObject testButton = SetUpButton(true, Control.Canvas); yield return null; if (Application.isBatchMode) { LogAssert.Expect(LogType.Exception, new Regex("Speech recognition is not supported on this machine")); } - Transform label = testButton.transform.GetChild(0); RectTransform sublabel = label.transform.GetChild(0) as RectTransform; Assert.AreEqual(sublabel.anchoredPosition3D, new Vector3(10, -30, -10), "Label is positioned correctly"); #else @@ -128,18 +129,19 @@ public IEnumerator TestPositionCanvasLabel() [UnityTest] public IEnumerator TestPositionNonCanvasLabel() { + GameObject testButton = SetUpButton(true, Control.NonCanvas); + Transform label = testButton.transform.GetChild(0); + #if MRTK_INPUT_PRESENT && MRTK_SPEECH_PRESENT SpeechInteractor interactor = FindObjectUtility.FindAnyObjectByType(true); interactor.gameObject.SetActive(true); - GameObject testButton = SetUpButton(true, Control.NonCanvas); yield return null; if (Application.isBatchMode) { LogAssert.Expect(LogType.Exception, new Regex("Speech recognition is not supported on this machine")); } - Transform label = testButton.transform.GetChild(0); Assert.AreEqual(label.transform.localPosition, new Vector3(10f, -.504f, -.004f), "Label is positioned correctly"); #else Assert.IsTrue(!label.gameObject.activeSelf, "Did not enable label because voice commands unavailable.");