Skip to content

Commit 0a6a542

Browse files
authored
Internal: XRI package test (#1782)
* added AdddingLatestXRIPackageThrowsNoErrors to test just that
1 parent cc42abb commit 0a6a542

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using System.Collections;
2+
using NUnit.Framework;
3+
using UnityEngine;
4+
using UnityEditor;
5+
using UnityEngine.TestTools;
6+
using UnityEditor.PackageManager;
7+
using UnityEditor.PackageManager.Requests;
8+
9+
// Disable irrelevant warning about there not being underscores in method names.
10+
#pragma warning disable CA1707
11+
12+
public class XRIPackageTests
13+
{
14+
static AddRequest XRAddRequest;
15+
static RemoveRequest XRRemoveRequest;
16+
17+
/// <summary>
18+
/// TearDown removes the added XRI package again.
19+
/// If you are adding a 2nd test that needs the XRI package adjust this.
20+
/// </summary>
21+
/// <returns></returns>
22+
[UnityTearDown]
23+
public IEnumerator TearDown()
24+
{
25+
XRRemoveRequest = Client.Remove("com.unity.xr.interaction.toolkit");
26+
EditorApplication.update += RemoveProgress;
27+
while (!XRRemoveRequest.IsCompleted)
28+
{
29+
yield return null;
30+
}
31+
}
32+
33+
[UnityTest]
34+
[Category("Integration")]
35+
public IEnumerator AdddingLatestXRIPackageThrowsNoErrors()
36+
{
37+
Application.logMessageReceived += HandleLog;
38+
39+
XRAddRequest = Client.Add("com.unity.xr.interaction.toolkit");
40+
EditorApplication.update += AddProgress;
41+
42+
while (!XRAddRequest.IsCompleted)
43+
{
44+
yield return null;
45+
}
46+
47+
AssetDatabase.Refresh();
48+
49+
yield return new WaitForDomainReload();
50+
}
51+
52+
static void AddProgress()
53+
{
54+
if (XRAddRequest.IsCompleted)
55+
{
56+
if (XRAddRequest.Status == StatusCode.Success)
57+
Debug.Log("Installed: " + XRAddRequest.Result.packageId);
58+
else if (XRAddRequest.Status >= StatusCode.Failure)
59+
Debug.Log(XRAddRequest.Error.message);
60+
61+
EditorApplication.update -= AddProgress;
62+
}
63+
}
64+
65+
static void RemoveProgress()
66+
{
67+
if (XRRemoveRequest.IsCompleted)
68+
{
69+
if (XRRemoveRequest.Status == StatusCode.Success)
70+
Debug.Log("Removed: XRI package");
71+
else if (XRRemoveRequest.Status >= StatusCode.Failure)
72+
Debug.Log(XRRemoveRequest.Error.message);
73+
74+
EditorApplication.update -= RemoveProgress;
75+
}
76+
}
77+
78+
void HandleLog(string logString, string stackTrace, LogType type)
79+
{
80+
Assert.That(type, Is.EqualTo(LogType.Log));
81+
}
82+
}

Assets/Tests/InputSystem.Editor/XRIPackageTest.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)