public void TestInstanceCreate(bool result, bool required)
        {
            Loader.DisableValidationChecksOnEnteringPlaymode = true;
            bool instanceCreated      = false;
            bool hookInstanceProcAddr = false;
            bool other = false;

            MockRuntime.Instance.TestCallback = (methodName, param) =>
            {
                switch (methodName)
                {
                case nameof(OpenXRFeature.OnInstanceCreate):
                    instanceCreated = true;
                    return(result);

                case nameof(OpenXRFeature.HookGetInstanceProcAddr):
                    hookInstanceProcAddr = true;
                    break;

                default:
                    other = true;
                    break;
                }

                return(true);
            };

            MockRuntime.Instance.required = required;
            base.InitializeAndStart();

            Assert.IsTrue(instanceCreated);
            Assert.IsTrue(hookInstanceProcAddr);

            if (required && !result)
            {
                Assert.IsNull(OpenXRLoaderBase.Instance);
            }
            else
            {
                Assert.IsNotNull(OpenXRLoaderBase.Instance);
            }

            // A feature that fails that is not required should be disabled
            if (!result && !required)
            {
                Assert.IsFalse(MockRuntime.Instance.enabled);
            }

            base.StopAndShutdown();

            if (result)
            {
                Assert.IsTrue(other);
            }
            else
            {
                // A feature that fails initialize should have no further callbacks
                Assert.IsFalse(other);
            }
        }
Beispiel #2
0
        protected override void ContextClickedItem(int id)
        {
            ConformObjectTreeViewItem item = FindItem(id, rootItem) as ConformObjectTreeViewItem;

            Assert.IsNotNull(item);
            if (item.conforms)
            {
                return;
            }

            // TODO ask the ConformObject to do this
            PropertyConformObject propertyConformObject = item.conformObject as PropertyConformObject;

            if (propertyConformObject != null)
            {
                GenericMenu menu = new GenericMenu();
                if (propertyConformObject.TemplateType == SerializedPropertyType.Generic)
                {
                    menu.AddItem(new GUIContent("Set children to Template Values"), false, FixCallback, item);
                }
                else if (propertyConformObject.TemplateType == SerializedPropertyType.ArraySize)
                {
                    menu.AddDisabledItem(new GUIContent("Cannot set array size"));
                }
                else
                {
                    menu.AddItem(new GUIContent("Set to " + propertyConformObject.TemplateValue), false, FixCallback, item);
                }

                menu.ShowAsContext();
            }
        }
        public void DisableSharedFeaturesLeaveOthersFeaturesEnabled()
        {
            string[] allFeatureIds = new string[] {
                MicrosoftHandInteraction.featureId,
                EyeGazeInteraction.featureId,
                MicrosoftMotionControllerProfile.featureId,
            };

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

            EnableFeatureInfos(BuildTargetGroup.WSA, otherFeatureIds, true);

            // Enable the second feature set and ensure that only features in the `all` list are enabled
            var featureSetToEnable = GetFeatureSetInfoWithId(BuildTargetGroup.WSA, k_TestFeatureSetIdTwo);

            EnableFeatureSet(BuildTargetGroup.WSA, featureSetToEnable.featureSetId, true);
            AssertOnlyFeatures(BuildTargetGroup.WSA, allFeatureIds, FeatureEnabled);

            // Disable the second feature set and ensure only features in the `others` list are enabled
            var featureSetToDisable = GetFeatureSetInfoWithId(BuildTargetGroup.WSA, k_TestFeatureSetIdTwo);

            Assert.IsNotNull(featureSetToDisable);
            EnableFeatureSet(BuildTargetGroup.WSA, featureSetToDisable.featureSetId, enabled: false);
            AssertOnlyFeatures(BuildTargetGroup.WSA, otherFeatureIds, FeatureEnabled);
        }
