浏览代码

Correct pipeline assets not beeing set up correctly after running the tests.

Also, backup and restore current opened scenes after running any test.
/main
Remy 7 年前
当前提交
585366d1
共有 3 个文件被更改,包括 44 次插入4 次删除
  1. 39
      Tests/Scripts/Editor/GraphicTests/Framework/TestFramework.cs
  2. 5
      Tests/Scripts/GraphicTests/Framework/SetupSceneForRenderPipelineTest.cs
  3. 4
      Tests/Scripts/GraphicTests/Framework/TestFrameworkTools.cs

39
Tests/Scripts/Editor/GraphicTests/Framework/TestFramework.cs


[OneTimeSetUp]
public void OneTimeSetUp()
{
BackupSceneManagerSetup();
SetupRenderPipeAsset();
}

Debug.Log("OnTimeTearDown");
RestoreSceneManagerSetup();
}
public static RenderPipelineAsset GetRenderPipelineAsset(string _SRP_ID)

string filePath = Path.Combine(absolutePath, TestFrameworkTools.renderPipelineAssets[_SRP_ID] );
filePath = filePath.Replace(Application.dataPath, "");
filePath = filePath.Remove(0, 1);
//Debug.Log("Before combine: " + filePath);
filePath = Path.Combine("Assets", filePath);
//Debug.Log("RP Asset is at : " + filePath);
return (RenderPipelineAsset)AssetDatabase.LoadAssetAtPath(filePath, typeof(RenderPipelineAsset));
}

public void SetupRenderPipeAsset()
{
Debug.Log("Set " + _SRP_ID + " render pipeline.");
//Debug.Log("Set " + _SRP_ID + " render pipeline. Previous was "+ ( (UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset == null)? "null":UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset.name) );
//Debug.Log("RestoreRenderPipeAsset from " + wantedTestsRenderPipeAsset.name + " to " + ((beforeTestsRenderPipeAsset == null)?"null":beforeTestsRenderPipeAsset.name));
{
//Debug.Log("RestoreRenderPipeAsset -> Actual restore");
}
}
public static SceneSetup[] sceneManagerSetupBeforeTest;
public void BackupSceneManagerSetup()
{
sceneManagerSetupBeforeTest = EditorSceneManager.GetSceneManagerSetup();
}
public void RestoreSceneManagerSetup()
{
if ( (sceneManagerSetupBeforeTest == null) || ( sceneManagerSetupBeforeTest.Length == 0 ) )
{
EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
}
else
{
EditorSceneManager.RestoreSceneManagerSetup(sceneManagerSetupBeforeTest);
}
}

5
Tests/Scripts/GraphicTests/Framework/SetupSceneForRenderPipelineTest.cs


public void TearDown()
{
if ( GraphicsSettings.renderPipelineAsset != m_OriginalAsset ) GraphicsSettings.renderPipelineAsset = m_OriginalAsset;
if (GraphicsSettings.renderPipelineAsset != m_OriginalAsset)
{
GraphicsSettings.renderPipelineAsset = m_OriginalAsset;
}
//EditorApplication.isPaused = false;
//EditorApplication.isPlaying = false;

4
Tests/Scripts/GraphicTests/Framework/TestFrameworkTools.cs


public static Dictionary<string, string> renderPipelineAssets = new Dictionary<string, string>()
{
{ "HDRP", "Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/HDRP_GraphicTests_Asset.asset" },
{ "LWRP", "Tests/GraphicsTests/RenderPipeline/LightweightPipeline/LightweightPipelineAsset.asset" }
{ "HDRP", "HDRenderPipeline/CommonAssets/HDRP_GraphicTests_Asset.asset" },
{ "LWRP", "LightweightPipeline/LightweightPipelineAsset.asset" }
};
// Renderpipeline assets used for the tests

正在加载...
取消
保存