From eb84bb298d2b95aec7b2ae12cbf25ac64f25379a Mon Sep 17 00:00:00 2001 From: tylermurphy534 Date: Sun, 6 Nov 2022 15:12:42 -0500 Subject: move to self host --- .../Editor/UnityEditorTests/UICompilerTests.cs | 49 ++++++++++++++++++++++ .../UnityEditorTests/UICompilerTests.cs.meta | 11 +++++ .../UnityEditorTests/UnityEditorTests.asmdef | 25 +++++++++++ .../UnityEditorTests/UnityEditorTests.asmdef.meta | 7 ++++ 4 files changed, 92 insertions(+) create mode 100644 VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UICompilerTests.cs create mode 100644 VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UICompilerTests.cs.meta create mode 100644 VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UnityEditorTests.asmdef create mode 100644 VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UnityEditorTests.asmdef.meta (limited to 'VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests') diff --git a/VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UICompilerTests.cs b/VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UICompilerTests.cs new file mode 100644 index 00000000..737586ec --- /dev/null +++ b/VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UICompilerTests.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; +using UnityEditor; +using UnityEngine; +using VRC.Udon.Editor; +using VRC.Udon.Editor.ProgramSources.UdonGraphProgram; +using VRC.Udon.Graph; +using UINew = VRC.Udon.Editor.ProgramSources.UdonGraphProgram.UI.GraphView; + +namespace Tests +{ + public class UICompilerTests + { + [Test] + public void CompareAssemblies() + { + // Cache Udon Graph View window for reuse + var graphViewWindow = EditorWindow.GetWindow(); + + // Loop through every asset in project + var assets = AssetDatabase.FindAssets("t:UdonGraphProgramAsset"); + foreach (string guid in assets) + { + // Compile assembly from copy of existing asset + string path = AssetDatabase.GUIDToAssetPath(guid); + var legacyData = GetDataFromAssetAtPath(path); + var legacyAssembly = UdonEditorManager.Instance.CompileGraph(legacyData, null, out Dictionary _, out Dictionary heapDefaultValues); + + // Compile assembly from copy of asset loaded into new graph + var newAsset = ScriptableObject.CreateInstance(); + newAsset.graphData = new UdonGraphData(legacyData); + // This function loads the asset and reserializes it + var newData = graphViewWindow.GetGraphDataFromAsset(newAsset); + var newAssembly = UdonEditorManager.Instance.CompileGraph(newData, null, out Dictionary _, out Dictionary heapDefaultValues1); + + Assert.AreEqual(newAssembly, legacyAssembly); + } + graphViewWindow.Close(); + } + + public UdonGraphData GetDataFromAssetAtPath(string path) + { + var targetAsset = AssetDatabase.LoadAssetAtPath(path); + return new UdonGraphData(targetAsset.graphData); + + } + } +} diff --git a/VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UICompilerTests.cs.meta b/VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UICompilerTests.cs.meta new file mode 100644 index 00000000..a9b1bcfc --- /dev/null +++ b/VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UICompilerTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 02e7e7f5f9fc2c24ab3af0b8780f3623 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UnityEditorTests.asmdef b/VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UnityEditorTests.asmdef new file mode 100644 index 00000000..34e24e8c --- /dev/null +++ b/VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UnityEditorTests.asmdef @@ -0,0 +1,25 @@ +{ + "name": "UnityEditorTests", + "references": [ + "VRC.Udon.Editor", + "VRC.Udon", + "VRC.Udon.Tests", + "UnityEngine.TestRunner", + "UnityEditor.TestRunner" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": true, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UnityEditorTests.asmdef.meta b/VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UnityEditorTests.asmdef.meta new file mode 100644 index 00000000..5ad1ed4e --- /dev/null +++ b/VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UnityEditorTests.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3c3c5a3876474c648a47177c1875f447 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: -- cgit v1.2.3-freya