first commit

This commit is contained in:
lethanhsonvsp
2025-11-17 15:36:52 +07:00
commit 6f2eafa33c
14093 changed files with 1253472 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3610673068254436ac90019f46e09f01
timeCreated: 1686043510

View File

@@ -0,0 +1,23 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
// This class is used for serialization purposes
// which requires public access to fields and a default empty constructor
[Serializable]
internal class BuildSettings
{
public BuildSettings(string platform, string buildTarget, bool developmentPlayer, string androidBuildSystem = "")
{
Platform = platform;
BuildTarget = buildTarget;
DevelopmentPlayer = developmentPlayer;
AndroidBuildSystem = androidBuildSystem;
}
public string Platform;
public string BuildTarget;
public bool DevelopmentPlayer;
public string AndroidBuildSystem;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f699428dfee64165b017dced94d8ca70
timeCreated: 1686043529

View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
// This class is used for serialization purposes
// which requires public access to fields and a default empty constructor
[Serializable]
internal class PlayerSettings
{
public string ScriptingBackend;
public bool MtRendering;
public bool GraphicsJobs;
public bool GpuSkinning;
public string GraphicsApi;
public string Batchmode;
public string StereoRenderingPath;
public string RenderThreadingMode;
public string AndroidMinimumSdkVersion;
public string AndroidTargetSdkVersion;
public string ScriptingRuntimeVersion;
public string AndroidTargetArchitecture;
public bool StripEngineCode;
public PlayerSettings(
string scriptingBackend,
bool gpuSkinning,
string graphicsApi,
string batchmode,
string stereoRenderingPath,
string renderThreadingMode,
string androidTargetSdkVersion,
string androidMinimumSdkVersion = "",
bool graphicsJobs = false,
bool mtRendering = false
)
{
ScriptingBackend = scriptingBackend;
GpuSkinning = gpuSkinning;
GraphicsApi = graphicsApi;
Batchmode = batchmode;
StereoRenderingPath = stereoRenderingPath;
RenderThreadingMode = renderThreadingMode;
AndroidTargetSdkVersion = androidTargetSdkVersion;
AndroidMinimumSdkVersion = androidMinimumSdkVersion;
GraphicsJobs = graphicsJobs;
MtRendering = mtRendering;
}
public PlayerSettings() { }
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d52ad1cdc75642419ac24e88b43a3821
timeCreated: 1686044146

View File

@@ -0,0 +1,35 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
// This class is used for serialization purposes
// which requires public access to fields and a default empty constructor
[Serializable]
internal class PlayerSystemInfo
{
public PlayerSystemInfo() { }
public PlayerSystemInfo(string operatingSystem, string deviceModel, string deviceName, string processorType, int processorCount, string graphicsDeviceName, int systemMemorySize, string xrModel = "", string xrDevice = "")
{
OperatingSystem = operatingSystem;
DeviceModel = deviceModel;
DeviceName = deviceName;
ProcessorType = processorType;
ProcessorCount = processorCount;
GraphicsDeviceName = graphicsDeviceName;
SystemMemorySize = systemMemorySize;
XrModel = xrModel;
XrDevice = xrDevice;
}
public string OperatingSystem;
public string DeviceModel;
public string DeviceName;
public string ProcessorType;
public int ProcessorCount;
public string GraphicsDeviceName;
public int SystemMemorySize;
public string XrModel;
public string XrDevice;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7ee0c4baf94a41009b0f9292988a2000
timeCreated: 1686044561

View File

@@ -0,0 +1,27 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
// This class is used for serialization purposes
// which requires public access to fields and a default empty constructor
[Serializable]
internal class QualitySettings
{
public QualitySettings(int vsync, int antiAliasing, string colorSpace, string anisotropicFiltering, string blendWeights)
{
Vsync = vsync;
AntiAliasing = antiAliasing;
ColorSpace = colorSpace;
AnisotropicFiltering = anisotropicFiltering;
BlendWeights = blendWeights;
}
public QualitySettings(){}
public int Vsync;
public int AntiAliasing;
public string ColorSpace;
public string AnisotropicFiltering;
public string BlendWeights;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: efce3ac61ba34d3590656de761a677e3
timeCreated: 1686048374

View File

@@ -0,0 +1,25 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
// This class is used for serialization purposes
// which requires public access to fields and a default empty constructor
[Serializable]
internal class ScreenSettings
{
public ScreenSettings(int screenWidth, int screenHeight, int screenRefreshRate, bool fullscreen)
{
ScreenWidth = screenWidth;
ScreenHeight = screenHeight;
ScreenRefreshRate = screenRefreshRate;
Fullscreen = fullscreen;
}
public ScreenSettings() { }
public int ScreenWidth;
public int ScreenHeight;
public int ScreenRefreshRate;
public bool Fullscreen;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 58a43a62ecbe444d963930822e17d4cd
timeCreated: 1686044804

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using UnityEditor.TestTools.TestRunner.Api;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal interface ITestRunnerApiMapper
{
string GetRunStateFromResultNunitXml(ITestResultAdaptor result);
TestState GetTestStateFromResult(ITestResultAdaptor result);
List<string> FlattenTestNames(ITestAdaptor testsToRun);
TestPlanMessage MapTestToTestPlanMessage(ITestAdaptor testsToRun);
TestStartedMessage MapTestToTestStartedMessage(ITestAdaptor test);
TestFinishedMessage TestResultToTestFinishedMessage(ITestResultAdaptor result);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6de79ae237e51554da96fd28f68b66a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal interface IUtpLogger
{
void Log(Message msg);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9014630255533ed42915965b4065cde8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
using System;
using UnityEditor.TestTools.TestRunner.Api;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal interface IUtpMessageReporter
{
void ReportTestFinished(ITestResultAdaptor result);
void ReportTestRunStarted(ITestAdaptor testsToRun);
void ReportTestStarted(ITestAdaptor test);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 952b3dc7b47846947b37c8d3ae46579a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9ea154c33fd8466f973f004e5c962df7
timeCreated: 1685970469

View File

@@ -0,0 +1,15 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
[Serializable]
internal class BuildSettingsMessage : Message
{
public BuildSettingsMessage()
{
type = "BuildSettings";
}
public BuildSettings BuildSettings;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3b3dcba2081245eb916aee8fd3459fc8
timeCreated: 1685970410

View File

@@ -0,0 +1,12 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class EditorVersionMessage : Message
{
public EditorVersionMessage()
{
type = "EditorVersion";
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 02ef7627f46742ae83071af8bf22f1af
timeCreated: 1685970427

View File

@@ -0,0 +1,29 @@
using System;
using System.Diagnostics;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
[Serializable]
internal abstract class Message
{
public string type;
// Milliseconds since unix epoch
public ulong time;
public int version;
public string phase;
public int processId;
protected Message()
{
version = 2;
phase = "Immediate";
processId = Process.GetCurrentProcess().Id;
AddTimeStamp();
}
public void AddTimeStamp()
{
time = Convert.ToUInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 321dc2c0720f8dd4f9396ecdc12b8746
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
[Serializable]
internal class PlayerSettingsMessage : Message
{
public PlayerSettings PlayerSettings;
public PlayerSettingsMessage()
{
type = "PlayerSettings";
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aa5e75ed0aae4030a1720d08f7a5322e
timeCreated: 1685970448

View File

@@ -0,0 +1,14 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
[Serializable]
internal class PlayerSystemInfoMessage : Message
{
public PlayerSystemInfo PlayerSystemInfo;
public PlayerSystemInfoMessage()
{
type = "PlayerSystemInfo";
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9f33b8e923ff41deaa73bc2c1f90d9a1
timeCreated: 1685970484

View File

@@ -0,0 +1,14 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
[Serializable]
internal class QualitySettingsMessage : Message
{
public QualitySettings QualitySettings;
public QualitySettingsMessage()
{
type = "QualitySettings";
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6cf74526594248e88be90b91eb2dbe1c
timeCreated: 1685970506

View File

@@ -0,0 +1,14 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class ScreenSettingsMessage : Message
{
public ScreenSettings ScreenSettings;
public ScreenSettingsMessage()
{
type = "ScreenSettings";
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3936a208997f4266b0b2d48aaca1e904
timeCreated: 1685970523

View File

@@ -0,0 +1,23 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class TestFinishedMessage : Message
{
public string name;
public TestState state;
public string message;
public ulong duration; // milliseconds
public ulong durationMicroseconds;
public string stackTrace;
public string fileName;
public int lineNumber;
public int iteration;
public TestFinishedMessage()
{
type = "TestStatus";
phase = "End";
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 423fe2ef878fa1140a7e1f7f9e365815
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class TestPlanMessage : Message
{
public List<string> tests;
public TestPlanMessage()
{
type = "TestPlan";
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 28f79a0d7e64c2345bc46f8c4cf788f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class TestStartedMessage : Message
{
public string name;
public TestState state;
public TestStartedMessage()
{
type = "TestStatus";
phase = "Begin";
state = TestState.Inconclusive;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bd3e81baa10021f4d877fa36382bab16
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace UnityEditor.TestRunner.UnityTestProtocol
{
[Obsolete("No longer in use")]
public interface ITestRunDataHolder
{
IList<TestRunData> TestRunDataList { get; }
}
[Obsolete("No longer in use")]
public class TestRunDataHolder: ScriptableSingleton<TestRunDataHolder>, ISerializationCallbackReceiver, ITestRunDataHolder
{
[SerializeField]
private TestRunData[] TestRunData;
public IList<TestRunData> TestRunDataList { get; private set; } = new List<TestRunData>();
public void OnBeforeSerialize()
{
TestRunData = TestRunDataList.ToArray();
}
public void OnAfterDeserialize()
{
TestRunDataList = TestRunData.ToList();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7dc341f3ffc346738912e0ae5aa6c7e4
timeCreated: 1699443220

View File

@@ -0,0 +1,13 @@
using System;
namespace UnityEditor.TestRunner.UnityTestProtocol
{
[Serializable]
public class TestRunData
{
public string SuiteName;
public string[] TestsInFixture;
public long OneTimeSetUpDuration;
public long OneTimeTearDownDuration;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0fc9f45e5db884c07b28ac7207622a4b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEditor.TestTools.TestRunner.GUI;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class TestRunnerApiMapper : ITestRunnerApiMapper
{
internal IGuiHelper guiHelper = new GuiHelper(new MonoCecilHelper(), new AssetsDatabaseHelper());
private readonly string _projectRepoPath;
public TestRunnerApiMapper(string projectRepoPath)
{
_projectRepoPath = projectRepoPath;
}
public TestPlanMessage MapTestToTestPlanMessage(ITestAdaptor testsToRun)
{
var testsNames = testsToRun != null ? FlattenTestNames(testsToRun) : new List<string>();
var msg = new TestPlanMessage
{
tests = testsNames
};
return msg;
}
public TestStartedMessage MapTestToTestStartedMessage(ITestAdaptor test)
{
return new TestStartedMessage
{
name = test.FullName
};
}
public TestFinishedMessage TestResultToTestFinishedMessage(ITestResultAdaptor result)
{
string filePathString = default;
int lineNumber = default;
if (result.Test.Method != null && result.Test.TypeInfo != null)
{
var method = result.Test.Method.MethodInfo;
var type = result.Test.TypeInfo.Type;
var fileOpenInfo = guiHelper.GetFileOpenInfo(type, method);
filePathString = !string.IsNullOrEmpty(_projectRepoPath) ? Path.Combine(_projectRepoPath, fileOpenInfo.FilePath) : fileOpenInfo.FilePath;
lineNumber = fileOpenInfo.LineNumber;
}
var iteration = 0;
if(result is TestResultAdaptor)
{
var adaptor = ((TestResultAdaptor)result);
iteration = adaptor.RepeatIteration == 0 ? adaptor.RetryIteration : adaptor.RepeatIteration;
}
return new TestFinishedMessage
{
name = result.Test.FullName,
duration = Convert.ToUInt64(result.Duration * 1000),
durationMicroseconds = Convert.ToUInt64(result.Duration * 1000000),
message = result.Message,
state = GetTestStateFromResult(result),
stackTrace = result.StackTrace,
fileName = filePathString,
lineNumber = lineNumber,
iteration = iteration
};
}
public string GetRunStateFromResultNunitXml(ITestResultAdaptor result)
{
var doc = new XmlDocument();
doc.LoadXml(result.ToXml().OuterXml);
return doc.FirstChild.Attributes["runstate"].Value;
}
public TestState GetTestStateFromResult(ITestResultAdaptor result)
{
var state = TestState.Failure;
if (result.TestStatus == TestStatus.Passed)
{
state = TestState.Success;
}
else if (result.TestStatus == TestStatus.Skipped)
{
state = TestState.Skipped;
if (result.ResultState.ToLowerInvariant().EndsWith("ignored"))
{
state = TestState.Ignored;
}
}
else
{
if (result.ResultState.ToLowerInvariant().Equals("inconclusive"))
{
state = TestState.Inconclusive;
}
if (result.ResultState.ToLowerInvariant().EndsWith("cancelled") ||
result.ResultState.ToLowerInvariant().EndsWith("error"))
{
state = TestState.Error;
}
}
return state;
}
public List<string> FlattenTestNames(ITestAdaptor test)
{
var results = new List<string>();
if (!test.IsSuite)
results.Add(test.FullName);
if (test.Children != null && test.Children.Any())
foreach (var child in test.Children)
results.AddRange(FlattenTestNames(child));
return results;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2011a59d3f76b3d4a85cb53f945fceee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using System;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
// This matches the state definitions expected by the Perl code, which in turn matches the NUnit 2 values...
internal enum TestState
{
Inconclusive = 0,
Skipped = 2,
Ignored = 3,
Success = 4,
Failure = 5,
Error = 6
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 77f432980bb30084299a138e15c6f571
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using System;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class UnityTestProtocolListener : ICallbacks
{
private IUtpMessageReporter m_UtpMessageReporter;
public UnityTestProtocolListener(string projectPath)
{
m_UtpMessageReporter = new UtpMessageReporter(new UtpDebugLogger(), projectPath);
}
public void RunStarted(ITestAdaptor testsToRun)
{
m_UtpMessageReporter.ReportTestRunStarted(testsToRun);
}
public void RunFinished(ITestResultAdaptor testResults)
{
// Apparently does nothing :)
}
public void TestStarted(ITestAdaptor test)
{
m_UtpMessageReporter.ReportTestStarted(test);
}
public void TestFinished(ITestResultAdaptor result)
{
m_UtpMessageReporter.ReportTestFinished(result);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 900aac3710bc14542a8d164e3f0ff820
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
[InitializeOnLoad]
internal static class UnityTestProtocolStarter
{
static UnityTestProtocolStarter()
{
var commandLineArgs = Environment.GetCommandLineArgs();
//Ensuring that it is used only when tests are run using UTR.
if (IsEnabled())
{
var api = ScriptableObject.CreateInstance<TestRunnerApi>();
var listener = new UnityTestProtocolListener(GetRepositoryPath(commandLineArgs));
api.RegisterCallbacks(listener);
}
}
internal static bool IsEnabled()
{
var commandLineArgs = Environment.GetCommandLineArgs();
return commandLineArgs.Contains("-automated") && commandLineArgs.Contains("-runTests");
}
private static string GetRepositoryPath(IReadOnlyList<string> commandLineArgs)
{
for (var i = 0; i < commandLineArgs.Count; i++)
{
if (commandLineArgs[i].Equals("-projectRepositoryPath"))
{
return commandLineArgs[i + 1];
}
}
return string.Empty;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1ac58cb55fc8daf4abd3945a2bbbb0c5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using System;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class UtpDebugLogger : IUtpLogger
{
internal const string UtpPrefix = "\n##utp:";
public void Log(Message msg)
{
var msgJson = JsonUtility.ToJson(msg);
Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "{0}{1}", UtpPrefix, msgJson);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d0abdd8cb6b29a24c8ee19626ef741b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,113 @@
#if UNITY_2022_2_OR_NEWER
using System;
#endif
using UnityEditor.Build;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal static class UtpMessageBuilder
{
internal static ScreenSettingsMessage BuildScreenSettings()
{
#if UNITY_2022_2_OR_NEWER
// casting to int and rounding to ensure backwards compatibility with older package versions
var screenRefreshRate = (int)Math.Round(Screen.currentResolution.refreshRateRatio.value);
#else
var screenRefreshRate = Screen.currentResolution.refreshRate;
#endif
var screenSettingsMessage = new ScreenSettingsMessage()
{
ScreenSettings = new ScreenSettings(Screen.currentResolution.width, Screen.currentResolution.height, screenRefreshRate, Screen.fullScreen)
};
return screenSettingsMessage;
}
public static QualitySettingsMessage BuildQualitySettings()
{
var qualitySettingsMessage = new QualitySettingsMessage()
{
QualitySettings = new QualitySettings(
UnityEngine.QualitySettings.vSyncCount,
UnityEngine.QualitySettings.antiAliasing,
UnityEngine.QualitySettings.activeColorSpace.ToString(),
UnityEngine.QualitySettings.anisotropicFiltering.ToString(),
UnityEngine.QualitySettings.skinWeights.ToString()
),
};
return qualitySettingsMessage;
}
internal static PlayerSystemInfoMessage BuildPlayerSystemInfo()
{
var xrDevice = string.Empty;
var XrModel = string.Empty;
#if ENABLE_XR
xrDevice = UnityEngine.XR.XRSettings.loadedDeviceName;
XrModel = UnityEngine.XR.XRDevice.model;
#endif
var playerSystemInfoMessage = new PlayerSystemInfoMessage()
{
PlayerSystemInfo = new PlayerSystemInfo(
SystemInfo.operatingSystem,
SystemInfo.deviceModel,
SystemInfo.deviceName,
SystemInfo.processorType,
SystemInfo.processorCount,
SystemInfo.graphicsDeviceName,
SystemInfo.systemMemorySize,
XrModel,
xrDevice
),
};
return playerSystemInfoMessage;
}
internal static PlayerSettingsMessage BuildPlayerSettings()
{
var scriptingBackend = string.Empty;
#if UNITY_2021_2_OR_NEWER
scriptingBackend =
UnityEditor.PlayerSettings.GetScriptingBackend(NamedBuildTarget.FromBuildTargetGroup(EditorUserBuildSettings.selectedBuildTargetGroup)).ToString();
#else
scriptingBackend = UnityEditor.PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup).ToString();
#endif
var playerSettingsMessage = new PlayerSettingsMessage()
{
PlayerSettings = new PlayerSettings(
scriptingBackend,
UnityEditor.PlayerSettings.gpuSkinning,
string.Empty,
UnityEditorInternal.InternalEditorUtility.inBatchMode.ToString(),
UnityEditor.PlayerSettings.stereoRenderingPath.ToString(),
UnityEditor.PlayerSettings.graphicsJobs ? "GraphicsJobs" : UnityEditor.PlayerSettings.MTRendering ? "MultiThreaded" : "SingleThreaded",
UnityEditor.PlayerSettings.Android.targetSdkVersion.ToString(),
UnityEditor.PlayerSettings.Android.minSdkVersion.ToString(),
UnityEditor.PlayerSettings.graphicsJobs,
UnityEditor.PlayerSettings.MTRendering
),
};
return playerSettingsMessage;
}
internal static BuildSettingsMessage BuildBuildSettings()
{
var buildSettingsMessage = new BuildSettingsMessage()
{
BuildSettings = new BuildSettings(
Application.platform.ToString(),
EditorUserBuildSettings.activeBuildTarget.ToString(),
EditorUserBuildSettings.development,
EditorUserBuildSettings.androidBuildSystem.ToString()
)
};
return buildSettingsMessage;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 319fe8cda376431bb7987d94f916819b
timeCreated: 1686048598

View File

@@ -0,0 +1,48 @@
using UnityEditor.TestTools.TestRunner.Api;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class UtpMessageReporter : IUtpMessageReporter
{
public ITestRunnerApiMapper TestRunnerApiMapper;
public IUtpLogger Logger;
public UtpMessageReporter(IUtpLogger utpLogger, string projectRepoPath)
{
TestRunnerApiMapper = new TestRunnerApiMapper(projectRepoPath);
Logger = utpLogger;
}
public void ReportTestRunStarted(ITestAdaptor testsToRun)
{
var testPlanMessage = TestRunnerApiMapper.MapTestToTestPlanMessage(testsToRun);
Logger.Log(testPlanMessage);
Logger.Log(UtpMessageBuilder.BuildScreenSettings());
Logger.Log(UtpMessageBuilder.BuildPlayerSettings());
Logger.Log(UtpMessageBuilder.BuildBuildSettings());
Logger.Log(UtpMessageBuilder.BuildPlayerSystemInfo());
Logger.Log(UtpMessageBuilder.BuildQualitySettings());
}
public void ReportTestStarted(ITestAdaptor test)
{
if (test.IsSuite)
return;
var msg = TestRunnerApiMapper.MapTestToTestStartedMessage(test);
Logger.Log(msg);
}
public void ReportTestFinished(ITestResultAdaptor result)
{
if (result.Test.IsSuite)
return;
var msg = TestRunnerApiMapper.TestResultToTestFinishedMessage(result);
Logger.Log(msg);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ebcc5f899d9277642868aeda9a17cbaf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: