@mflrevan/ucp 0.4.0 → 0.4.1
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.
- package/README.md +2 -2
- package/package.json +8 -2
- package/bridge/com.ucp.bridge/CHANGELOG.md +0 -128
- package/bridge/com.ucp.bridge/CHANGELOG.md.meta +0 -7
- package/bridge/com.ucp.bridge/Editor/Bridge/BridgeServer.cs +0 -576
- package/bridge/com.ucp.bridge/Editor/Bridge/BridgeServer.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Bridge.meta +0 -8
- package/bridge/com.ucp.bridge/Editor/Controllers/AssetController.cs +0 -530
- package/bridge/com.ucp.bridge/Editor/Controllers/AssetController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/BuildController.cs +0 -230
- package/bridge/com.ucp.bridge/Editor/Controllers/BuildController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/CompilationController.cs +0 -26
- package/bridge/com.ucp.bridge/Editor/Controllers/CompilationController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/EditorController.cs +0 -18
- package/bridge/com.ucp.bridge/Editor/Controllers/EditorController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/EditorSettingsController.cs +0 -438
- package/bridge/com.ucp.bridge/Editor/Controllers/EditorSettingsController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/FileController.cs +0 -145
- package/bridge/com.ucp.bridge/Editor/Controllers/FileController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/HierarchyController.cs +0 -319
- package/bridge/com.ucp.bridge/Editor/Controllers/HierarchyController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/LogsController.cs +0 -288
- package/bridge/com.ucp.bridge/Editor/Controllers/LogsController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/MaterialController.cs +0 -295
- package/bridge/com.ucp.bridge/Editor/Controllers/MaterialController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/ObjectReferenceResolver.cs +0 -93
- package/bridge/com.ucp.bridge/Editor/Controllers/ObjectReferenceResolver.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/PlayModeController.cs +0 -84
- package/bridge/com.ucp.bridge/Editor/Controllers/PlayModeController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/PrefabController.cs +0 -242
- package/bridge/com.ucp.bridge/Editor/Controllers/PrefabController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/PropertyController.cs +0 -533
- package/bridge/com.ucp.bridge/Editor/Controllers/PropertyController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/SceneController.cs +0 -269
- package/bridge/com.ucp.bridge/Editor/Controllers/SceneController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/ScreenshotController.cs +0 -125
- package/bridge/com.ucp.bridge/Editor/Controllers/ScreenshotController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/ScriptController.cs +0 -104
- package/bridge/com.ucp.bridge/Editor/Controllers/ScriptController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/SnapshotController.cs +0 -227
- package/bridge/com.ucp.bridge/Editor/Controllers/SnapshotController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/TestRunnerController.cs +0 -240
- package/bridge/com.ucp.bridge/Editor/Controllers/TestRunnerController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers/VcsController.cs +0 -611
- package/bridge/com.ucp.bridge/Editor/Controllers/VcsController.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Controllers.meta +0 -8
- package/bridge/com.ucp.bridge/Editor/Protocol/CommandRouter.cs +0 -53
- package/bridge/com.ucp.bridge/Editor/Protocol/CommandRouter.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Protocol/MessageTypes.cs +0 -80
- package/bridge/com.ucp.bridge/Editor/Protocol/MessageTypes.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Protocol/MiniJson.cs +0 -358
- package/bridge/com.ucp.bridge/Editor/Protocol/MiniJson.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Protocol.meta +0 -8
- package/bridge/com.ucp.bridge/Editor/Scripts/IUCPScript.cs +0 -37
- package/bridge/com.ucp.bridge/Editor/Scripts/IUCPScript.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Editor/Scripts.meta +0 -8
- package/bridge/com.ucp.bridge/Editor/UCP.Bridge.Editor.asmdef +0 -16
- package/bridge/com.ucp.bridge/Editor/UCP.Bridge.Editor.asmdef.meta +0 -7
- package/bridge/com.ucp.bridge/Editor.meta +0 -8
- package/bridge/com.ucp.bridge/Runtime/UCP.Bridge.Runtime.asmdef +0 -14
- package/bridge/com.ucp.bridge/Runtime/UCP.Bridge.Runtime.asmdef.meta +0 -7
- package/bridge/com.ucp.bridge/Runtime.meta +0 -8
- package/bridge/com.ucp.bridge/Tests/Editor/ControllerSmokeTests.cs +0 -670
- package/bridge/com.ucp.bridge/Tests/Editor/ControllerSmokeTests.cs.meta +0 -2
- package/bridge/com.ucp.bridge/Tests/Editor/UCP.Bridge.Editor.Tests.asmdef +0 -12
- package/bridge/com.ucp.bridge/Tests/Editor/UCP.Bridge.Editor.Tests.asmdef.meta +0 -7
- package/bridge/com.ucp.bridge/Tests/Editor.meta +0 -8
- package/bridge/com.ucp.bridge/Tests.meta +0 -8
- package/bridge/com.ucp.bridge/package.json +0 -27
- package/bridge/com.ucp.bridge/package.json.meta +0 -7
|
@@ -1,227 +0,0 @@
|
|
|
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.InstanceIDToObject(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
|
-
}
|
|
@@ -1,240 +0,0 @@
|
|
|
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
|
-
}
|