Beispiel #4
0
        public void ScopeWithChildrenExists()
        {
            var scopeWithChildren = m_usdRoot.transform.Find("TestComponent/ScopeTest");

            Assert.IsNotNull(scopeWithChildren);
            Assert.AreNotEqual(0, scopeWithChildren.childCount);
        }
        public static void TestMyParentPrivateComponentsArray(GameObject obj, bool inactive = false)
        {
            Assert.IsTrue(obj != null);
            var test = obj.GetComponent <ProcessorTestComponent>();

            Assert.IsTrue(test != null);
            var list            = test.GetComponentsInParent <Renderer>(inactive);
            SerializedObject so = new SerializedObject(test);

            Assert.IsNotNull(so);
            var propArray = inactive ? so.FindProperty("parentPrivateComponentsArrayInactive") : so.FindProperty("parentPrivateComponentsArray");

            Assert.IsNotNull(propArray);
            var propList = inactive ? so.FindProperty("parentPrivateComponentsListInactive") : so.FindProperty("parentPrivateComponentsList");

            Assert.IsNotNull(propList);

            if (list == null)
            {
                Assert.IsNull(propArray.objectReferenceValue);
                Assert.IsNull(propList.objectReferenceValue);
            }
            else
            {
                Assert.IsTrue(propArray.arraySize == list.Length);
                Assert.IsTrue(propList.arraySize == list.Length);
                for (var index = 0; index < list.Length; index++)
                {
                    Assert.AreEqual(list[index], propArray.GetArrayElementAtIndex(index).objectReferenceValue);
                    Assert.AreEqual(list[index], propArray.GetArrayElementAtIndex(index).objectReferenceValue);
                }
            }
        }
Beispiel #6
0
        public IEnumerator ScrappingTest()
        {
            SceneManager.LoadScene("ProductionAndScrappingTest");
            yield return(null);


            var helper          = Object.FindObjectOfType <ProductionTestHelper>();
            var resourceManager = Object.FindObjectOfType <ResourceManager>();

            Assert.IsNotNull(helper);
            Assert.IsNotNull(resourceManager);

            var units     = Object.FindObjectsOfType <Unit>();
            int slotIndex = 0;

            foreach (var unit in units)
            {
                unit.transform.position = helper.Scrapyard.GetComponent <Node>().UnitSlots[slotIndex].transform.position;
                ++slotIndex;
            }

            yield return(new WaitForSeconds(0.1f));

            foreach (var unit in units)
            {
                helper.Scrapyard.ScrapUnit(unit);
            }

            yield return(null);

            Assert.IsTrue(resourceManager.ResourcesRemaining == resourceManager.MaxResources);
        }
Beispiel #7
0
        public IEnumerator ProductionTest()
        {
            SceneManager.LoadScene("ProductionAndScrappingTest");
            yield return(null);

            var helper          = Object.FindObjectOfType <ProductionTestHelper>();
            var resourceManager = Object.FindObjectOfType <ResourceManager>();

            Assert.IsNotNull(helper);
            Assert.IsNotNull(resourceManager);

            var factory   = helper.FactoryToFillOut;
            int slotCount = factory.GetComponent <Node>().UnitSlots.Count;

            for (int i = 0; i < slotCount; ++i)
            {
                helper.FactoryToFillOut.ProduceUnit(0);
                yield return(new WaitForSeconds(0.1f));
            }

            yield return(null);

            Assert.IsFalse(factory.GetComponent <Node>().UnitSlots.Exists(slot => !slot.IsOccupied));
            Assert.IsTrue(resourceManager.ResourcesRemaining == (resourceManager.MaxResources - slotCount * helper.FactoryToFillOut.UnitProductionData[0].ProductionCost));
        }
        public void NonoverrideKnownTestFeatureSet()
        {
            var foundFeatureSet = GetFeatureSetWithId(BuildTargetGroup.WSA, k_TestFeatureSetId);

            Assert.IsNotNull(foundFeatureSet);
            Assert.AreEqual(0, String.Compare(foundFeatureSet.name, k_KnownFeatureSetName, true));
        }
        public void AssetBundleTable_GetAssetDataTest()
        {
#if UNITY_EDITOR
            AssetBundleSettings.SimulateAssetBundleInEditor = true;
#endif
            ResKit.Init();

            var assetBundleTable = AssetBundleSettings.AssetBundleConfigFile;

            var resSearchKeys = ResSearchKeys.Allocate("coin_get1", null, typeof(AudioClip));
            var audioClipData = assetBundleTable.GetAssetData(resSearchKeys);
            resSearchKeys.Recycle2Cache();

            Assert.IsNotNull(audioClipData);
            Assert.AreEqual(audioClipData.OwnerBundleName, "coin_get1_mp3");
            Assert.AreEqual(audioClipData.AssetObjectTypeCode, typeof(AudioClip).ToCode());

            resSearchKeys = ResSearchKeys.Allocate("coin_get1", null, typeof(GameObject));
            var gameObjectData = assetBundleTable.GetAssetData(resSearchKeys);
            resSearchKeys.Recycle2Cache();

            Assert.IsNotNull(gameObjectData);
            Assert.AreEqual(gameObjectData.OwnerBundleName, "coin_get1_prefab");
            Assert.AreEqual(gameObjectData.AssetObjectTypeCode, typeof(GameObject).ToCode());
        }
        public void OverrideKnownTestFeatureSet()
        {
            var foundFeatureSet = OpenXRFeatureSetManager.GetFeatureSetWithId(BuildTargetGroup.Standalone, k_TestFeatureSetId);

            Assert.IsNotNull(foundFeatureSet);
            Assert.AreEqual(0, String.Compare(foundFeatureSet.name, k_TestFeatureSetName, true));
        }
        public void AssetBundleTable_GetAssetDataTest()
        {
            FromUnityToDll.Setting.SimulationMode = false;

            ResKit.Init();

            var assetBundleTable = AssetBundleSettings.AssetBundleConfigFile;

            var resSearchKeys = ResSearchKeys.Allocate("coin_get1", null, typeof(AudioClip));
            var audioClipData = assetBundleTable.GetAssetData(resSearchKeys);

            resSearchKeys.Recycle2Cache();

            Assert.IsNotNull(audioClipData);
            Assert.AreEqual(audioClipData.OwnerBundleName, "coin_get1_mp3");
            Assert.AreEqual(audioClipData.AssetObjectTypeCode, typeof(AudioClip).ToCode());

            resSearchKeys = ResSearchKeys.Allocate("coin_get1", null, typeof(GameObject));
            var gameObjectData = assetBundleTable.GetAssetData(resSearchKeys);

            resSearchKeys.Recycle2Cache();

            Assert.IsNotNull(gameObjectData);
            Assert.AreEqual(gameObjectData.OwnerBundleName, "coin_get1_prefab");
            Assert.AreEqual(gameObjectData.AssetObjectTypeCode, typeof(GameObject).ToCode());
        }
        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);
                }
            }
        }
