Exemplo n.º 1
0
        public virtual bool RunTest(string TestName)
        {
            if (bWasTestRunningInEditor && !EditorApplication.isPlaying && TestRunnerInst != null && TestRunnerInst.CurrentTest != null && TestRunnerInst.CurrentTest.bStartGameInEditor)
            {
                if (InternalCleanupTestable(true))
                {
                    bWasTestRunningInEditor = false;

                    return(true);
                }

                return(false);
            }

            if (MonsterStarter.GetInstance(false) == null || TestRunnerInst == null)
            {
                if (TestRunnerInst == null)
                {
                    TestRunnerInst = new MonsterTestRunner();

                    TestRunnerInst.PreloadTest(TestName);
                }

                if (TestRunnerInst.CurrentTest != null && TestRunnerInst.CurrentTest.bAllowRunningInEditor &&
                    !InternalBuildTestable(true))
                {
                    return(false);
                }

                if (TestRunnerInst.CurrentTest != null && TestRunnerInst.CurrentTest.bStartGameInEditor)
                {
                    EditorApplication.isPlaying = true;

                    bWasTestRunningInEditor = true;

                    if (MonsterStarter.GetInstance(false) == null)
                    {
                        return(false);
                    }
                }

                TestRunnerInst.StartTest(TestName);
            }

            if (TestRunnerInst.RunTests())
            {
                return(TestRunnerInst.CurrentTest == null || !TestRunnerInst.CurrentTest.bAllowRunningInEditor || InternalCleanupTestable(true));
            }

            return(false);
        }
Exemplo n.º 2
0
        public virtual void Awake()
        {
            if(Instance == null)
            {
                DontDestroyOnLoad(gameObject);
                Instance = this;

                CheckForAndRunTest();
            }
            else
            {
                GameObject.DestroyImmediate(gameObject);
            }
        }
Exemplo n.º 3
0
        public virtual void Awake()
        {
            if (Instance == null)
            {
                DontDestroyOnLoad(gameObject);
                Instance = this;

                CheckForAndRunTest();
            }
            else
            {
                GameObject.DestroyImmediate(gameObject);
            }
        }
Exemplo n.º 4
0
        public virtual bool InternalBuildTestable(bool bRunningTestInEditor = false)
        {
            if (!bRunningTestInEditor)
            {
                if (!IgorSetScriptingDefines.ExtraModuleParams.Contains("MONSTER_TEST_RUNTIME"))
                {
                    IgorSetScriptingDefines.ExtraModuleParams += ";MONSTER_TEST_RUNTIME";
                }

                if (!IgorSetScriptingDefines.ExtraModuleParams.Contains("IGOR_RUNTIME"))
                {
                    IgorSetScriptingDefines.ExtraModuleParams += ";IGOR_RUNTIME";
                }

                IgorJobConfig.SetStringParam(LastDisplayResolutionDialogFlag, PlayerSettings.displayResolutionDialog.ToString());

                PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled;
            }

            if (!bRunningTestInEditor || (TestRunnerInst.CurrentTest != null && TestRunnerInst.CurrentTest.bForceLoadToFirstSceneInEditor))
            {
                string FirstLevelName = IgorUtils.GetFirstLevelName();

                if (FirstLevelName != "")
                {
                    if (EditorApplication.currentScene != FirstLevelName)
                    {
                        EditorApplication.OpenScene(FirstLevelName);

                        return(false);
                    }
                }
            }

            if (MonsterStarter.GetInstance() == null)
            {
                GameObject MonsterStarterInst = new GameObject("MonsterTestStarter");

                MonsterStarterInst.AddComponent <MonsterStarter>();

                EditorApplication.SaveScene();
            }

            if (!bRunningTestInEditor)
            {
                string StreamingAssetsFolder = Path.Combine("Assets", Path.Combine("StreamingAssets", Path.Combine("Igor", Path.Combine("Monster", "Config"))));

                if (Directory.Exists(StreamingAssetsFolder))
                {
                    MonsterDebug.LogError("Attempting to overwrite the " + StreamingAssetsFolder + ", but it already exists!");

                    IgorRuntimeUtils.DeleteDirectory(StreamingAssetsFolder);

                    Directory.CreateDirectory(StreamingAssetsFolder);
                }
                else
                {
                    Directory.CreateDirectory(StreamingAssetsFolder);
                }

                string ConfigRoot = Path.Combine(MonsterTestCore.MonsterLocalDirectoryRoot, "Config");

                if (Directory.Exists(ConfigRoot))
                {
                    IgorRuntimeUtils.DirectoryCopy(ConfigRoot, StreamingAssetsFolder, true);
                }
            }

            return(true);
        }