summaryrefslogtreecommitdiff
path: root/VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests
diff options
context:
space:
mode:
Diffstat (limited to 'VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests')
-rw-r--r--VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UICompilerTests.cs49
-rw-r--r--VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UICompilerTests.cs.meta11
-rw-r--r--VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UnityEditorTests.asmdef25
-rw-r--r--VRCSDK3Worlds/Assets/Udon/Editor/UnityEditorTests/UnityEditorTests.asmdef.meta7
4 files changed, 92 insertions, 0 deletions
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<UINew.UdonGraphWindow>();
+
+ // 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<string, (string uid, string fullName, int index)> _, out Dictionary<string, (object value, Type type)> heapDefaultValues);
+
+ // Compile assembly from copy of asset loaded into new graph
+ var newAsset = ScriptableObject.CreateInstance<UdonGraphProgramAsset>();
+ 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<string, (string uid, string fullName, int index)> _, out Dictionary<string, (object value, Type type)> heapDefaultValues1);
+
+ Assert.AreEqual(newAssembly, legacyAssembly);
+ }
+ graphViewWindow.Close();
+ }
+
+ public UdonGraphData GetDataFromAssetAtPath(string path)
+ {
+ var targetAsset = AssetDatabase.LoadAssetAtPath<UdonGraphProgramAsset>(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: