Ejemplo n.º 1
0
        public override void BeforeTest()
        {
            base.BeforeTest();

            cachedFeatureStates.Clear();
            var buildTargetGroups = Enum.GetValues(typeof(BuildTargetGroup));

            foreach (BuildTargetGroup buildTargetGroup in buildTargetGroups)
            {
                // Enum has duplicates in it so skip those.
                if (cachedFeatureStates.ContainsKey(buildTargetGroup))
                {
                    continue;
                }

                var cachedFeatureState = new Dictionary <string, bool>();

                var extInfo = FeatureHelpersInternal.GetAllFeatureInfo(buildTargetGroup);
                foreach (var ext in extInfo.Features)
                {
                    cachedFeatureState.Add(ext.Attribute.FeatureId, ext.Feature.enabled);
                    ext.Feature.enabled = false;
                }

                if (cachedFeatureState.Count > 0)
                {
                    cachedFeatureStates.Add(buildTargetGroup, cachedFeatureState);
                }
            }

            OpenXRFeatureSetManager.InitializeFeatureSets(true);
        }
Ejemplo n.º 2
0
        public void EnableFeatureSetEnablesFeatures()
        {
            OpenXRFeatureSetManager.InitializeFeatureSets(true);
            var extInfo = FeatureHelpersInternal.GetAllFeatureInfo(BuildTargetGroup.Standalone);

            foreach (var ext in extInfo.Features)
            {
                Assert.IsFalse(ext.Feature.enabled);
            }

            var foundFeatureSet = OpenXRFeatureSetManager.GetFeatureSetInfoWithId(BuildTargetGroup.Standalone, k_TestFeatureSetId);

            Assert.IsNotNull(foundFeatureSet);
            foundFeatureSet.isEnabled  = true;
            foundFeatureSet.wasChanged = true;
            OpenXRFeatureSetManager.SetFeaturesFromEnabledFeatureSets(BuildTargetGroup.Standalone);

            foreach (var ext in extInfo.Features)
            {
                if (String.Compare(ext.Attribute.FeatureId, MicrosoftHandInteraction.featureId, true) == 0)
                {
                    Assert.IsTrue(ext.Feature.enabled);
                }
                else
                {
                    Assert.IsFalse(ext.Feature.enabled);
                }
            }
        }
Ejemplo n.º 3
0
        public void CheckDefaultValues()
        {
            var extInfo     = FeatureHelpersInternal.GetAllFeatureInfo(BuildTargetGroup.Standalone);
            var mockExtInfo = extInfo.Features.SingleOrDefault(ext => ext.Attribute.UiName == "Mock Runtime");

            Assert.AreEqual(mockExtInfo.Attribute.UiName, mockExtInfo.Feature.nameUi);
            Assert.AreEqual(mockExtInfo.Attribute.Version, mockExtInfo.Feature.version);
            Assert.AreEqual(mockExtInfo.Attribute.OpenxrExtensionStrings, mockExtInfo.Feature.openxrExtensionStrings);
        }