Beispiel #13
0
        public void TransfromtoLocal_ChildObjectTransform_LocalTransform()
        {
            GameObject parent = new GameObject();

            parent.transform.position = new Vector3(1, 1, 1);
            GameObject child = new GameObject();

            child.transform.parent        = parent.transform;
            child.transform.localPosition = new Vector3(.2f, .3f, .5f);
            child.transform.localRotation = new Quaternion(.3f, .4f, .5f, 1);

            var testMsg     = child.transform.ToLocal <FLU>();
            var fluPosition = child.transform.localPosition.To <FLU>();
            var fluRotation = child.transform.localRotation.To <FLU>();

            Assert.IsNotNull(testMsg);
            Assert.AreApproximatelyEqual(fluPosition.x, (float)testMsg.translation.x);
            Assert.AreApproximatelyEqual(fluPosition.y, (float)testMsg.translation.y);
            Assert.AreApproximatelyEqual(fluPosition.z, (float)testMsg.translation.z);
            Assert.AreApproximatelyEqual(fluRotation.x, (float)testMsg.rotation.x);
            Assert.AreApproximatelyEqual(fluRotation.y, (float)testMsg.rotation.y);
            Assert.AreApproximatelyEqual(fluRotation.z, (float)testMsg.rotation.z);
            Assert.AreApproximatelyEqual(fluRotation.w, (float)testMsg.rotation.w);

            Object.DestroyImmediate(parent);
        }
