Skip to content

Commit a646793

Browse files
committed
More BasePlayModeTests
1 parent b0169ec commit a646793

File tree

5 files changed

+16
-56
lines changed

5 files changed

+16
-56
lines changed

Assets/MRTK/Tests/PlayModeTests/BaseCursorTests.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace Microsoft.MixedReality.Toolkit.Tests
2323
{
2424
// Tests to verify that cursor state is updated correctly
25-
public class BaseCursorTests
25+
public class BaseCursorTests : BasePlayModeTests
2626
{
2727
// Keeping this low by default so the test runs fast. Increase it to be able to see hand movements in the editor.
2828
private const int numFramesPerMove = 1;
@@ -41,10 +41,10 @@ public class BaseCursorTests
4141
/// for examples.
4242
/// See also comments at <see cref="TestUtilities.PlayspaceToArbitraryPose"/>.
4343
/// </remarks>
44-
[UnitySetUp]
45-
public IEnumerator SetUp()
44+
public override IEnumerator Setup()
4645
{
47-
PlayModeTestUtilities.Setup();
46+
yield return base.Setup();
47+
4848
TestUtilities.PlayspaceToArbitraryPose();
4949

5050
// Target frame rate is set to 50 to match the physics
@@ -69,12 +69,10 @@ public IEnumerator SetUp()
6969
yield return null;
7070
}
7171

72-
[UnityTearDown]
73-
public IEnumerator TearDown()
72+
public override IEnumerator TearDown()
7473
{
7574
Object.Destroy(cube);
76-
TestUtilities.ShutdownMixedRealityToolkit();
77-
yield return null;
75+
yield return base.TearDown();
7876
}
7977

8078
private void VerifyCursorStateFromPointers(IEnumerable<IMixedRealityPointer> pointers, CursorStateEnum state)

Assets/MRTK/Tests/PlayModeTests/BaseEventSystemTests.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,8 @@ namespace Microsoft.MixedReality.Toolkit.Tests
3131
/// (i.e. input and diagnostics are used, but any arbitrary systems that can raise events on demand
3232
/// would work)
3333
/// </remarks>
34-
class BaseEventSystemTests
34+
internal class BaseEventSystemTests : BasePlayModeTests
3535
{
36-
[UnitySetUp]
37-
public IEnumerator Setup()
38-
{
39-
PlayModeTestUtilities.Setup();
40-
yield return null;
41-
}
42-
43-
[UnityTearDown]
44-
public IEnumerator TearDown()
45-
{
46-
PlayModeTestUtilities.TearDown();
47-
yield return null;
48-
}
49-
5036
/// <summary>
5137
/// Test input system catches exception thrown in global listener responding to input event, and
5238
/// that the input system is still able to unregister the event listener (i.e. eventExecutionDepth

Assets/MRTK/Tests/PlayModeTests/BoundsControlTests.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,24 @@ namespace Microsoft.MixedReality.Toolkit.Tests
2727
/// <summary>
2828
/// Tests for runtime behavior of bounds control
2929
/// </summary>
30-
public class BoundsControlTests
30+
public class BoundsControlTests : BasePlayModeTests
3131
{
3232
private Material testMaterial;
3333
private Material testMaterialGrabbed;
3434

3535
#region Utilities
36-
[UnitySetUp]
37-
public IEnumerator Setup()
38-
{
39-
PlayModeTestUtilities.Setup();
4036

37+
public override IEnumerator Setup()
38+
{
4139
// create shared test materials
4240
var shader = StandardShaderUtility.MrtkStandardShader;
4341
testMaterial = new Material(shader);
4442
testMaterial.color = Color.yellow;
4543

4644
testMaterialGrabbed = new Material(shader);
4745
testMaterialGrabbed.color = Color.green;
48-
yield return null;
49-
}
5046

51-
[UnityTearDown]
52-
public IEnumerator TearDown()
53-
{
54-
PlayModeTestUtilities.TearDown();
55-
yield return null;
47+
yield return base.Setup();
5648
}
5749

5850
private readonly Vector3 boundsControlStartCenter = Vector3.forward * 1.5f;

Assets/MRTK/Tests/PlayModeTests/Core/Providers/Hands/BaseHandVisualizerTests.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212

1313
using Microsoft.MixedReality.Toolkit.Input;
1414
using Microsoft.MixedReality.Toolkit.Utilities;
15-
using NUnit.Framework;
1615
using System.Collections;
1716
using UnityEngine;
1817
using UnityEngine.EventSystems;
1918
using UnityEngine.TestTools;
2019

2120
namespace Microsoft.MixedReality.Toolkit.Tests
2221
{
23-
public class BaseHandVisualizerTests
22+
public class BaseHandVisualizerTests : BasePlayModeTests
2423
{
2524
/// <summary>
2625
/// A mock IMixedRealityInputSource, used to test BaseHandVisualizer::OnHandMeshUpdated.
@@ -71,20 +70,6 @@ private class MockController : IMixedRealityController
7170
public bool IsInPointingPose => throw new System.NotImplementedException();
7271
}
7372

74-
[UnitySetUp]
75-
public IEnumerator Setup()
76-
{
77-
PlayModeTestUtilities.Setup();
78-
yield return null;
79-
}
80-
81-
[UnityTearDown]
82-
public IEnumerator TearDown()
83-
{
84-
TestUtilities.ShutdownMixedRealityToolkit();
85-
yield return null;
86-
}
87-
8873
/// <summary>
8974
/// Validates that OnHandMeshUpdated can be called with hand mesh vertices of different
9075
/// lengths and not crash.

Assets/MRTK/Tests/PlayModeTests/SpatialObserverTests.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using NUnit.Framework;
1616
using System.Collections;
1717
using UnityEditor;
18-
using UnityEngine;
1918
using UnityEngine.TestTools;
2019

2120
namespace Microsoft.MixedReality.Toolkit.Tests
@@ -117,9 +116,9 @@ public IEnumerator TestManualStartObserver()
117116
public IEnumerator TestDisableSpatialAwarenessSystem()
118117
{
119118
var mrtkProfile = CreateMRTKTestProfile(TestSpatialAwarenessSystemProfilePath);
120-
119+
121120
mrtkProfile.IsSpatialAwarenessSystemEnabled = false;
122-
121+
123122
TestUtilities.InitializeMixedRealityToolkit(mrtkProfile);
124123
yield return PlayModeTestUtilities.WaitForInputSystemUpdate();
125124

@@ -129,11 +128,11 @@ public IEnumerator TestDisableSpatialAwarenessSystem()
129128
private static MixedRealityToolkitConfigurationProfile CreateMRTKTestProfile(string spatialAwarenessSystemPath)
130129
{
131130
var mrtkProfile = TestUtilities.GetDefaultMixedRealityProfile<MixedRealityToolkitConfigurationProfile>();
132-
131+
133132
mrtkProfile.SpatialAwarenessSystemSystemType = new SystemType(typeof(MixedRealitySpatialAwarenessSystem));
134133
mrtkProfile.IsSpatialAwarenessSystemEnabled = true;
135134
mrtkProfile.SpatialAwarenessSystemProfile = AssetDatabase.LoadAssetAtPath<MixedRealitySpatialAwarenessSystemProfile>(spatialAwarenessSystemPath);
136-
135+
137136
return mrtkProfile;
138137
}
139138
}

0 commit comments

Comments
 (0)