Ejemplo n.º 4
0
        public void EnableFeatures()
        {
            var extInfo = FeatureHelpersInternal.GetAllFeatureInfo(BuildTargetGroup.Standalone);

            extInfo.Features.SingleOrDefault(ext => ext.Attribute.UiName == "Mock Runtime").Feature.enabled = true;
            Assert.IsTrue(MockRuntime.Instance.enabled);

            extInfo.Features.SingleOrDefault(ext => ext.Attribute.UiName == "Mock Runtime").Feature.enabled = false;
            Assert.IsFalse(MockRuntime.Instance.enabled);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Helper function to retrieve the cached FeatureInfos for a given build target group
        /// </summary>
        /// <param name="buildTargetGroup">Build target group</param>
        /// <returns>Array of FeatureInfos for the build target group</returns>
        public static FeatureHelpersInternal.FeatureInfo[] GetFeatureInfos(BuildTargetGroup buildTargetGroup)
        {
            if (null == s_FeatureInfos)
            {
                s_FeatureInfos = new Dictionary <BuildTargetGroup, FeatureHelpersInternal.FeatureInfo[]>();
            }

            if (!s_FeatureInfos.TryGetValue(buildTargetGroup, out var featureInfos))
            {
                featureInfos = FeatureHelpersInternal.GetAllFeatureInfo(buildTargetGroup).Features.ToArray();
                s_FeatureInfos[buildTargetGroup] = featureInfos;
            }

            return(featureInfos);
        }
        /// <summary>
        /// Initialize the feature sets by disabling all features sets and all features
        /// </summary>
        /// <param name="addTestFeatures">True to include test features</param>
        private void InitializeFeatureSets(bool addTestFeatures)
        {
            // Initialize first with test feature sets so we can make sure all feature sets are disabled
            OpenXRFeatureSetManager.InitializeFeatureSets(true);

            foreach (var buildTargetGroup in GetBuildTargetGroups())
            {
                // Disable all feature sets for this build target
                foreach (var featureSetInfo in FeatureSetInfosForBuildTarget(buildTargetGroup))
                {
                    featureSetInfo.isEnabled  = false;
                    featureSetInfo.wasEnabled = false;
                    OpenXREditorSettings.Instance.SetFeatureSetSelected(buildTargetGroup, featureSetInfo.featureSetId, false);
                }

                // Disable all features for this build target
                var extInfo = FeatureHelpersInternal.GetAllFeatureInfo(buildTargetGroup);
                foreach (var ext in extInfo.Features)
                {
                    ext.Feature.enabled = false;
                }
            }

            // If requested with no feature sets then reinitialize
            if (!addTestFeatures)
            {
                OpenXRFeatureSetManager.InitializeFeatureSets(false);
            }

            foreach (var buildTargetGroup in GetBuildTargetGroups())
            {
                // No feature sets should be enabled for any build target
                Assert.IsFalse(FeatureSetInfosForBuildTarget(buildTargetGroup).Any(f => f.isEnabled));

                // No features should be enabled
                AssertAllFeatures(buildTargetGroup, FeatureDisabled);
            }
        }
Ejemplo n.º 7
0
        public void DisableSharedFeaturesLeaveOthersFeaturesEnabled()
        {
            string[] allFeatureIds = new string[] {
                MicrosoftHandInteraction.featureId,
                EyeGazeInteraction.featureId,
                MicrosoftMotionControllerProfile.featureId,
            };

            string[] otherFeatureIds = new string[] {
                MicrosoftMotionControllerProfile.featureId,
            };

            OpenXRFeatureSetManager.InitializeFeatureSets(true);
            var extInfo = FeatureHelpersInternal.GetAllFeatureInfo(BuildTargetGroup.WSA);

            foreach (var ext in extInfo.Features)
            {
                Assert.IsFalse(ext.Feature.enabled);
                if (Array.IndexOf(otherFeatureIds, ext.Attribute.FeatureId) > -1)
                {
                    ext.Feature.enabled = true;
                }
            }

            var featureSetToEnable = OpenXRFeatureSetManager.GetFeatureSetInfoWithId(BuildTargetGroup.WSA, k_TestFeatureSetIdTwo);

            featureSetToEnable.isEnabled  = true;
            featureSetToEnable.wasChanged = true;
            OpenXRFeatureSetManager.SetFeaturesFromEnabledFeatureSets(BuildTargetGroup.WSA);

            foreach (var ext in extInfo.Features)
            {
                if (Array.IndexOf(allFeatureIds, ext.Attribute.FeatureId) >= 0)
                {
                    Assert.IsTrue(ext.Feature.enabled);
                }
                else
                {
                    Assert.IsFalse(ext.Feature.enabled);
                }
            }

            var featureSetToDisable = OpenXRFeatureSetManager.GetFeatureSetInfoWithId(BuildTargetGroup.WSA, k_TestFeatureSetIdTwo);

            Assert.IsNotNull(featureSetToDisable);
            featureSetToDisable.isEnabled  = false;
            featureSetToDisable.wasChanged = true;
            OpenXRFeatureSetManager.SetFeaturesFromEnabledFeatureSets(BuildTargetGroup.WSA);

            foreach (var ext in extInfo.Features)
            {
                if (Array.IndexOf(otherFeatureIds, ext.Attribute.FeatureId) >= 0)
                {
                    Assert.IsTrue(ext.Feature.enabled);
                }
                else
                {
                    Assert.IsFalse(ext.Feature.enabled);
                }
            }
        }