Beispiel #14
0
        public IEnumerator StartFromTestWithSingletonAndReturnBack()
        {
            SceneManager.LoadScene("SceneWithSingleton");
            yield return(new WaitForSeconds(.1f));

            var instance1 = TestSingleton.GetInstance;

            Assert.IsNotNull(instance1);
            var instance2 = Object.FindObjectOfType <TestSingleton>();

            Assert.IsNotNull(instance2);
            Assert.AreEqual(instance1, instance2);

            SceneManager.LoadScene("SceneWithoutSingleton");
            yield return(new WaitForSeconds(.1f));

            instance1 = TestSingleton.GetInstance;
            Assert.IsNotNull(instance1);
            instance2 = Object.FindObjectOfType <TestSingleton>();
            Assert.IsNotNull(instance2);
            Assert.AreEqual(instance1, instance2);


            SceneManager.LoadScene("SceneWithSingleton");
            yield return(new WaitForSeconds(.1f));

            instance1 = TestSingleton.GetInstance;
            Assert.IsNotNull(instance1);
            instance2 = Object.FindObjectOfType <TestSingleton>();
            Assert.IsNotNull(instance2);
            Assert.AreEqual(instance1, instance2);
        }
        public void NestedSourceScope()
        {
            var       registry = new UTinyRegistry();
            var       builtInCount = registry.Count;
            var       sourceId = "outer";
            var       nestedSourceId = "inner";
            UTinyType testType, testType2;

            using (registry.SourceIdentifierScope(sourceId))
            {
                testType = registry.CreateType(UTinyId.New(), "TestType", UTinyTypeCode.Component);
                using (registry.SourceIdentifierScope(nestedSourceId))
                {
                    testType2 = registry.CreateType(UTinyId.New(), "TestType2", UTinyTypeCode.Component);
                }
            }

            var testTypeRef  = (UTinyType.Reference)testType;
            var testType2Ref = (UTinyType.Reference)testType2;

            Assert.AreEqual(builtInCount + 2, registry.Count);

            registry.UnregisterAllBySource(sourceId);
            Assert.AreEqual(builtInCount + 1, registry.Count);

            Assert.IsNull(testTypeRef.Dereference(registry));
            Assert.IsNotNull(testType2Ref.Dereference(registry));

            registry.UnregisterAllBySource(nestedSourceId);
            Assert.AreEqual(builtInCount, registry.Count);
            Assert.IsNull(testTypeRef.Dereference(registry));
            Assert.IsNull(testType2Ref.Dereference(registry));
        }
        public IEnumerator ResourcesResLoadAsyncTest()
        {
            var resLoader = ResLoader.Allocate();

            var       loaded = false;
            AudioClip clip   = null;

            // 异步加载一个资源
            resLoader.Add2Load <AudioClip>("resources://coin_get1", (succeed, res) =>
            {
                if (succeed)
                {
                    clip   = res.Asset as AudioClip;
                    loaded = true;
                }
                else
                {
                    loaded = true;
                }
            });

            resLoader.LoadAsync();

            // 等待回调成功
            while (!loaded)
            {
                yield return(null);
            }

            Assert.IsNotNull(clip);

            resLoader.Recycle2Cache();
        }
Beispiel #17
0
        public IEnumerator StartFromTestWithSingletonAndReturnBack()
        {
            SceneManager.LoadScene("PoolingTestScene");
            yield return(new WaitForSeconds(.1f));

            var instance1 = Object.FindObjectOfType <BlockPooler>();

            Assert.IsNotNull(instance1);

            SceneManager.LoadScene("PoolingTestScene2");
            yield return(new WaitForSeconds(.1f));

            var instance2 = Object.FindObjectOfType <BlockPooler>();

            Assert.IsNotNull(instance2);
            Assert.AreEqual(instance1, instance2);

            SceneManager.LoadScene("PoolingTestScene");
            yield return(new WaitForSeconds(.1f));


            var instance3 = Object.FindObjectOfType <BlockPooler>();

            Assert.IsNotNull(instance3);
            Assert.AreEqual(instance1, instance3);
            Assert.AreEqual(instance2, instance3);
        }
Beispiel #18
0
        /// <summary>
        /// Evaluates the possibility of moving from the given postion to the given other position.
        /// Assumes the spaces between the two positions are clear of pieces.
        /// Returns "null" if the move isn't allowed.
        /// Also outputs whether something is blocking any further movement in this direction.
        /// </summary>
        /// <param name="isBlocking">
        /// This variable will tell whether something is blocking
        ///     any further movement in this direction.
        /// </param>
        private Action_Move TryMove(Vector2i from, Vector2i to, out bool isBlocking)
        {
            Piece p = theBoard[from.x, from.y];

            Assert.IsNotNull(p, "No piece at " + from.ToString());

            //If something is already there, no moves are allowed and the movement is blocked.
            if (theBoard[to.x, to.y] != null)
            {
                isBlocking = true;
                return(null);
            }

            //If this piece isn't a king and this is the throne square,
            //    it can't move into the throne but it can move *through* it.
            if (!p.IsKing && to.x == (BoardSize / 2) && to.y == (BoardSize / 2))
            {
                isBlocking = false;
                return(null);
            }

            //Otherwise, it's a valid move.
            isBlocking = false;
            return(new Action_Move(to, p, GetCaptures(from, to)));
        }
