コード例 #1
0
        public IEnumerator TestVoiceInputOnPrefab()
        {
            TestButtonUtilities.InstantiateDefaultButton(
                TestButtonUtilities.DefaultButtonType.DefaultPushButton,
                out Interactable interactable,
                out Transform translateTargetObject);

            // Subscribe to interactable's on click so we know the click went through
            bool wasClicked = false;

            interactable.OnClick.AddListener(() => { wasClicked = true; });

            Vector3 targetStartPosition = translateTargetObject.localPosition;

            // Set up its voice command
            interactable.VoiceCommand       = "Select";
            interactable.VoiceRequiresFocus = false;

            // Find an input source to associate with the input event (doesn't matter which one)
            IMixedRealityInputSource defaultInputSource = CoreServices.InputSystem.DetectedInputSources.FirstOrDefault();

            Assert.NotNull(defaultInputSource, "At least one input source must be present for this test to work.");

            //
            // Test speech when disabled
            //

            interactable.IsEnabled = false;

            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            yield return(TestInputUtilities.ExecuteSpeechCommand(interactable.VoiceCommand, interactable.InputAction, defaultInputSource));

            yield return(TestButtonUtilities.CheckButtonTranslation(targetStartPosition, translateTargetObject, false));

            Assert.False(wasClicked, "Interactable was clicked.");
            Assert.False(interactable.IsVisited, "Interactable was visited.");

            //
            // Test speech when enabled
            //

            interactable.IsEnabled = true;

            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            yield return(TestInputUtilities.ExecuteSpeechCommand(interactable.VoiceCommand, interactable.InputAction, defaultInputSource));

            yield return(TestButtonUtilities.CheckButtonTranslation(targetStartPosition, translateTargetObject));

            Assert.True(wasClicked, "Interactable was not clicked.");
            Assert.True(interactable.IsVisited, "Interactable was not visited.");

            GameObject.Destroy(interactable.gameObject);
        }
コード例 #2
0
        private IEnumerator RunGlobalClick(IMixedRealityInputSource defaultInputSource,
                                           MixedRealityInputAction inputAction,
                                           Vector3 targetStartPosition,
                                           Transform translateTargetObject,
                                           bool shouldTranslate = true)
        {
            yield return(TestInputUtilities.ExecuteGlobalClick(defaultInputSource, inputAction, () =>
            {
                return TestButtonUtilities.CheckButtonTranslation(targetStartPosition, translateTargetObject, shouldTranslate);
            }));

            // Wait for at button release animation to finish
            yield return(new WaitForSeconds(TestButtonUtilities.ButtonReleaseAnimationDelay));
        }