RemotePlayerTestController.cs
2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using UnityEditor.Networking.PlayerConnection;
using UnityEditor.TestTools.TestRunner;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEditor.TestTools.TestRunner.UnityTestProtocol;
using UnityEngine;
using UnityEngine.Networking.PlayerConnection;
using UnityEngine.TestRunner.TestLaunchers;
namespace UnityEditor.TestRunner.TestLaunchers
{
[Serializable]
internal class RemoteTestRunController : ScriptableSingleton<RemoteTestRunController>
{
[SerializeField]
private RemoteTestResultReciever m_RemoteTestResultReciever;
[SerializeField]
private PlatformSpecificSetup m_PlatformSpecificSetup;
[SerializeField]
private bool m_RegisteredConnectionCallbacks;
public void Init(BuildTarget buildTarget)
{
m_PlatformSpecificSetup = new PlatformSpecificSetup(buildTarget);
m_PlatformSpecificSetup.Setup();
m_RemoteTestResultReciever = new RemoteTestResultReciever();
EditorConnection.instance.Initialize();
if (!m_RegisteredConnectionCallbacks)
{
EditorConnection.instance.Initialize();
DelegateEditorConnectionEvents();
}
}
private void DelegateEditorConnectionEvents()
{
m_RegisteredConnectionCallbacks = true;
//This is needed because RemoteTestResultReciever is not a ScriptableObject
EditorConnection.instance.Register(PlayerConnectionMessageIds.runStartedMessageId, RunStarted);
EditorConnection.instance.Register(PlayerConnectionMessageIds.runFinishedMessageId, RunFinished);
EditorConnection.instance.Register(PlayerConnectionMessageIds.testStartedMessageId, TestStarted);
EditorConnection.instance.Register(PlayerConnectionMessageIds.testFinishedMessageId, TestFinished);
}
private void RunStarted(MessageEventArgs messageEventArgs)
{
m_RemoteTestResultReciever.RunStarted(messageEventArgs);
CallbacksDelegator.instance.RunStartedRemotely(messageEventArgs.data);
}
private void RunFinished(MessageEventArgs messageEventArgs)
{
m_RemoteTestResultReciever.RunFinished(messageEventArgs);
m_PlatformSpecificSetup.CleanUp();
CallbacksDelegator.instance.RunFinishedRemotely(messageEventArgs.data);
}
private void TestStarted(MessageEventArgs messageEventArgs)
{
CallbacksDelegator.instance.TestStartedRemotely(messageEventArgs.data);
}
private void TestFinished(MessageEventArgs messageEventArgs)
{
CallbacksDelegator.instance.TestFinishedRemotely(messageEventArgs.data);
}
public void PostBuildAction()
{
m_PlatformSpecificSetup.PostBuildAction();
}
public void PostSuccessfulBuildAction()
{
m_PlatformSpecificSetup.PostSuccessfulBuildAction();
}
}
}