Beispiel #19
0
        public void GetGameDataPath()
        {
            string path = FileUtils.GetGameDataPath();

            Assert.IsNotNull(path);
            Assert.IsTrue(path.EndsWith("/Assets/GameData/"),
                          "ゲームデータの格納場所が「/Assets/GameData/」配下であること。");
        }
Beispiel #20
0
        public void GetColumn_Should_NotReturnNull_When_FieldWasConfigured()
        {
            var fieldInfo = Type.GetField("_columnElement", BindingFlags.NonPublic | BindingFlags.Instance);

            fieldInfo?.SetValue(ScriptUnderTest, new GameObject());

            Assert.IsNotNull(ScriptUnderTest.Column);
        }
        /// <summary>
        /// Enables a required feature of a given type.
        /// </summary>
        /// <param name="featureType">Type of feature to enable</param>
        /// <returns>Feature that was enabled or null</returns>
        protected OpenXRFeature EnableFeature(Type featureType, bool enable = true)
        {
            var feature = GetFeature(featureType);

            Assert.IsNotNull(feature);
            feature.enabled = enable;
            return(feature);
        }
        public void NonoverrideKnownTestFeatureSet()
        {
            OpenXRFeatureSetManager.InitializeFeatureSets(true);
            var foundFeatureSet = OpenXRFeatureSetManager.GetFeatureSetWithId(BuildTargetGroup.WSA, k_TestFeatureSetId);

            Assert.IsNotNull(foundFeatureSet);
            Assert.AreEqual(0, String.Compare(foundFeatureSet.name, k_KnownFeatureSetName, true));
        }
        private static void VerifyClip(TimelineClip clip)
        {
            Assert.IsNotNull(clip);
            DummyTimelinePlayableAsset playableAsset = clip.asset as DummyTimelinePlayableAsset;

            Assert.IsNotNull(playableAsset);
            Assert.IsTrue(playableAsset.IsInitialized());
        }
        public void CreateInstance()
        {
            DummySingletonA firstSingleton  = DummySingletonA.GetOrCreateInstance();
            DummySingletonA secondSingleton = DummySingletonA.GetOrCreateInstance();

            Assert.IsNotNull(firstSingleton);
            Assert.AreEqual(firstSingleton, secondSingleton);
        }
Beispiel #25
0
        public void GetColors_Should_NotReturnNull_When_FieldWasConfigured()
        {
            var fieldInfo = Type.GetField("_rowColors", BindingFlags.NonPublic | BindingFlags.Instance);

            fieldInfo?.SetValue(ScriptUnderTest, new Color[0]);

            Assert.IsNotNull(ScriptUnderTest.Colors);
        }
Beispiel #26
0
//----------------------------------------------------------------------------------------------------------------------

        static Transform FindOrCreateChildAndVerify(Transform parent, string childName)
        {
            Transform child = parent.FindOrCreateChild(childName);

            Assert.IsNotNull(child);
            Assert.AreEqual(parent, child.parent);
            return(child);
        }
        public void CreateDifferentSingletons()
        {
            MonoBehaviour singletonA = DummySingletonA.GetOrCreateInstance();
            MonoBehaviour singletonB = DummySingletonB.GetOrCreateInstance();

            Assert.IsNotNull(singletonA);
            Assert.IsNotNull(singletonB);
            Assert.AreNotEqual(singletonA, singletonB);
        }
Beispiel #28
0
        /// <summary>
        /// Registers the object with a Physics system either the default system or one which exists within the level.
        /// </summary>
        void OnEnable()
        {
            // Ensure we have a physics system to register with.
            var m_system = Physics.FindSystem();

            Assert.IsNotNull(m_system, "Couldn't find a Physics system to register with.");

            m_system.Register(this);
        }
        public void AddItem(MenuItem item, int indx)
        {
            Assert.IsNotNull(item);

            _items.Insert(indx, item);
            item.Setup(_items.Count > ItemsPerFrame
                ? (indx) % ItemsPerFrame
                : indx, transform);
        }
        private GameObject InstantiatePrefabFromPath(string path)
        {
            // Load joystick prefab.
            Object     joystickPrefab = AssetDatabase.LoadAssetAtPath(path, typeof(Object));
            GameObject joystick       = Object.Instantiate(joystickPrefab) as GameObject;

            Assert.IsNotNull(joystick);
            return(joystick);
        }