forked from Unity-Technologies/BoatAttack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split test script between editor and runtime folders
- Loading branch information
Showing
8 changed files
with
88 additions
and
42 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
Assets/Scripts/UnityGFXTests/Editor/BoatAttackGraphicsTestsEditor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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 changes: 11 additions & 0 deletions
11
Assets/Scripts/UnityGFXTests/Editor/BoatAttackGraphicsTestsEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
Assets/Scripts/UnityGFXTests/Editor/UnityGFXTests.BoatAttack.asmdef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"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 changes: 7 additions & 0 deletions
7
Assets/Scripts/UnityGFXTests/Editor/UnityGFXTests.BoatAttack.asmdef.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Assets/Scripts/UnityGFXTests/Runtime/BoatAttackGraphicsTests.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Assets/Scripts/UnityGFXTests/Runtime/UnityGFXTests.BoatAttack.asmdef.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.