summaryrefslogtreecommitdiff
path: root/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestLaunchers/RemotePlayerLogController.cs
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-04-19 17:19:32 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-04-19 17:19:32 -0400
commitc55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 (patch)
treeee4d51c7c1d633e11f46453ef1edd3c77c4ef9f7 /Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestLaunchers/RemotePlayerLogController.cs
downloadProject-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.gz
Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.bz2
Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.zip
Inital commit
Diffstat (limited to 'Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestLaunchers/RemotePlayerLogController.cs')
-rw-r--r--Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestLaunchers/RemotePlayerLogController.cs83
1 files changed, 83 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestLaunchers/RemotePlayerLogController.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestLaunchers/RemotePlayerLogController.cs
new file mode 100644
index 0000000..ebdf71e
--- /dev/null
+++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestLaunchers/RemotePlayerLogController.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using UnityEditor.DeploymentTargets;
+using UnityEditor.TestTools.TestRunner.CommandLineTest;
+using UnityEngine;
+
+namespace UnityEditor.TestRunner.TestLaunchers
+{
+ [Serializable]
+ internal class RemotePlayerLogController : ScriptableSingleton<RemotePlayerLogController>
+ {
+ private List<LogWriter> m_LogWriters;
+
+ private Dictionary<string, DeploymentTargetLogger> m_Loggers;
+
+ private string m_DeviceLogsDirectory;
+
+ public void SetBuildTarget(BuildTarget buildTarget)
+ {
+ m_Loggers = GetDeploymentTargetLoggers(buildTarget);
+ }
+
+ public void SetLogsDirectory(string dir)
+ {
+ m_DeviceLogsDirectory = dir;
+ }
+
+ public void StartLogWriters()
+ {
+ if (m_DeviceLogsDirectory == null || m_Loggers == null)
+ return;
+
+ m_LogWriters = new List<LogWriter>();
+
+ foreach (var logger in m_Loggers)
+ {
+ m_LogWriters.Add(new LogWriter(m_DeviceLogsDirectory, logger.Key, logger.Value));
+ logger.Value.Start();
+ }
+ }
+
+ public void StopLogWriters()
+ {
+ if (m_LogWriters == null)
+ return;
+
+ foreach (var logWriter in m_LogWriters)
+ {
+ logWriter.Stop();
+ }
+ }
+
+ private Dictionary<string, DeploymentTargetLogger> GetDeploymentTargetLoggers(BuildTarget buildTarget)
+ {
+ DeploymentTargetManager deploymentTargetManager;
+
+ try
+ {
+ deploymentTargetManager = DeploymentTargetManager.CreateInstance(EditorUserBuildSettings.activeBuildTargetGroup, buildTarget);
+ }
+ catch (NotSupportedException ex)
+ {
+ Debug.Log(ex.Message);
+ Debug.Log("Deployment target logger not initialised");
+ return null;
+ }
+
+ var targets = deploymentTargetManager.GetKnownTargets();
+ var loggers = new Dictionary<string, DeploymentTargetLogger>();
+
+ foreach (var target in targets)
+ {
+ if (target.status != DeploymentTargetStatus.Ready) continue;
+
+ var logger = deploymentTargetManager.GetTargetLogger(target.id);
+ logger.Clear();
+ loggers.Add(target.id, logger);
+ }
+
+ return loggers;
+ }
+ }
+}