三国卡牌客户端基础资源仓库
yyl
18 小时以前 cec146fc3fe287928e075c79ece20a20a9b16b20
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
using System;
using UnityEditor;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine;
 
namespace Microsoft.Unity.VisualStudio.Editor.Testing
{
    [InitializeOnLoad]
    internal class TestRunnerApiListener
    {
        private static readonly TestRunnerApi _testRunnerApi;
        private static readonly TestRunnerCallbacks _testRunnerCallbacks;
 
        static TestRunnerApiListener()
        {
            if (!VisualStudioEditor.IsEnabled)
                return;
 
            _testRunnerApi = ScriptableObject.CreateInstance<TestRunnerApi>();
            _testRunnerCallbacks = new TestRunnerCallbacks();
 
            _testRunnerApi.RegisterCallbacks(_testRunnerCallbacks);
        }
 
        public static void RetrieveTestList(string mode)
        {
            RetrieveTestList((TestMode) Enum.Parse(typeof(TestMode), mode));
        }
 
        private static void RetrieveTestList(TestMode mode)
        {
            _testRunnerApi?.RetrieveTestList(mode, ta => _testRunnerCallbacks.TestListRetrieved(mode, ta));
        }
 
        public static void ExecuteTests(string command)
        {
            // ExecuteTests format:
            // TestMode:FullName
 
            var index = command.IndexOf(':');
            if (index < 0)
                return;
 
            var testMode = (TestMode)Enum.Parse(typeof(TestMode), command.Substring(0, index));
            var filter = command.Substring(index + 1);
 
            ExecuteTests(new Filter { testMode = testMode, testNames = new [] { filter } });
        }
 
        private static void ExecuteTests(Filter filter)
        {
            _testRunnerApi?.Execute(new ExecutionSettings(filter));
        }
    }
}