public static IEnumerable GetScenesForPipeline(string _pipelinePath, bool fixtureParam = false)
            {
#if UNITY_EDITOR
                string absoluteScenesPath = s_Path.Aggregate(s_RootPath, Path.Combine);

                string assetScenesPath = absoluteScenesPath.Substring(absoluteScenesPath.IndexOf("Assets"));

                string filesPath = Path.Combine(assetScenesPath, _pipelinePath);

                string listFilePath = Path.Combine(filesPath, "EditorPlayModeTests.asset");

                EditorPlayModeTests listFile = (EditorPlayModeTests)AssetDatabase.LoadMainAssetAtPath(listFilePath);
                if (listFile == null)
                {
                    AssetDatabase.CreateAsset(ScriptableObject.CreateInstance <EditorPlayModeTests>(), listFilePath);
                    AssetDatabase.Refresh();

                    yield return(null);
                }
                else
                {
                    // Get the additional infos
                    var additionalInfos = GetAdditionalInfos(Path.Combine(filesPath, "AdditionalTestSceneInfos.asset"));

                    for (int i = 0; i < listFile.scenesPath.Length; ++i)
                    {
                        string path = listFile.scenesPath[i];

                        var p     = new FileInfo(Path.Combine(filesPath, path));
                        var split = s_Path.Aggregate("", Path.Combine);
                        split = string.Format("{0}{1}", split, Path.DirectorySeparatorChar);
                        var splitPaths = p.FullName.Split(new[] { split }, StringSplitOptions.RemoveEmptyEntries);

                        string sceneNum = p.Name.Split("_"[0])[0];

                        TestInfo testInfo = new TestInfo
                        {
                            name           = p.Name,
                            comment        = additionalInfos.ContainsKey(sceneNum)? additionalInfos[sceneNum].comment:null,
                            relativePath   = p.ToString(),
                            templatePath   = splitPaths.Last(),
                            threshold      = compareThreshold,
                            frameWait      = frameWait,
                            sceneListIndex = i
                        };

                        if (fixtureParam)
                        {
                            yield return(new TestFixtureData(testInfo));
                        }
                        else
                        {
                            yield return(testInfo);
                        }
                    }
                }
#else
                yield return("null");
#endif
            }
            public static IEnumerable GetScenesForPipeline(string _pipelinePath, bool fixtureParam = false)
            {
#if UNITY_EDITOR
                var absoluteScenesPath = s_Path.Aggregate("Assets", Path.Combine);

                var filesPath = Path.Combine(absoluteScenesPath, _pipelinePath);

                string listFilePath = Path.Combine(filesPath, "EditorPlayModeTests.asset");

                EditorPlayModeTests listFile = (EditorPlayModeTests)AssetDatabase.LoadMainAssetAtPath(listFilePath);
                if (listFile == null)
                {
                    yield return(null);
                }
                else
                {
                    foreach (string path in listFile.scenesPath)
                    {
                        var p     = new FileInfo(path);
                        var split = s_Path.Aggregate("", Path.Combine);
                        split = string.Format("{0}{1}", split, Path.DirectorySeparatorChar);
                        var splitPaths = p.FullName.Split(new[] { split }, StringSplitOptions.RemoveEmptyEntries);

                        TestInfo testInfo = new TestInfo
                        {
                            name         = p.Name,
                            relativePath = path,
                            templatePath = splitPaths.Last(),
                            threshold    = 0.02f,
                            frameWait    = 100
                        };

                        if (fixtureParam)
                        {
                            yield return(new TestFixtureData(testInfo));
                        }
                        else
                        {
                            yield return(testInfo);
                        }
                    }
                }
#else
                yield return("null");
#endif
            }
Exemple #3
0
 private void OnEnable()
 {
     typedTarget = (EditorPlayModeTests)target;
 }