@mflrevan/ucp 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +1 -1
  2. package/bridge/com.ucp.bridge/CHANGELOG.md +145 -0
  3. package/bridge/com.ucp.bridge/CHANGELOG.md.meta +7 -0
  4. package/bridge/com.ucp.bridge/Editor/Bridge/BridgeServer.cs +583 -0
  5. package/bridge/com.ucp.bridge/Editor/Bridge/BridgeServer.cs.meta +2 -0
  6. package/bridge/com.ucp.bridge/Editor/Bridge.meta +8 -0
  7. package/bridge/com.ucp.bridge/Editor/Controllers/AssetController.cs +425 -0
  8. package/bridge/com.ucp.bridge/Editor/Controllers/AssetController.cs.meta +2 -0
  9. package/bridge/com.ucp.bridge/Editor/Controllers/AssetImportSupport.cs +355 -0
  10. package/bridge/com.ucp.bridge/Editor/Controllers/AssetImportSupport.cs.meta +2 -0
  11. package/bridge/com.ucp.bridge/Editor/Controllers/BuildController.cs +233 -0
  12. package/bridge/com.ucp.bridge/Editor/Controllers/BuildController.cs.meta +2 -0
  13. package/bridge/com.ucp.bridge/Editor/Controllers/CompilationController.cs +26 -0
  14. package/bridge/com.ucp.bridge/Editor/Controllers/CompilationController.cs.meta +2 -0
  15. package/bridge/com.ucp.bridge/Editor/Controllers/EditorController.cs +31 -0
  16. package/bridge/com.ucp.bridge/Editor/Controllers/EditorController.cs.meta +2 -0
  17. package/bridge/com.ucp.bridge/Editor/Controllers/EditorSettingsController.cs +527 -0
  18. package/bridge/com.ucp.bridge/Editor/Controllers/EditorSettingsController.cs.meta +2 -0
  19. package/bridge/com.ucp.bridge/Editor/Controllers/FileController.cs +141 -0
  20. package/bridge/com.ucp.bridge/Editor/Controllers/FileController.cs.meta +2 -0
  21. package/bridge/com.ucp.bridge/Editor/Controllers/HierarchyController.cs +326 -0
  22. package/bridge/com.ucp.bridge/Editor/Controllers/HierarchyController.cs.meta +2 -0
  23. package/bridge/com.ucp.bridge/Editor/Controllers/ImporterController.cs +209 -0
  24. package/bridge/com.ucp.bridge/Editor/Controllers/ImporterController.cs.meta +2 -0
  25. package/bridge/com.ucp.bridge/Editor/Controllers/LogsController.cs +409 -0
  26. package/bridge/com.ucp.bridge/Editor/Controllers/LogsController.cs.meta +2 -0
  27. package/bridge/com.ucp.bridge/Editor/Controllers/MaterialController.cs +354 -0
  28. package/bridge/com.ucp.bridge/Editor/Controllers/MaterialController.cs.meta +2 -0
  29. package/bridge/com.ucp.bridge/Editor/Controllers/ObjectReferenceResolver.cs +93 -0
  30. package/bridge/com.ucp.bridge/Editor/Controllers/ObjectReferenceResolver.cs.meta +2 -0
  31. package/bridge/com.ucp.bridge/Editor/Controllers/PackagesController.cs +503 -0
  32. package/bridge/com.ucp.bridge/Editor/Controllers/PackagesController.cs.meta +2 -0
  33. package/bridge/com.ucp.bridge/Editor/Controllers/PlayModeController.cs +188 -0
  34. package/bridge/com.ucp.bridge/Editor/Controllers/PlayModeController.cs.meta +2 -0
  35. package/bridge/com.ucp.bridge/Editor/Controllers/PrefabController.cs +260 -0
  36. package/bridge/com.ucp.bridge/Editor/Controllers/PrefabController.cs.meta +2 -0
  37. package/bridge/com.ucp.bridge/Editor/Controllers/ProfilerController.cs +1679 -0
  38. package/bridge/com.ucp.bridge/Editor/Controllers/ProfilerController.cs.meta +2 -0
  39. package/bridge/com.ucp.bridge/Editor/Controllers/PropertyController.cs +563 -0
  40. package/bridge/com.ucp.bridge/Editor/Controllers/PropertyController.cs.meta +2 -0
  41. package/bridge/com.ucp.bridge/Editor/Controllers/SceneChangeTracker.cs +166 -0
  42. package/bridge/com.ucp.bridge/Editor/Controllers/SceneChangeTracker.cs.meta +2 -0
  43. package/bridge/com.ucp.bridge/Editor/Controllers/SceneController.cs +318 -0
  44. package/bridge/com.ucp.bridge/Editor/Controllers/SceneController.cs.meta +2 -0
  45. package/bridge/com.ucp.bridge/Editor/Controllers/ScreenshotController.cs +125 -0
  46. package/bridge/com.ucp.bridge/Editor/Controllers/ScreenshotController.cs.meta +2 -0
  47. package/bridge/com.ucp.bridge/Editor/Controllers/ScriptController.cs +104 -0
  48. package/bridge/com.ucp.bridge/Editor/Controllers/ScriptController.cs.meta +2 -0
  49. package/bridge/com.ucp.bridge/Editor/Controllers/SnapshotController.cs +227 -0
  50. package/bridge/com.ucp.bridge/Editor/Controllers/SnapshotController.cs.meta +2 -0
  51. package/bridge/com.ucp.bridge/Editor/Controllers/TestRunnerController.cs +240 -0
  52. package/bridge/com.ucp.bridge/Editor/Controllers/TestRunnerController.cs.meta +2 -0
  53. package/bridge/com.ucp.bridge/Editor/Controllers/VcsController.cs +611 -0
  54. package/bridge/com.ucp.bridge/Editor/Controllers/VcsController.cs.meta +2 -0
  55. package/bridge/com.ucp.bridge/Editor/Controllers.meta +8 -0
  56. package/bridge/com.ucp.bridge/Editor/Protocol/CommandRouter.cs +53 -0
  57. package/bridge/com.ucp.bridge/Editor/Protocol/CommandRouter.cs.meta +2 -0
  58. package/bridge/com.ucp.bridge/Editor/Protocol/MessageTypes.cs +80 -0
  59. package/bridge/com.ucp.bridge/Editor/Protocol/MessageTypes.cs.meta +2 -0
  60. package/bridge/com.ucp.bridge/Editor/Protocol/MiniJson.cs +358 -0
  61. package/bridge/com.ucp.bridge/Editor/Protocol/MiniJson.cs.meta +2 -0
  62. package/bridge/com.ucp.bridge/Editor/Protocol.meta +8 -0
  63. package/bridge/com.ucp.bridge/Editor/Scripts/IUCPScript.cs +37 -0
  64. package/bridge/com.ucp.bridge/Editor/Scripts/IUCPScript.cs.meta +2 -0
  65. package/bridge/com.ucp.bridge/Editor/Scripts.meta +8 -0
  66. package/bridge/com.ucp.bridge/Editor/UCP.Bridge.Editor.asmdef +16 -0
  67. package/bridge/com.ucp.bridge/Editor/UCP.Bridge.Editor.asmdef.meta +7 -0
  68. package/bridge/com.ucp.bridge/Editor.meta +8 -0
  69. package/bridge/com.ucp.bridge/Runtime/UCP.Bridge.Runtime.asmdef +14 -0
  70. package/bridge/com.ucp.bridge/Runtime/UCP.Bridge.Runtime.asmdef.meta +7 -0
  71. package/bridge/com.ucp.bridge/Runtime.meta +8 -0
  72. package/bridge/com.ucp.bridge/Tests/Editor/ControllerSmokeTests.cs +1085 -0
  73. package/bridge/com.ucp.bridge/Tests/Editor/ControllerSmokeTests.cs.meta +2 -0
  74. package/bridge/com.ucp.bridge/Tests/Editor/UCP.Bridge.Editor.Tests.asmdef +12 -0
  75. package/bridge/com.ucp.bridge/Tests/Editor/UCP.Bridge.Editor.Tests.asmdef.meta +7 -0
  76. package/bridge/com.ucp.bridge/Tests/Editor.meta +8 -0
  77. package/bridge/com.ucp.bridge/Tests.meta +8 -0
  78. package/bridge/com.ucp.bridge/package.json +27 -0
  79. package/bridge/com.ucp.bridge/package.json.meta +7 -0
  80. package/package.json +2 -2
  81. package/scripts/install.js +4 -6
