-
Notifications
You must be signed in to change notification settings - Fork 333
Expand file tree
/
Copy pathXRIPackageTest.cs
More file actions
88 lines (74 loc) · 2.48 KB
/
XRIPackageTest.cs
File metadata and controls
88 lines (74 loc) · 2.48 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
82
83
84
85
86
87
88
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEditor;
using UnityEngine.TestTools;
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;
// Disable irrelevant warning about there not being underscores in method names.
#pragma warning disable CA1707
public class XRIPackageTests
{
static AddRequest XRAddRequest;
static RemoveRequest XRRemoveRequest;
/// <summary>
/// TearDown removes the added XRI package again.
/// If you are adding a 2nd test that needs the XRI package adjust this.
/// </summary>
/// <returns></returns>
[UnityTearDown]
public IEnumerator TearDown()
{
XRRemoveRequest = Client.Remove("com.unity.xr.interaction.toolkit");
EditorApplication.update += RemoveProgress;
while (!XRRemoveRequest.IsCompleted)
{
yield return null;
}
//Delete the Assets/XRI folder (and its content) that the XRI package creates
if (AssetDatabase.IsValidFolder("Assets/XRI"))
{
AssetDatabase.DeleteAsset("Assets/XRI");
}
}
[UnityTest]
[Category("Integration")]
public IEnumerator AddingLatestXRIPackageThrowsNoErrors()
{
Application.logMessageReceived += HandleLog;
XRAddRequest = Client.Add("com.unity.xr.interaction.toolkit");
EditorApplication.update += AddProgress;
while (!XRAddRequest.IsCompleted)
{
yield return null;
}
AssetDatabase.Refresh();
yield return new WaitForDomainReload();
}
static void AddProgress()
{
if (XRAddRequest.IsCompleted)
{
if (XRAddRequest.Status == StatusCode.Success)
Debug.Log("Installed: " + XRAddRequest.Result.packageId);
else if (XRAddRequest.Status >= StatusCode.Failure)
Debug.Log(XRAddRequest.Error.message);
EditorApplication.update -= AddProgress;
}
}
static void RemoveProgress()
{
if (XRRemoveRequest.IsCompleted)
{
if (XRRemoveRequest.Status == StatusCode.Success)
Debug.Log("Removed: XRI package");
else if (XRRemoveRequest.Status >= StatusCode.Failure)
Debug.Log(XRRemoveRequest.Error.message);
EditorApplication.update -= RemoveProgress;
}
}
void HandleLog(string logString, string stackTrace, LogType type)
{
Assert.That(type, Is.EqualTo(LogType.Log));
}
}