浏览代码

Split test script between editor and runtime folders

/main
Andre McGrail 3 年前
当前提交
280f1a84
共有 8 个文件被更改,包括 88 次插入42 次删除
  1. 38
      Assets/Scripts/UnityGFXTests/Runtime/BoatAttackGraphicsTests.cs
  2. 2
      Assets/Scripts/UnityGFXTests/Runtime/BoatAttackGraphicsTests.cs.meta
  3. 6
      Assets/Scripts/UnityGFXTests/Runtime/UnityGFXTests.BoatAttack.asmdef
  4. 2
      Assets/Scripts/UnityGFXTests/Runtime/UnityGFXTests.BoatAttack.asmdef.meta
  5. 41
      Assets/Scripts/UnityGFXTests/Editor/BoatAttackGraphicsTestsEditor.cs
  6. 11
      Assets/Scripts/UnityGFXTests/Editor/BoatAttackGraphicsTestsEditor.cs.meta
  7. 23
      Assets/Scripts/UnityGFXTests/Editor/UnityGFXTests.BoatAttack.asmdef
  8. 7
      Assets/Scripts/UnityGFXTests/Editor/UnityGFXTests.BoatAttack.asmdef.meta

38
Assets/Scripts/UnityGFXTests/Runtime/BoatAttackGraphicsTests.cs


using UnityEngine.TestTools;
using UnityEngine.TestTools.Graphics;
using UnityEngine.SceneManagement;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.TestTools.Graphics;
#endif
public class BoatAttackGraphicsTests : IPrebuildSetup, IPostBuildCleanup
public class BoatAttackGraphicsTests
private const string DefineKey = "BoatAttack_Tests_ScriptingDefines";
private static float _oldTimeScale = 1.0f; // give default of 1 just in case
#if UNITY_EDITOR
public void Setup()
{
// save current scription defines and set both STATIC_EVERYTHING and LWRP_DEBUG_STATIC_POSTFX
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
EditorPrefs.SetString(DefineKey, defines);
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, "STATIC_EVERYTHING;LWRP_DEBUG_STATIC_POSTFX");
// store current timescale and set it to 0
_oldTimeScale = Time.timeScale;
Time.timeScale = 0f;
// run base graphics test setup
SetupGraphicsTestCases.Setup();
}
#endif
[UnityTest, Category("BoatAttack")]
[UseGraphicsTestCases]

[TearDown]
public void DumpImagesInEditor()
{
ResultsUtility.ExtractImagesFromTestProperties(TestContext.CurrentContext.Test);
}
public void Cleanup()
{
EditorApplication.delayCall += FinalCall;
Time.timeScale = _oldTimeScale;
Shader.DisableKeyword("_STATIC_SHADER");
}
private static void FinalCall()
{
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, EditorPrefs.GetString(DefineKey));
EditorPrefs.DeleteKey(DefineKey);
UnityEditor.TestTools.Graphics.ResultsUtility.ExtractImagesFromTestProperties(TestContext.CurrentContext.Test);
}
#endif
}

2
Assets/Scripts/UnityGFXTests/Runtime/BoatAttackGraphicsTests.cs.meta


fileFormatVersion: 2
guid: d73105ca5926f484d907793c734ea6ee
guid: e54fc75b65a2627438a94e5598ffabc7
MonoImporter:
externalObjects: {}
serializedVersion: 2

6
Assets/Scripts/UnityGFXTests/Runtime/UnityGFXTests.BoatAttack.asmdef


"rootNamespace": "",
"references": [
"GUID:c081bc530f560634bb5c21d4b323a7f1",
"GUID:0acc523941302664db1f4e527237feb3",
"GUID:27619889b8ba8c24980f49ee34dbb44a",
"GUID:e18141520846dcc44b725b2f74e91229"
"GUID:27619889b8ba8c24980f49ee34dbb44a"
],
"includePlatforms": [],
"excludePlatforms": [],

"nunit.framework.dll"
],
"autoReferenced": true,
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],

2
Assets/Scripts/UnityGFXTests/Runtime/UnityGFXTests.BoatAttack.asmdef.meta


fileFormatVersion: 2
guid: 383bb64436b6a49c6bdbc8b7fb20fc14
guid: fc3748608b3f2404fb61a32951fdca2c
AssemblyDefinitionImporter:
externalObjects: {}
userData:

41
Assets/Scripts/UnityGFXTests/Editor/BoatAttackGraphicsTestsEditor.cs


using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using UnityEngine.TestTools.Graphics;
using UnityEngine.SceneManagement;
using UnityEditor;
using UnityEditor.TestTools.Graphics;
public class BoatAttackGraphicsTestsEditor : IPrebuildSetup, IPostBuildCleanup
{
private const string DefineKey = "BoatAttack_Tests_ScriptingDefines";
private static float _oldTimeScale = 1.0f; // give default of 1 just in case
public void Setup()
{
// save current scription defines and set both STATIC_EVERYTHING and LWRP_DEBUG_STATIC_POSTFX
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
EditorPrefs.SetString(DefineKey, defines);
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, "STATIC_EVERYTHING;LWRP_DEBUG_STATIC_POSTFX");
// store current timescale and set it to 0
_oldTimeScale = Time.timeScale;
Time.timeScale = 0f;
// run base graphics test setup
SetupGraphicsTestCases.Setup();
}
public void Cleanup()
{
EditorApplication.delayCall += FinalCall;
Time.timeScale = _oldTimeScale;
Shader.DisableKeyword("_STATIC_SHADER");
}
private static void FinalCall()
{
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, EditorPrefs.GetString(DefineKey));
EditorPrefs.DeleteKey(DefineKey);
}
}

11
Assets/Scripts/UnityGFXTests/Editor/BoatAttackGraphicsTestsEditor.cs.meta


fileFormatVersion: 2
guid: d73105ca5926f484d907793c734ea6ee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

23
Assets/Scripts/UnityGFXTests/Editor/UnityGFXTests.BoatAttack.asmdef


{
"name": "UnityGFXTests.Editor.BoatAttack",
"rootNamespace": "",
"references": [
"GUID:c081bc530f560634bb5c21d4b323a7f1",
"GUID:0acc523941302664db1f4e527237feb3",
"GUID:27619889b8ba8c24980f49ee34dbb44a",
"GUID:e18141520846dcc44b725b2f74e91229"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

7
Assets/Scripts/UnityGFXTests/Editor/UnityGFXTests.BoatAttack.asmdef.meta


fileFormatVersion: 2
guid: 383bb64436b6a49c6bdbc8b7fb20fc14
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存