@@ -0,0 +1,104 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using UnityEngine;
4
+
5
+ namespace UCP.Bridge
6
+ {
7
+ public static class ScriptController
8
+ {
9
+ public static void Register(CommandRouter router)
10
+ {
11
+ router.Register("exec/list", HandleList);
12
+ router.Register("exec/run", HandleRun);
13
+ }
14
+
15
+ private static List<IUCPScript> DiscoverScripts()
16
+ {
17
+ var scripts = new List<IUCPScript>();
18
+ var interfaceType = typeof(IUCPScript);
19
+
20
+ foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
21
+ {
22
+ try
23
+ {
24
+ foreach (var type in assembly.GetTypes())
25
+ {
26
+ if (interfaceType.IsAssignableFrom(type) && !type.IsAbstract && !type.IsInterface)
27
+ {
28
+ try
29
+ {
30
+ var instance = (IUCPScript)Activator.CreateInstance(type);
31
+ scripts.Add(instance);
32
+ }
33
+ catch (Exception ex)
34
+ {
35
+ Debug.LogWarning($"[UCP] Failed to instantiate script {type.Name}: {ex.Message}");
36
+ }
37
+ }
38
+ }
39
+ }
40
+ catch (System.Reflection.ReflectionTypeLoadException)
41
+ {
42
+ // Some assemblies can't be scanned - skip silently
43
+ }
44
+ }
45
+
46
+ return scripts;
47
+ }
48
+
49
+ private static object HandleList(string paramsJson)
50
+ {
51
+ var scripts = DiscoverScripts();
52
+ var result = new List<object>();
53
+
54
+ foreach (var s in scripts)
55
+ {
56
+ result.Add(new Dictionary<string, object>
57
+ {
58
+ ["name"] = s.Name,
59
+ ["description"] = s.Description
60
+ });
61
+ }
62
+
63
+ return new Dictionary<string, object>
64
+ {
65
+ ["scripts"] = result,
66
+ ["count"] = result.Count
67
+ };
68
+ }
69
+
70
+ private static object HandleRun(string paramsJson)
71
+ {
72
+ var p = MiniJson.Deserialize(paramsJson) as Dictionary<string, object>;
73
+ if (p == null || !p.TryGetValue("name", out var nameObj))
74
+ throw new ArgumentException("Missing 'name' parameter");
75
+
76
+ var name = nameObj.ToString();
77
+ var scriptParams = "{}";
78
+ if (p.TryGetValue("params", out var paramsObj) && paramsObj != null)
79
+ scriptParams = MiniJson.Serialize(paramsObj);
80
+
81
+ var scripts = DiscoverScripts();
82
+ IUCPScript target = null;
83
+ foreach (var s in scripts)
84
+ {
85
+ if (string.Equals(s.Name, name, StringComparison.OrdinalIgnoreCase))
86
+ {
87
+ target = s;
88
+ break;
89
+ }
90
+ }
91
+
92
+ if (target == null)
93
+ throw new ArgumentException($"Script not found: {name}. Use exec/list to see available scripts.");
94
+
95
+ var result = target.Execute(scriptParams);
96
+
97
+ return new Dictionary<string, object>
98
+ {
99
+ ["script"] = name,
100
+ ["result"] = result
101
+ };
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 99c09fd6072b27744bc0ca44a4f0f8b8
@@ -0,0 +1,227 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using UnityEngine;
4
+ using UnityEngine.SceneManagement;
5
+
6
+ namespace UCP.Bridge
7
+ {
8
+ public static class SnapshotController
9
+ {
10
+ public static void Register(CommandRouter router)
11
+ {
12
+ router.Register("snapshot", HandleSnapshot);
13
+ router.Register("objects/list", HandleListObjects);
14
+ router.Register("objects/components", HandleGetComponents);
15
+ router.Register("objects/transform", HandleGetTransform);
16
+ }
17
+
18
+ private static object HandleSnapshot(string paramsJson)
19
+ {
20
+ var p = MiniJson.Deserialize(paramsJson) as Dictionary<string, object>;
21
+ var filter = p != null && p.TryGetValue("filter", out var f) ? f?.ToString() : null;
22
+ var maxDepth = 0;
23
+ if (p != null && p.TryGetValue("depth", out var d))
24
+ maxDepth = System.Convert.ToInt32(d);
25
+
26
+ var scene = SceneManager.GetActiveScene();
27
+ var roots = scene.GetRootGameObjects();
28
+ var objects = new List<object>();
29
+ int totalObjects = 0;
30
+ int totalComponents = 0;
31
+
32
+ foreach (var root in roots)
33
+ {
34
+ SerializeGameObject(root, objects, ref totalObjects, ref totalComponents, filter, 0, maxDepth);
35
+ }
36
+
37
+ return new Dictionary<string, object>
38
+ {
39
+ ["scene"] = scene.path,
40
+ ["sceneName"] = scene.name,
41
+ ["playMode"] = Application.isPlaying,
42
+ ["timestamp"] = System.DateTime.UtcNow.ToString("o"),
43
+ ["objects"] = objects,
44
+ ["stats"] = new Dictionary<string, object>
45
+ {
46
+ ["objectCount"] = totalObjects,
47
+ ["componentCount"] = totalComponents,
48
+ ["rootCount"] = roots.Length
49
+ }
50
+ };
51
+ }
52
+
53
+ private static bool SerializeGameObject(
54
+ GameObject go, List<object> list, ref int objectCount, ref int componentCount,
55
+ string filter, int depth, int maxDepth)
56
+ {
57
+ bool matchesFilter = string.IsNullOrEmpty(filter)
58
+ || go.name.Contains(filter, System.StringComparison.OrdinalIgnoreCase);
59
+
60
+ var children = new List<object>();
61
+ if (depth < maxDepth)
62
+ {
63
+ for (int i = 0; i < go.transform.childCount; i++)
64
+ {
65
+ SerializeGameObject(
66
+ go.transform.GetChild(i).gameObject,
67
+ children,
68
+ ref objectCount,
69
+ ref componentCount,
70
+ filter,
71
+ depth + 1,
72
+ maxDepth);
73
+ }
74
+ }
75
+
76
+ if (!matchesFilter && children.Count == 0)
77
+ {
78
+ return false;
79
+ }
80
+
81
+ objectCount++;
82
+ var compList = GetComponentTypes(go, ref componentCount);
83
+
84
+ var entry = new Dictionary<string, object>
85
+ {
86
+ ["instanceId"] = go.GetInstanceID(),
87
+ ["name"] = go.name,
88
+ ["active"] = go.activeSelf,
89
+ ["tag"] = go.tag,
90
+ ["layer"] = go.layer,
91
+ ["layerName"] = LayerMask.LayerToName(go.layer),
92
+ ["depth"] = depth,
93
+ ["childCount"] = go.transform.childCount,
94
+ ["components"] = compList,
95
+ };
96
+
97
+ if (children.Count > 0)
98
+ entry["children"] = children;
99
+
100
+ list.Add(entry);
101
+ return true;
102
+ }
103
+
104
+ private static object HandleListObjects(string paramsJson)
105
+ {
106
+ var p = MiniJson.Deserialize(paramsJson) as Dictionary<string, object>;
107
+ var maxDepth = 0;
108
+ if (p != null && p.TryGetValue("depth", out var d))
109
+ maxDepth = Convert.ToInt32(d);
110
+
111
+ var scene = SceneManager.GetActiveScene();
112
+ var roots = scene.GetRootGameObjects();
113
+ var objects = new List<object>();
114
+
115
+ foreach (var root in roots)
116
+ {
117
+ ListObjectsRecursive(root, objects, 0, maxDepth);
118
+ }
119
+
120
+ return new Dictionary<string, object> { ["objects"] = objects };
121
+ }
122
+
123
+ private static void ListObjectsRecursive(GameObject go, List<object> list, int depth, int maxDepth)
124
+ {
125
+ list.Add(new Dictionary<string, object>
126
+ {
127
+ ["instanceId"] = go.GetInstanceID(),
128
+ ["name"] = go.name,
129
+ ["active"] = go.activeSelf,
130
+ ["tag"] = go.tag,
131
+ ["layer"] = go.layer,
132
+ ["layerName"] = LayerMask.LayerToName(go.layer),
133
+ ["childCount"] = go.transform.childCount,
134
+ ["components"] = GetComponentTypes(go),
135
+ ["depth"] = depth
136
+ });
137
+
138
+ if (depth < maxDepth)
139
+ {
140
+ for (int i = 0; i < go.transform.childCount; i++)
141
+ ListObjectsRecursive(go.transform.GetChild(i).gameObject, list, depth + 1, maxDepth);
142
+ }
143
+ }
144
+
145
+ private static object HandleGetComponents(string paramsJson)
146
+ {
147
+ var p = MiniJson.Deserialize(paramsJson) as Dictionary<string, object>;
148
+ if (p == null || !p.TryGetValue("instanceId", out var idObj))
149
+ throw new System.ArgumentException("Missing 'instanceId' parameter");
150
+
151
+ int instanceId = System.Convert.ToInt32(idObj);
152
+ var go = FindByInstanceId(instanceId);
153
+ if (go == null)
154
+ throw new System.Exception($"GameObject not found: {instanceId}");
155
+
156
+ var components = go.GetComponents<Component>();
157
+ var list = new List<object>();
158
+ foreach (var c in components)
159
+ {
160
+ if (c == null) continue;
161
+ var dict = new Dictionary<string, object>
162
+ {
163
+ ["type"] = c.GetType().Name,
164
+ ["fullType"] = c.GetType().FullName
165
+ };
166
+ if (c is Behaviour b)
167
+ dict["enabled"] = b.enabled;
168
+ list.Add(dict);
169
+ }
170
+
171
+ return new Dictionary<string, object>
172
+ {
173
+ ["instanceId"] = instanceId,
174
+ ["name"] = go.name,
175
+ ["components"] = list
176
+ };
177
+ }
178
+
179
+ private static object HandleGetTransform(string paramsJson)
180
+ {
181
+ var p = MiniJson.Deserialize(paramsJson) as Dictionary<string, object>;
182
+ if (p == null || !p.TryGetValue("instanceId", out var idObj))
183
+ throw new System.ArgumentException("Missing 'instanceId' parameter");
184
+
185
+ int instanceId = System.Convert.ToInt32(idObj);
186
+ var go = FindByInstanceId(instanceId);
187
+ if (go == null)
188
+ throw new System.Exception($"GameObject not found: {instanceId}");
189
+
190
+ var t = go.transform;
191
+ return new Dictionary<string, object>
192
+ {
193
+ ["instanceId"] = instanceId,
194
+ ["name"] = go.name,
195
+ ["position"] = new List<object> { (double)t.position.x, (double)t.position.y, (double)t.position.z },
196
+ ["localPosition"] = new List<object> { (double)t.localPosition.x, (double)t.localPosition.y, (double)t.localPosition.z },
197
+ ["rotation"] = new List<object> { (double)t.rotation.x, (double)t.rotation.y, (double)t.rotation.z, (double)t.rotation.w },
198
+ ["eulerAngles"] = new List<object> { (double)t.eulerAngles.x, (double)t.eulerAngles.y, (double)t.eulerAngles.z },
199
+ ["localScale"] = new List<object> { (double)t.localScale.x, (double)t.localScale.y, (double)t.localScale.z }
200
+ };
201
+ }
202
+
203
+ private static GameObject FindByInstanceId(int id)
204
+ {
205
+ var obj = UnityEditor.EditorUtility.EntityIdToObject(id);
206
+ return obj as GameObject;
207
+ }
208
+
209
+ private static List<object> GetComponentTypes(GameObject go)
210
+ {
211
+ int ignored = 0;
212
+ return GetComponentTypes(go, ref ignored);
213
+ }
214
+
215
+ private static List<object> GetComponentTypes(GameObject go, ref int componentCount)
216
+ {
217
+ var componentTypes = new List<object>();
218
+ foreach (var component in go.GetComponents<Component>())
219
+ {
220
+ if (component == null) continue;
221
+ componentCount++;
222
+ componentTypes.Add(component.GetType().Name);
223
+ }
224
+ return componentTypes;
225
+ }
226
+ }
227
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: d73a4998b9c64014d8fa833b8a42f2fb
@@ -0,0 +1,240 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Reflection;
4
+ using UnityEditor;
5
+ using UnityEditor.TestTools.TestRunner.Api;
6
+ using UnityEngine;
7
+
8
+ namespace UCP.Bridge
9
+ {
10
+ public static class TestRunnerController
11
+ {
12
+ private static TestRunnerApi s_api;
13
+ private static TestResultCollector s_collector;
14
+
15
+ public static void Register(CommandRouter router)
16
+ {
17
+ router.Register("tests/run", HandleRunTests);
18
+ }
19
+
20
+ private static object HandleRunTests(string paramsJson)
21
+ {
22
+ var p = MiniJson.Deserialize(paramsJson) as Dictionary<string, object>;
23
+ var mode = "edit";
24
+ string filter = null;
25
+
26
+ if (p != null)
27
+ {
28
+ if (p.TryGetValue("mode", out var m)) mode = m?.ToString() ?? "edit";
29
+ if (p.TryGetValue("filter", out var f)) filter = f?.ToString();
30
+ }
31
+
32
+ var testMode = mode.ToLowerInvariant() switch
33
+ {
34
+ "play" => TestMode.PlayMode,
35
+ "playmode" => TestMode.PlayMode,
36
+ _ => TestMode.EditMode
37
+ };
38
+
39
+ if (s_api == null)
40
+ s_api = ScriptableObject.CreateInstance<TestRunnerApi>();
41
+
42
+ if (s_collector != null)
43
+ s_api.UnregisterCallbacks(s_collector);
44
+
45
+ s_collector = new TestResultCollector();
46
+ s_api.RegisterCallbacks(s_collector);
47
+
48
+ var executionSettings = new ExecutionSettings
49
+ {
50
+ filters = new[] { new Filter { testMode = testMode } }
51
+ };
52
+
53
+ if (!string.IsNullOrEmpty(filter))
54
+ {
55
+ executionSettings.filters[0].testNames = new[] { filter };
56
+ }
57
+
58
+ var shouldWaitForPlayModeExit =
59
+ testMode == TestMode.EditMode &&
60
+ (EditorApplication.isPlaying || EditorApplication.isPlayingOrWillChangePlaymode);
61
+
62
+ if (shouldWaitForPlayModeExit)
63
+ {
64
+ if (EditorApplication.isPlaying)
65
+ EditorApplication.isPlaying = false;
66
+
67
+ ExecuteWhenReady(executionSettings, testMode, EditorApplication.timeSinceStartup + 30.0);
68
+ }
69
+ else
70
+ {
71
+ s_api.Execute(executionSettings);
72
+ }
73
+
74
+ // Tests run asynchronously in Unity. We return immediately with a pending status.
75
+ // Results will be sent as notifications when complete.
76
+ return new Dictionary<string, object>
77
+ {
78
+ ["status"] = "started",
79
+ ["mode"] = mode,
80
+ ["message"] = shouldWaitForPlayModeExit
81
+ ? "Edit-mode tests queued. Waiting for Unity to exit play mode before starting."
82
+ : "Tests started. Results will arrive as notifications."
83
+ };
84
+ }
85
+
86
+ private static void ExecuteWhenReady(ExecutionSettings settings, TestMode mode, double deadline)
87
+ {
88
+ EditorApplication.delayCall += () =>
89
+ {
90
+ var stillInPlayMode = EditorApplication.isPlaying || EditorApplication.isPlayingOrWillChangePlaymode;
91
+ if (mode == TestMode.EditMode && stillInPlayMode)
92
+ {
93
+ if (EditorApplication.timeSinceStartup > deadline)
94
+ {
95
+ BridgeServer.BroadcastNotification("tests/result", new Dictionary<string, object>
96
+ {
97
+ ["summary"] = new Dictionary<string, object>
98
+ {
99
+ ["total"] = 1,
100
+ ["passed"] = 0,
101
+ ["failed"] = 1,
102
+ ["skipped"] = 0,
103
+ ["duration"] = 0.0
104
+ },
105
+ ["tests"] = new List<object>
106
+ {
107
+ new Dictionary<string, object>
108
+ {
109
+ ["name"] = "UCP.Bridge.Tests.PlayModeExitGuard",
110
+ ["status"] = "failed",
111
+ ["duration"] = 0.0,
112
+ ["message"] = "Timed out waiting for Unity to exit play mode before running edit-mode tests."
113
+ }
114
+ }
115
+ });
116
+
117
+ if (s_api != null && s_collector != null)
118
+ s_api.UnregisterCallbacks(s_collector);
119
+ return;
120
+ }
121
+
122
+ ExecuteWhenReady(settings, mode, deadline);
123
+ return;
124
+ }
125
+
126
+ s_api.Execute(settings);
127
+ };
128
+ }
129
+
130
+ private class TestResultCollector : ICallbacks
131
+ {
132
+ private readonly List<object> _results = new();
133
+ private int _passed, _failed, _skipped;
134
+ private double _startTime;
135
+
136
+ public TestResultCollector()
137
+ {
138
+ _startTime = EditorApplication.timeSinceStartup;
139
+ }
140
+
141
+ public void RunStarted(ITestAdaptor testsToRun) { }
142
+
143
+ public void RunFinished(ITestResultAdaptor result)
144
+ {
145
+ _results.Clear();
146
+ _passed = 0;
147
+ _failed = 0;
148
+ _skipped = 0;
149
+ CollectLeafResults(result);
150
+
151
+ var duration = EditorApplication.timeSinceStartup - _startTime;
152
+
153
+ var summary = new Dictionary<string, object>
154
+ {
155
+ ["total"] = _passed + _failed + _skipped,
156
+ ["passed"] = _passed,
157
+ ["failed"] = _failed,
158
+ ["skipped"] = _skipped,
159
+ ["duration"] = (double)duration
160
+ };
161
+
162
+ BridgeServer.BroadcastNotification("tests/result", new Dictionary<string, object>
163
+ {
164
+ ["summary"] = summary,
165
+ ["tests"] = _results
166
+ });
167
+
168
+ if (s_api != null)
169
+ s_api.UnregisterCallbacks(this);
170
+ }
171
+
172
+ public void TestStarted(ITestAdaptor test) { }
173
+
174
+ public void TestFinished(ITestResultAdaptor result) { }
175
+
176
+ private void CollectLeafResults(ITestResultAdaptor result)
177
+ {
178
+ if (result == null)
179
+ return;
180
+
181
+ if (result.HasChildren)
182
+ {
183
+ foreach (var child in result.Children)
184
+ CollectLeafResults(child);
185
+ return;
186
+ }
187
+
188
+ string status;
189
+ switch (result.TestStatus)
190
+ {
191
+ case TestStatus.Passed:
192
+ status = "passed";
193
+ _passed++;
194
+ break;
195
+ case TestStatus.Failed:
196
+ status = "failed";
197
+ _failed++;
198
+ break;
199
+ case TestStatus.Skipped:
200
+ status = "skipped";
201
+ _skipped++;
202
+ break;
203
+ default:
204
+ status = "unknown";
205
+ break;
206
+ }
207
+
208
+ var entry = new Dictionary<string, object>
209
+ {
210
+ ["name"] = ResolveTestName(result),
211
+ ["status"] = status,
212
+ ["duration"] = result.Duration
213
+ };
214
+
215
+ if (!string.IsNullOrEmpty(result.Message))
216
+ entry["message"] = result.Message;
217
+ if (!string.IsNullOrEmpty(result.StackTrace))
218
+ entry["stackTrace"] = result.StackTrace;
219
+
220
+ _results.Add(entry);
221
+ }
222
+
223
+ private static string ResolveTestName(ITestResultAdaptor result)
224
+ {
225
+ if (!string.IsNullOrEmpty(result.FullName))
226
+ return result.FullName;
227
+
228
+ if (result.Test != null)
229
+ {
230
+ if (!string.IsNullOrEmpty(result.Test.FullName))
231
+ return result.Test.FullName;
232
+ if (!string.IsNullOrEmpty(result.Test.Name))
233
+ return result.Test.Name;
234
+ }
235
+
236
+ return result.Name;
237
+ }
238
+ }
239
+ }
240
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 6cb4d794571ded244bda9bb540e7c25f